From 5519763ba9c567f6eb04764b0696da628565a585 Mon Sep 17 00:00:00 2001 From: Wolfgang Steudel Date: Thu, 13 Nov 2014 09:45:59 +0000 Subject: [PATCH] alarming: include last shared network in alarming [off by one] We have defined some shared networks with a couple of address ranges and wanted to monitor the availability of free IP addresses in the shared networks. We were wondering why in some cases there was no warning, although one shared network's usage was above the threshold. We found the reason. In output_alarming() the code was not skipping "All networks", but missing the last shared network in the list. Moving "shared_p++" to the beginning of the loop seems to solve the bug. Reviewed-by: Sami Kerola Signed-off-by: Wolfgang Steudel --- THANKS | 1 + src/output.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 8c18c15..949078f 100644 --- a/THANKS +++ b/THANKS @@ -31,3 +31,4 @@ Ryan Steinmetz Dan Pritts Fredrik Lysén Conor McCarthy +Wolfgang Steudel diff --git a/src/output.c b/src/output.c index dc79bab..9268b32 100644 --- a/src/output.c +++ b/src/output.c @@ -994,6 +994,7 @@ int output_alarming(void) } if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { + shared_p++; if (config.minsize < shared_p->available) { perc = (float)(100 * shared_p->used) / shared_p->available; if (config.critical < perc) @@ -1005,7 +1006,6 @@ int output_alarming(void) } else { si++; } - shared_p++; } }