diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_snmp.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 56bad880..d3968a27 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -1165,17 +1165,36 @@ nextarg (char *str) | |||
1165 | char * | 1165 | char * |
1166 | multiply (char *str) | 1166 | multiply (char *str) |
1167 | { | 1167 | { |
1168 | double val = strtod (str, NULL); | 1168 | char *endptr; |
1169 | val *= multiplier; | 1169 | double val; |
1170 | char *conv = "%f"; | 1170 | char *conv = "%f"; |
1171 | |||
1172 | if(verbose>2) | ||
1173 | printf(" multiply input: %s\n", str); | ||
1174 | |||
1175 | val = strtod (str, &endptr); | ||
1176 | if ((val == 0.0) && (endptr == str)) { | ||
1177 | if(multiplier != 1) { | ||
1178 | die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str); | ||
1179 | } | ||
1180 | return str; | ||
1181 | } | ||
1182 | |||
1183 | if(verbose>2) | ||
1184 | printf(" multiply extracted double: %f\n", val); | ||
1185 | val *= multiplier; | ||
1171 | if (fmtstr != "") { | 1186 | if (fmtstr != "") { |
1172 | conv = fmtstr; | 1187 | conv = fmtstr; |
1173 | } | 1188 | } |
1174 | if (val == (int)val) { | 1189 | if (val == (int)val) { |
1175 | sprintf(str, "%.0f", val); | 1190 | sprintf(str, "%.0f", val); |
1176 | } else { | 1191 | } else { |
1192 | if(verbose>2) | ||
1193 | printf(" multiply using format: %s\n", conv); | ||
1177 | sprintf(str, conv, val); | 1194 | sprintf(str, conv, val); |
1178 | } | 1195 | } |
1196 | if(verbose>2) | ||
1197 | printf(" multiply result: %s\n", str); | ||
1179 | return str; | 1198 | return str; |
1180 | } | 1199 | } |
1181 | 1200 | ||