diff options
author | Sven Nierlein <sven@nierlein.de> | 2021-11-17 11:58:41 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.org> | 2021-11-17 14:04:09 +0100 |
commit | 024d268386353133af1a9ff5c0b5879397c19b1c (patch) | |
tree | 285cae08903f564af57304df3344e35a2ccbb401 /plugins/check_snmp.c | |
parent | 3f9b22ab16b5a9b74d62d7fff9b6bf3a51ed93f7 (diff) | |
download | monitoring-plugins-024d268386353133af1a9ff5c0b5879397c19b1c.tar.gz |
check_snmp: fix performance thresholds when using multiple oids
when using check_snmp with multiple oids it simply printed the unparsed content
from -w/-c into the thresholds for each oid. So each oid contained the hole -w
from all oids.
./check_snmp ... -o iso.3.6.1.2.1.25.1.3.0,iso.3.6.1.2.1.25.1.5.0 -w '1,2' -c '3,4'
before:
SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1,2;3,4 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;1,2;3,4
after:
SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1;3 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;2;4
This also applies to fixed thresholds since check_snmp translates negative infinities from: '~:-1' to '@-1:~'
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index afc568b2..58d46b11 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -468,6 +468,9 @@ main (int argc, char **argv) | |||
468 | /* Process this block for numeric comparisons */ | 468 | /* Process this block for numeric comparisons */ |
469 | /* Make some special values,like Timeticks numeric only if a threshold is defined */ | 469 | /* Make some special values,like Timeticks numeric only if a threshold is defined */ |
470 | if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { | 470 | if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { |
471 | if (verbose > 2) { | ||
472 | print_thresholds(" thresholds", thlds[i]); | ||
473 | } | ||
471 | ptr = strpbrk (show, "-0123456789"); | 474 | ptr = strpbrk (show, "-0123456789"); |
472 | if (ptr == NULL) | 475 | if (ptr == NULL) |
473 | die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); | 476 | die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); |
@@ -581,14 +584,16 @@ main (int argc, char **argv) | |||
581 | 584 | ||
582 | if (warning_thresholds) { | 585 | if (warning_thresholds) { |
583 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); | 586 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); |
584 | strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1); | 587 | if(thlds[i]->warning && thlds[i]->warning->text) |
588 | strncat(perfstr, thlds[i]->warning->text, sizeof(perfstr)-strlen(perfstr)-1); | ||
585 | } | 589 | } |
586 | 590 | ||
587 | if (critical_thresholds) { | 591 | if (critical_thresholds) { |
588 | if (!warning_thresholds) | 592 | if (!warning_thresholds) |
589 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); | 593 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); |
590 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); | 594 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); |
591 | strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1); | 595 | if(thlds[i]->critical && thlds[i]->critical->text) |
596 | strncat(perfstr, thlds[i]->critical->text, sizeof(perfstr)-strlen(perfstr)-1); | ||
592 | } | 597 | } |
593 | 598 | ||
594 | strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); | 599 | strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); |