[nagiosplug] check_snmp: use single quotes for perf data labels
"Nagios Plugin Development" <[email protected]> Tue, 26 Jun 2012 22:10:12 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug Branch: master Commit: 843f9540562930391b7db224664adbf951f11275 Author: Sven Nierlein <[email protected]> Date: Wed Jun 27 00:02:09 2012 +0200 URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=843f954 check_snmp: use single quotes for perf data labels --- plugins/check_snmp.c | 6 +++--- plugins/tests/check_snmp.t | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 51ad6f4..a5a88d2 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -494,10 +494,10 @@ main (int argc, char **argv) if (strpbrk (temp_string, " ='\"") == NULL) { strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1); } else { - if (strpbrk (temp_string, "\"") == NULL) { - quote_string="\""; - } else { + if (strpbrk (temp_string, "'") == NULL) { quote_string="'"; + } else { + quote_string="\""; } strncat(perfstr, quote_string, sizeof(perfstr)-strlen(perfstr)-1); strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1); diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index 7a5a8b3..1ef0b20 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t @@ -8,7 +8,7 @@ use Test::More; use NPTest; use FindBin qw($Bin); -my $tests = 51; +my $tests = 53; # Check that all dependent modules are available eval { require NetSNMP::OID; @@ -165,6 +165,10 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1 is($res->return_code, 0, "OK as no thresholds" ); is($res->output, "SNMP OK - 70660 | iso.3.6.1.4.1.8072.3.2.67.10=70660c ", "Check label"); +$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test test'" ); +is($res->return_code, 0, "OK as no thresholds" ); +is($res->output, "SNMP OK - test test 71326 | 'test test'=71326c ", "Check label"); + $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" ); is($res->return_code, 0, "OK for first call" ); ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/