add --snet-alarms option to suppress excess range alarms

Some users may not want to have alarms about ranges that are part of a
shared-network, so allow them to suppress such.

Requested-by: Frank Bulk <fbulk@mypremieronline.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2015-11-27 23:42:23 +00:00
parent 99b6af70ef
commit 7f3d553c7f
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
4 changed files with 17 additions and 1 deletions

View file

@ -161,6 +161,12 @@ is
If critical percentage is not specified it defaults to If critical percentage is not specified it defaults to
.BR @ALARM_CRIT@ . .BR @ALARM_CRIT@ .
.TP .TP
\fB\-\-snet\-alarms
Suppress range alarms that are part of shared networks. Use of this option
will keep alarm criteria applied to ranges that are not part of shared-net
along with shared-net alarms. This option may help reducing alarm noise for
configurations that has lots of small ranges in big shared-networks.
.TP
\fB\-\-minsize\fR=\fIsize\fR \fB\-\-minsize\fR=\fIsize\fR
Ignore ranges and shared networks that are smaller or equal to the Ignore ranges and shared networks that are smaller or equal to the
defined size. This option is meaningful only in context of alarming, and defined size. This option is meaningful only in context of alarming, and

View file

@ -94,7 +94,8 @@ int main(int argc, char **argv)
char const *tmp; char const *tmp;
struct range_t *tmp_ranges; struct range_t *tmp_ranges;
enum { enum {
OPT_WARN = CHAR_MAX + 1, OPT_SNET_ALARMS = CHAR_MAX + 1,
OPT_WARN,
OPT_CRIT, OPT_CRIT,
OPT_MINSIZE OPT_MINSIZE
}; };
@ -110,6 +111,7 @@ int main(int argc, char **argv)
{"limit", required_argument, NULL, 'L'}, {"limit", required_argument, NULL, 'L'},
{"version", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"snet-alarms", no_argument, NULL, OPT_SNET_ALARMS},
{"warning", required_argument, NULL, OPT_WARN}, {"warning", required_argument, NULL, OPT_WARN},
{"critical", required_argument, NULL, OPT_CRIT}, {"critical", required_argument, NULL, OPT_CRIT},
{"minsize", required_argument, NULL, OPT_MINSIZE}, {"minsize", required_argument, NULL, OPT_MINSIZE},
@ -127,6 +129,7 @@ int main(int argc, char **argv)
* command line option */ * command line option */
config.output_file[0] = '\0'; config.output_file[0] = '\0';
/* Alarming defaults. */ /* Alarming defaults. */
config.snet_alarms = false;
config.warning = ALARM_WARN; config.warning = ALARM_WARN;
config.critical = ALARM_CRIT; config.critical = ALARM_CRIT;
/* File location defaults */ /* File location defaults */
@ -194,6 +197,9 @@ int main(int argc, char **argv)
} }
} }
break; break;
case OPT_SNET_ALARMS:
config.snet_alarms = true;
break;
case OPT_WARN: case OPT_WARN:
strcpy(config.output_format, "a"); strcpy(config.output_format, "a");
config.warning = strtod_or_err(optarg, "illegal argument"); config.warning = strtod_or_err(optarg, "illegal argument");

View file

@ -130,6 +130,7 @@ struct configuration_t {
char *output_file; char *output_file;
int output_limit[2]; int output_limit[2];
bool backups_found; bool backups_found;
bool snet_alarms;
double warning; double warning;
double critical; double critical;
double minsize; double minsize;

View file

@ -1000,6 +1000,9 @@ int output_alarming(void)
if (config.output_limit[1] & BIT1) { if (config.output_limit[1] & BIT1) {
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
if (config.snet_alarms && range_p->shared_net != shared_networks) {
continue;
}
if (config.minsize < range_size) { if (config.minsize < range_size) {
perc = (float)(100 * range_p->count) / range_size; perc = (float)(100 * range_p->count) / range_size;
if (config.critical < perc) if (config.critical < perc)