#!/usr/bin/php -q debug = true; } if ($html) { $spiker->html = true; } else { $spiker->html = false; } if ($dryrun) { $spiker->dryrun = true; } else { $spiker->dryrun = false; } $result = $spiker->remove_spikes(); if (!$result) { print "ERROR: Remove Spikes experienced errors\n"; print $spiker->get_errors(); exit(-1); } else { print $spiker->get_output(); exit(0); } /* display_version - displays version information */ function display_version() { $version = get_cacti_cli_version(); print "Cacti Spike Remover Utility, Version $version, " . COPYRIGHT_YEARS . "\n"; } /* display_help - displays the usage of the function */ function display_help () { display_version(); print "\nusage: removespikes.php -R|--rrdfile=rrdfile [-M|--method=stddev] [-A|--avgnan] [-S|--stddev=N]\n"; print " [-O|--outliers=N | --outlier-start=YYYY-MM-DD HH:MM --outlier-end=YYYY-MM-DD HH:MM]\n"; print " [-P|--percent=N] [-N|--number=N] [-D|--dryrun] [-d|--debug]\n"; print " [--html]\n\n"; print "A utility to programatically remove spikes from Cacti graphs. If no optional input parameters\n"; print "are specified the defaults are taken from the Cacti database.\n\n"; print "Required:\n"; print " --rrdfile=F - The path to the RRDfile that will be de-spiked.\n\n"; print "Optional:\n"; print " --method - The spike removal method to use. Options are stddev|variance|fill|float\n"; print " --avgnan - The spike replacement method to use. Options are last|avg|nan\n"; print " --stddev - The number of standard deviations +/- allowed\n"; print " --percent - The sample to sample percentage variation allowed\n"; print " --number - The maximum number of spikes to remove from the RRDfile\n"; print " --outlier-start - A start date of an incident where all data should be considered\n"; print " invalid data and should be excluded from average calculations.\n"; print " --outlier-end - An end date of an incident where all data should be considered\n"; print " invalid data and should be excluded from average calculations.\n"; print " --outliers - The number of outliers to ignore when calculating average.\n"; print " --dryrun - If specified, the RRDfile will not be changed. Instead a summary of\n"; print " changes that would have been performed will be issued.\n"; print " --backup - Backup the original RRDfile to preserve prior values.\n\n"; print "The remainder of arguments are informational\n"; print " --html - Format the output for a web browser\n"; print " --debug - Display verbose output during execution\n"; }