diff options
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index d3968a27..c4ddd0ed 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,6 +1171,9 @@ 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 | ||
@@ -1187,15 +1192,15 @@ multiply (char *str) | |||
1187 | conv = fmtstr; | 1192 | conv = fmtstr; |
1188 | } | 1193 | } |
1189 | if (val == (int)val) { | 1194 | if (val == (int)val) { |
1190 | sprintf(str, "%.0f", val); | 1195 | snprintf(buffer, DEFAULT_BUFFER_SIZE, "%.0f", val); |
1191 | } else { | 1196 | } else { |
1192 | if(verbose>2) | 1197 | if(verbose>2) |
1193 | printf(" multiply using format: %s\n", conv); | 1198 | printf(" multiply using format: %s\n", conv); |
1194 | sprintf(str, conv, val); | 1199 | snprintf(buffer, DEFAULT_BUFFER_SIZE, conv, val); |
1195 | } | 1200 | } |
1196 | if(verbose>2) | 1201 | if(verbose>2) |
1197 | printf(" multiply result: %s\n", str); | 1202 | printf(" multiply result: %s\n", buffer); |
1198 | return str; | 1203 | return buffer; |
1199 | } | 1204 | } |
1200 | 1205 | ||
1201 | 1206 | ||