diff options
author | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-07-11 14:39:29 (GMT) |
---|---|---|
committer | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-07-11 14:39:29 (GMT) |
commit | 068c124f361d4c615aed79f6fe607f39040b2e31 (patch) | |
tree | d60e1d1aab59231c15f7da6f60424e4b2541f281 /plugins | |
parent | 4f4dd3a7a342f79dbd40e5636a5808f80ef6ed7b (diff) | |
download | monitoring-plugins-068c124f361d4c615aed79f6fe607f39040b2e31.tar.gz |
Detect if fmtstr was set in edge cases
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_snmp.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 425bb7b..135bbc7 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -158,6 +158,7 @@ int perf_labels = 1; | |||
158 | char* ip_version = ""; | 158 | char* ip_version = ""; |
159 | double multiplier = 1.0; | 159 | double multiplier = 1.0; |
160 | char *fmtstr = ""; | 160 | char *fmtstr = ""; |
161 | bool fmtstr_set = false; | ||
161 | char buffer[DEFAULT_BUFFER_SIZE]; | 162 | char buffer[DEFAULT_BUFFER_SIZE]; |
162 | 163 | ||
163 | static char *fix_snmp_range(char *th) | 164 | static char *fix_snmp_range(char *th) |
@@ -423,7 +424,7 @@ main (int argc, char **argv) | |||
423 | else if (strstr (response, "INTEGER: ")) { | 424 | else if (strstr (response, "INTEGER: ")) { |
424 | show = multiply (strstr (response, "INTEGER: ") + 9); | 425 | show = multiply (strstr (response, "INTEGER: ") + 9); |
425 | 426 | ||
426 | if (strcmp(fmtstr, "") != 0) { | 427 | if (fmtstr_set) { |
427 | conv = fmtstr; | 428 | conv = fmtstr; |
428 | } | 429 | } |
429 | } | 430 | } |
@@ -973,6 +974,7 @@ process_arguments (int argc, char **argv) | |||
973 | case 'f': | 974 | case 'f': |
974 | if (multiplier != 1.0) { | 975 | if (multiplier != 1.0) { |
975 | fmtstr=optarg; | 976 | fmtstr=optarg; |
977 | fmtstr_set = true; | ||
976 | } | 978 | } |
977 | break; | 979 | break; |
978 | } | 980 | } |
@@ -1187,7 +1189,7 @@ multiply (char *str) | |||
1187 | if(verbose>2) | 1189 | if(verbose>2) |
1188 | printf(" multiply extracted double: %f\n", val); | 1190 | printf(" multiply extracted double: %f\n", val); |
1189 | val *= multiplier; | 1191 | val *= multiplier; |
1190 | if (strcmp(fmtstr, "") != 0) { | 1192 | if (fmtstr_set) { |
1191 | conv = fmtstr; | 1193 | conv = fmtstr; |
1192 | } | 1194 | } |
1193 | if (val == (int)val) { | 1195 | if (val == (int)val) { |