diff options
author | Sven Nierlein <sven@nierlein.de> | 2022-12-22 12:02:52 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.org> | 2022-12-22 12:54:51 +0100 |
commit | 9ba8f5ed66004c102bb626e47bb36dc9d0388632 (patch) | |
tree | 87193034d6ab87f025c0416236046b2aa246f4d8 /plugins/check_snmp.c | |
parent | def946bd9792ffff34b865449b18eea6e8f116af (diff) | |
download | monitoring-plugins-9ba8f5ed66004c102bb626e47bb36dc9d0388632.tar.gz |
check_snmp: always apply format when applying multiplier
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index d407609f..56bad880 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 | } |