summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_snmp.c6
-rwxr-xr-xplugins/tests/check_snmp.t2
2 files changed, 6 insertions, 2 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index d407609..56bad88 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -1167,10 +1167,14 @@ multiply (char *str)
1167{ 1167{
1168 double val = strtod (str, NULL); 1168 double val = strtod (str, NULL);
1169 val *= multiplier; 1169 val *= multiplier;
1170 char *conv = "%f";
1171 if (fmtstr != "") {
1172 conv = fmtstr;
1173 }
1170 if (val == (int)val) { 1174 if (val == (int)val) {
1171 sprintf(str, "%.0f", val); 1175 sprintf(str, "%.0f", val);
1172 } else { 1176 } else {
1173 sprintf(str, "%f", val); 1177 sprintf(str, conv, val);
1174 } 1178 }
1175 return str; 1179 return str;
1176} 1180}
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index bb5b8db..bc03ec6 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -279,7 +279,7 @@ is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' ,
279 279
280$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.19 --multiplier=.1 -f '%.2f' "); 280$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.19 --multiplier=.1 -f '%.2f' ");
281is($res->return_code, 0, "Test multiply RC + format" ); 281is($res->return_code, 0, "Test multiply RC + format" );
282is($res->output, 'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ', "Test multiply .1 output + format" ); 282is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
283 283
284$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.19 --multiplier=.1 -f '%.2f' -w 1"); 284$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.19 --multiplier=.1 -f '%.2f' -w 1");
285is($res->return_code, 1, "Test multiply RC + format + thresholds" ); 285is($res->return_code, 1, "Test multiply RC + format + thresholds" );