output: make --skip to take arguments what will be skipped

Accidental typo in usage() caused realisation making skipping to fully
controllable is good idea.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-13 20:23:12 +00:00
parent e4f7259cf6
commit 3369278fc0
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
9 changed files with 216 additions and 23 deletions

View file

@ -90,12 +90,19 @@ int range_output_helper(struct conf_t *state, struct output_helper_t *oh,
&& (oh->range_size - range_p->count) < state->warn_count)
oh->status = STATUS_WARN;
if (oh->status != STATUS_OK) {
if (oh->range_size <= state->minsize)
if (oh->range_size <= state->minsize) {
oh->status = STATUS_IGNORED;
else if (state->snet_alarms && range_p->shared_net != state->shared_net_root)
if (state->skip_minsize)
return 1;
} else if (state->snet_alarms && range_p->shared_net != state->shared_net_root) {
oh->status = STATUS_SUPPRESSED;
if (state->skip_suppressed)
return 1;
}
}
if (state->skip_ok && oh->status == STATUS_OK)
if ((state->skip_ok && oh->status == STATUS_OK) ||
(state->skip_warning && oh->status == STATUS_WARN) ||
(state->skip_critical && oh->status == STATUS_CRIT))
return 1;
return 0;
}
@ -111,6 +118,8 @@ int shnet_output_helper(struct conf_t *state, struct output_helper_t *oh,
oh->tcp = NAN;
oh->bup = NAN;
oh->status = STATUS_SUPPRESSED;
if (state->skip_suppressed)
return 1;
return 0;
}
@ -120,16 +129,23 @@ int shnet_output_helper(struct conf_t *state, struct output_helper_t *oh,
oh->bup = (double)(100 * shared_p->backups) / shared_p->available;
/* set status */
if (shared_p->available <= state->minsize)
if (shared_p->available <= state->minsize) {
oh->status = STATUS_IGNORED;
else if (state->critical < oh->percent && shared_p->used < state->crit_count)
if (state->skip_minsize)
return 1;
} else if (state->critical < oh->percent && shared_p->used < state->crit_count) {
oh->status = STATUS_CRIT;
else if (state->warning < oh->percent && shared_p->used < state->warn_count)
if (state->skip_critical)
return 1;
} else if (state->warning < oh->percent && shared_p->used < state->warn_count) {
oh->status = STATUS_WARN;
else
if (state->skip_warning)
return 1;
} else {
oh->status = STATUS_OK;
if (state->skip_ok && oh->status == STATUS_OK)
return 1;
if (state->skip_ok)
return 1;
}
return 0;
}