mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
add --warn-count and --crit-count options to suppress alarm noise
Alarm criteria based solely on percentage was found to be difficult to be tricky to setup in environments that has small ranges and big shared-nets mixed up together. These two new options should help making alarming more useful. Requested-by: Frank Bulk <fbulk@mypremieronline.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
7f3d553c7f
commit
5cede1ff31
4 changed files with 42 additions and 5 deletions
|
|
@ -161,6 +161,27 @@ is
|
|||
If critical percentage is not specified it defaults to
|
||||
.BR @ALARM_CRIT@ .
|
||||
.TP
|
||||
\fB\-\-warn\-count\fR=\fInumber\fR
|
||||
A
|
||||
.I number
|
||||
of free leases before alarm is raised. When specified both \-\-warning
|
||||
.I percent
|
||||
and count
|
||||
.I number
|
||||
are required to be exceeded in order to alarm criteria being fulfilled.
|
||||
.IP
|
||||
This option is intented to be used in setup where very large and small
|
||||
shared-networks and ranges co-exists. In such environments percent based
|
||||
alarming can lead to either flood of alarms about small ranges, or way too
|
||||
great overhead of free addresses in large shared-networks. Suggested usage
|
||||
is to set percentage to a level that makes small ranges to ring, and set the
|
||||
count to match level when an enormous shared-network is too few free leases.
|
||||
.IP
|
||||
Defaults to 2^32, that is size of entire IPv4 address space.
|
||||
.TP
|
||||
\fB\-\-crit\-count\fR=\fInumber\fR
|
||||
Same as \-\-warn\-count, but for critical alarms.
|
||||
.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
|
||||
|
|
|
|||
|
|
@ -97,7 +97,9 @@ int main(int argc, char **argv)
|
|||
OPT_SNET_ALARMS = CHAR_MAX + 1,
|
||||
OPT_WARN,
|
||||
OPT_CRIT,
|
||||
OPT_MINSIZE
|
||||
OPT_MINSIZE,
|
||||
OPT_WARN_COUNT,
|
||||
OPT_CRIT_COUNT
|
||||
};
|
||||
int ret_val;
|
||||
|
||||
|
|
@ -114,6 +116,8 @@ int main(int argc, char **argv)
|
|||
{"snet-alarms", no_argument, NULL, OPT_SNET_ALARMS},
|
||||
{"warning", required_argument, NULL, OPT_WARN},
|
||||
{"critical", required_argument, NULL, OPT_CRIT},
|
||||
{"warn-count", required_argument, NULL, OPT_WARN_COUNT},
|
||||
{"crit-count", required_argument, NULL, OPT_CRIT_COUNT},
|
||||
{"minsize", required_argument, NULL, OPT_MINSIZE},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
|
@ -132,6 +136,8 @@ int main(int argc, char **argv)
|
|||
config.snet_alarms = false;
|
||||
config.warning = ALARM_WARN;
|
||||
config.critical = ALARM_CRIT;
|
||||
config.warn_count = 0x100000000; /* == 2^32 that is the entire IPv4 space */
|
||||
config.crit_count = 0x100000000; /* basically turns off the count criteria */
|
||||
/* File location defaults */
|
||||
strncpy(config.dhcpdconf_file, DHCPDCONF_FILE, MAXLEN - 1);
|
||||
strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE, MAXLEN - 1);
|
||||
|
|
@ -208,6 +214,14 @@ int main(int argc, char **argv)
|
|||
strcpy(config.output_format, "a");
|
||||
config.critical = strtod_or_err(optarg, "illegal argument");
|
||||
break;
|
||||
case OPT_WARN_COUNT:
|
||||
strcpy(config.output_format, "a");
|
||||
config.warn_count = strtod_or_err(optarg, "illegal argument");
|
||||
break;
|
||||
case OPT_CRIT_COUNT:
|
||||
strcpy(config.output_format, "a");
|
||||
config.crit_count = strtod_or_err(optarg, "illegal argument");
|
||||
break;
|
||||
case OPT_MINSIZE:
|
||||
config.minsize = strtod_or_err(optarg, "illegal argument");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ struct configuration_t {
|
|||
bool snet_alarms;
|
||||
double warning;
|
||||
double critical;
|
||||
double warn_count;
|
||||
double crit_count;
|
||||
double minsize;
|
||||
};
|
||||
/*! \struct shared_network_t
|
||||
|
|
|
|||
|
|
@ -1005,9 +1005,9 @@ int output_alarming(void)
|
|||
}
|
||||
if (config.minsize < range_size) {
|
||||
perc = (float)(100 * range_p->count) / range_size;
|
||||
if (config.critical < perc)
|
||||
if (config.critical < perc && (range_size - range_p->count) < config.crit_count)
|
||||
rc++;
|
||||
else if (config.warning < perc)
|
||||
else if (config.warning < perc && (range_size - range_p->count) < config.warn_count)
|
||||
rw++;
|
||||
else
|
||||
ro++;
|
||||
|
|
@ -1025,9 +1025,9 @@ int output_alarming(void)
|
|||
perc =
|
||||
shared_p->available ==
|
||||
0 ? 100 : (float)(100 * shared_p->used) / shared_p->available;
|
||||
if (config.critical < perc)
|
||||
if (config.critical < perc && shared_p->available < config.crit_count)
|
||||
sc++;
|
||||
else if (config.warning < perc)
|
||||
else if (config.warning < perc && shared_p->available < config.warn_count)
|
||||
sw++;
|
||||
else
|
||||
so++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue