mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 07:47:00 +00:00
output: allow user to ignore small ranges and shared networks
Some have configuration which combines small ranges such as one host, and greater address ranges that are important to monitor. Especially the one host ranges tend to cause a lot of false-positive alarms, as they are immediately 100% full when a machine requests an address. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
4becf97fb3
commit
28f1e8c54c
5 changed files with 48 additions and 18 deletions
|
|
@ -159,6 +159,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\-\-minsize\fR=\fIsize\f
|
||||||
|
Ignore ranges and shared networks that are smaller or equal to the
|
||||||
|
defined size. This option is meaningful only in context of alarming, and
|
||||||
|
will intented to supress for example single host ranges. By default this
|
||||||
|
option is not in use.
|
||||||
|
.TP
|
||||||
\fB\-v\fR, \fB\-\-version\fR
|
\fB\-v\fR, \fB\-\-version\fR
|
||||||
Print version information to standard output and exit successfully.
|
Print version information to standard output and exit successfully.
|
||||||
.TP
|
.TP
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ int main(int argc, char **argv)
|
||||||
struct range_t *tmp_ranges;
|
struct range_t *tmp_ranges;
|
||||||
enum {
|
enum {
|
||||||
OPT_WARN = CHAR_MAX + 1,
|
OPT_WARN = CHAR_MAX + 1,
|
||||||
OPT_CRIT
|
OPT_CRIT,
|
||||||
|
OPT_MINSIZE
|
||||||
};
|
};
|
||||||
int ret_val;
|
int ret_val;
|
||||||
|
|
||||||
|
|
@ -89,6 +90,7 @@ int main(int argc, char **argv)
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"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},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -192,6 +194,10 @@ int main(int argc, char **argv)
|
||||||
config.critical =
|
config.critical =
|
||||||
strtod_or_err(optarg, "illegal argument");
|
strtod_or_err(optarg, "illegal argument");
|
||||||
break;
|
break;
|
||||||
|
case OPT_MINSIZE:
|
||||||
|
config.minsize =
|
||||||
|
strtod_or_err(optarg, "illegal argument");
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
/* Print version */
|
/* Print version */
|
||||||
print_version();
|
print_version();
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ struct configuration_t {
|
||||||
bool backups_found;
|
bool backups_found;
|
||||||
double warning;
|
double warning;
|
||||||
double critical;
|
double critical;
|
||||||
|
double minsize;
|
||||||
};
|
};
|
||||||
/*! \struct shared_network_t
|
/*! \struct shared_network_t
|
||||||
* \brief Counters for an individual shared network.
|
* \brief Counters for an individual shared network.
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,8 @@ This is ISC dhcpd pools usage analyzer.\n\
|
||||||
-L, --limit=NR output limit mask 77 - 00\n");
|
-L, --limit=NR output limit mask 77 - 00\n");
|
||||||
fprintf(out, "\
|
fprintf(out, "\
|
||||||
--warning=PERC set warning alarming limit\n\
|
--warning=PERC set warning alarming limit\n\
|
||||||
--critical=PERC set critical alarming limit\n");
|
--critical=PERC set critical alarming limit\n\
|
||||||
|
--minsize=size disable alarms for small ranges and shared-nets\n");
|
||||||
fprintf(out, "\
|
fprintf(out, "\
|
||||||
-v, --version version information\n\
|
-v, --version version information\n\
|
||||||
-h, --help this screen\n\
|
-h, --help this screen\n\
|
||||||
|
|
|
||||||
48
src/output.c
48
src/output.c
|
|
@ -1018,7 +1018,7 @@ int output_alarming(void)
|
||||||
struct shared_network_t *shared_p;
|
struct shared_network_t *shared_p;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
float perc;
|
float perc;
|
||||||
int rw = 0, rc = 0, ro = 0, sw = 0, sc = 0, so = 0;
|
int rw = 0, rc = 0, ro = 0, ri = 0, sw = 0, sc = 0, so = 0, si = 0;
|
||||||
int ret_val, ret;
|
int ret_val, ret;
|
||||||
|
|
||||||
range_p = ranges;
|
range_p = ranges;
|
||||||
|
|
@ -1037,27 +1037,36 @@ 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++) {
|
||||||
perc = (float)(100 * range_p->count) / range_size;
|
if (config.minsize < range_size) {
|
||||||
if (config.critical < perc)
|
perc =
|
||||||
rc++;
|
(float)(100 * range_p->count) / range_size;
|
||||||
else if (config.warning < perc)
|
if (config.critical < perc)
|
||||||
rw++;
|
rc++;
|
||||||
else
|
else if (config.warning < perc)
|
||||||
ro++;
|
rw++;
|
||||||
|
else
|
||||||
|
ro++;
|
||||||
|
} else {
|
||||||
|
ri++;
|
||||||
|
}
|
||||||
range_p++;
|
range_p++;
|
||||||
range_size = get_range_size(range_p);
|
range_size = get_range_size(range_p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & BIT2) {
|
if (config.output_limit[1] & BIT2) {
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
perc = (float)(100 * shared_p->used) /
|
if (config.minsize < shared_p->available) {
|
||||||
shared_p->available;
|
perc = (float)(100 * shared_p->used) /
|
||||||
if (config.critical < perc)
|
shared_p->available;
|
||||||
sc++;
|
if (config.critical < perc)
|
||||||
else if (config.warning < perc)
|
sc++;
|
||||||
sw++;
|
else if (config.warning < perc)
|
||||||
else
|
sw++;
|
||||||
so++;
|
else
|
||||||
|
so++;
|
||||||
|
} else {
|
||||||
|
si++;
|
||||||
|
}
|
||||||
shared_p++;
|
shared_p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1079,10 +1088,17 @@ int output_alarming(void)
|
||||||
if (config.output_limit[0] & BIT1) {
|
if (config.output_limit[0] & BIT1) {
|
||||||
fprintf(outfile, "Ranges; crit: %d warn: %d ok: %d ", rc, rw,
|
fprintf(outfile, "Ranges; crit: %d warn: %d ok: %d ", rc, rw,
|
||||||
ro);
|
ro);
|
||||||
|
if (ri != 0) {
|
||||||
|
fprintf(outfile, "ignored: %d ", ri);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & BIT2) {
|
if (config.output_limit[0] & BIT2) {
|
||||||
fprintf(outfile, "Shared nets; crit: %d warn: %d ok: %d", sc,
|
fprintf(outfile, "Shared nets; crit: %d warn: %d ok: %d", sc,
|
||||||
sw, so);
|
sw, so);
|
||||||
|
if (si != 0) {
|
||||||
|
fprintf(outfile, "ignored: %d ", si);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
if (outfile == stdout) {
|
if (outfile == stdout) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue