diff --git a/THANKS b/THANKS index 6e76373..a1ba2bc 100644 --- a/THANKS +++ b/THANKS @@ -45,3 +45,4 @@ Boris Lytochkin Jeff Bailey José Bollo Sebastián Cramatte +Mark Sangster diff --git a/src/output.c b/src/output.c index a2f0c29..275e431 100644 --- a/src/output.c +++ b/src/output.c @@ -158,11 +158,11 @@ int shnet_output_helper(struct conf_t *state, struct output_helper_t *oh, oh->status = STATUS_IGNORED; if (state->skip_minsize) return 1; - } else if (state->critical < oh->percent && shared_p->used < state->crit_count) { + } else if (state->critical < oh->percent && (shared_p->available - shared_p->used) < state->crit_count) { oh->status = STATUS_CRIT; if (state->skip_critical) return 1; - } else if (state->warning < oh->percent && shared_p->used < state->warn_count) { + } else if (state->warning < oh->percent && (shared_p->available - shared_p->used) < state->warn_count) { oh->status = STATUS_WARN; if (state->skip_warning) return 1; diff --git a/tests/alarm-count-option b/tests/alarm-count-option index 763af1b..37d894d 100755 --- a/tests/alarm-count-option +++ b/tests/alarm-count-option @@ -32,6 +32,13 @@ dhcpd-pools -c $top_srcdir/tests/confs/complete -l $top_srcdir/tests/leases/comp echo $? >> tests/outputs/$IAM-too cat tests/outputs/$IAM-too >> tests/outputs/$IAM +echo '== shared net count alarms ==' >> tests/outputs/$IAM +dhcpd-pools -c $top_srcdir/tests/confs/complete -l $top_srcdir/tests/leases/complete \ + --color=always --format t --crit-count=20 --critical=0 --warning=0 --warn-count=24 \ + --output=tests/outputs/$IAM-too +echo $? >> tests/outputs/$IAM-too +cat tests/outputs/$IAM-too >> tests/outputs/$IAM + rm -f tests/outputs/$IAM-too diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM exit $? diff --git a/tests/expected/alarm-count-option b/tests/expected/alarm-count-option index 3e9b76d..c2f466e 100644 --- a/tests/expected/alarm-count-option +++ b/tests/expected/alarm-count-option @@ -14,3 +14,21 @@ Shared nets - crit: 0 warn: 0 ok: 0 ignored: 2; | snet_crit=0 snet_warn=0 snet_o WARNING: dhcpd-pools: Ranges - crit: 0 warn: 0 ok: 2; | range_crit=0 range_warn=0 range_ok=2 Shared nets - crit: 0 warn: 2 ok: 0; | snet_crit=0 snet_warn=2 snet_ok=0 1 +== shared net count alarms == +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +example1 10.0.0.1 - 10.0.0.20 20 11 55.000 0 11 55.000 +example1 10.1.0.1 - 10.1.0.20 20 10 50.000 0 10 50.000 +example2 10.2.0.1 - 10.2.0.20 20 8 40.000 0 8 40.000 +example2 10.3.0.1 - 10.3.0.20 20 9 45.000 0 9 45.000 +All networks 10.4.0.1 - 10.4.0.20 20 5 25.000 0 5 25.000 + +Shared networks: +name max cur percent touch t+c t+c perc +example1 40 21 52.500 0 21 52.500 +example2 40 17 42.500 0 17 42.500 + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 100 43 43.000 0 43 43.000 +0