alarming: make native nagios support to dhcpd-pools

This commit makes integrating the command with nagios much easier.

$ dhcpd-pools -c dhcpd.conf -l dhcpd.leases --critical 80 --warning 75
CRITICAL: dhcpd-pools: Ranges; crit: 14 warn: 22 ok: 220 Shared nets; crit: 1 warn: 0 ok: 4

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-06-24 15:32:50 +02:00
parent 5a307703c9
commit 42dd80aeac
6 changed files with 161 additions and 2 deletions

View file

@ -136,6 +136,28 @@ char *safe_strdup(const char *restrict str)
return ret;
}
/* Return percentage value */
double strtod_or_err(const char *str, const char *errmesg)
{
double num;
char *end = NULL;
if (str == NULL || *str == '\0')
goto err;
errno = 0;
num = strtod(str, &end);
if (errno || str == end || (end && *end))
goto err;
return num;
err:
if (errno)
err(EXIT_FAILURE, "%s: '%s'", errmesg, str);
errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
}
void flip_ranges(struct range_t *restrict ranges, struct range_t *restrict tmp_ranges)
{
unsigned int i = num_ranges - 1, j;
@ -237,6 +259,9 @@ This is ISC dhcpd pools usage analyzer.\n\
-o, --output=FILE output into a file\n\
-L, --limit=NR output limit mask 77 - 00\n");
fprintf(out, "\
--warning=PERC set warning alarming limit\n\
--critical=PERC set critical alarming limit\n");
fprintf(out, "\
-v, --version version information\n\
-h, --help this screen\n\
\n\