diff options
author | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-04-28 09:00:05 (GMT) |
---|---|---|
committer | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-04-28 09:00:05 (GMT) |
commit | 34c4d13edd8ece1e928c578974218c10d25600c4 (patch) | |
tree | 96eaf64dc46c8b785d437250d42471180597a699 /plugins/check_snmp.c | |
parent | e4ddeb7bb722b50613108da1cb51a48e84068701 (diff) | |
parent | 7cb82e6486e662fa4d2530523787d3eced266545 (diff) | |
download | monitoring-plugins-34c4d13edd8ece1e928c578974218c10d25600c4.tar.gz |
Merge branch 'master' into RincewindsHat-patch-1
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index d3968a2..c425df3 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -46,6 +46,7 @@ const char *email = "devel@monitoring-plugins.org"; | |||
46 | #define DEFAULT_PRIV_PROTOCOL "DES" | 46 | #define DEFAULT_PRIV_PROTOCOL "DES" |
47 | #define DEFAULT_DELIMITER "=" | 47 | #define DEFAULT_DELIMITER "=" |
48 | #define DEFAULT_OUTPUT_DELIMITER " " | 48 | #define DEFAULT_OUTPUT_DELIMITER " " |
49 | #define DEFAULT_BUFFER_SIZE 100 | ||
49 | 50 | ||
50 | #define mark(a) ((a)!=0?"*":"") | 51 | #define mark(a) ((a)!=0?"*":"") |
51 | 52 | ||
@@ -157,6 +158,7 @@ int perf_labels = 1; | |||
157 | char* ip_version = ""; | 158 | char* ip_version = ""; |
158 | double multiplier = 1.0; | 159 | double multiplier = 1.0; |
159 | char *fmtstr = ""; | 160 | char *fmtstr = ""; |
161 | char buffer[DEFAULT_BUFFER_SIZE]; | ||
160 | 162 | ||
161 | static char *fix_snmp_range(char *th) | 163 | static char *fix_snmp_range(char *th) |
162 | { | 164 | { |
@@ -1169,15 +1171,15 @@ multiply (char *str) | |||
1169 | double val; | 1171 | double val; |
1170 | char *conv = "%f"; | 1172 | char *conv = "%f"; |
1171 | 1173 | ||
1174 | if(multiplier == 1) | ||
1175 | return(str); | ||
1176 | |||
1172 | if(verbose>2) | 1177 | if(verbose>2) |
1173 | printf(" multiply input: %s\n", str); | 1178 | printf(" multiply input: %s\n", str); |
1174 | 1179 | ||
1175 | val = strtod (str, &endptr); | 1180 | val = strtod (str, &endptr); |
1176 | if ((val == 0.0) && (endptr == str)) { | 1181 | if ((val == 0.0) && (endptr == str)) { |
1177 | if(multiplier != 1) { | 1182 | die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str); |
1178 | die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str); | ||
1179 | } | ||
1180 | return str; | ||
1181 | } | 1183 | } |
1182 | 1184 | ||
1183 | if(verbose>2) | 1185 | if(verbose>2) |
@@ -1187,15 +1189,15 @@ multiply (char *str) | |||
1187 | conv = fmtstr; | 1189 | conv = fmtstr; |
1188 | } | 1190 | } |
1189 | if (val == (int)val) { | 1191 | if (val == (int)val) { |
1190 | sprintf(str, "%.0f", val); | 1192 | snprintf(buffer, DEFAULT_BUFFER_SIZE, "%.0f", val); |
1191 | } else { | 1193 | } else { |
1192 | if(verbose>2) | 1194 | if(verbose>2) |
1193 | printf(" multiply using format: %s\n", conv); | 1195 | printf(" multiply using format: %s\n", conv); |
1194 | sprintf(str, conv, val); | 1196 | snprintf(buffer, DEFAULT_BUFFER_SIZE, conv, val); |
1195 | } | 1197 | } |
1196 | if(verbose>2) | 1198 | if(verbose>2) |
1197 | printf(" multiply result: %s\n", str); | 1199 | printf(" multiply result: %s\n", buffer); |
1198 | return str; | 1200 | return buffer; |
1199 | } | 1201 | } |
1200 | 1202 | ||
1201 | 1203 | ||
@@ -1272,7 +1274,7 @@ print_help (void) | |||
1272 | printf (" %s\n", "--rate-multiplier"); | 1274 | printf (" %s\n", "--rate-multiplier"); |
1273 | printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); | 1275 | printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); |
1274 | printf (" %s\n", "--offset=OFFSET"); | 1276 | printf (" %s\n", "--offset=OFFSET"); |
1275 | printf (" %s\n", _("Add/substract the specified OFFSET to numeric sensor data")); | 1277 | printf (" %s\n", _("Add/subtract the specified OFFSET to numeric sensor data")); |
1276 | 1278 | ||
1277 | /* Tests Against Strings */ | 1279 | /* Tests Against Strings */ |
1278 | printf (" %s\n", "-s, --string=STRING"); | 1280 | printf (" %s\n", "-s, --string=STRING"); |