summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-04-03 17:38:01 +0200
committerGitHub <noreply@github.com>2023-04-03 17:38:01 +0200
commit495c4c9adfa482303b31cdac7d28adda82d2d2ed (patch)
treeabb7d9ded7a184d2eec52060dfbb507e4e5f9b06
parentbbc97d57f7f9e0a49fea78c02861c444fe95d46a (diff)
parentac3032a0ba6f30befd6c605970ae856dcdb05384 (diff)
downloadmonitoring-plugins-495c4c9adfa482303b31cdac7d28adda82d2d2ed.tar.gz
Merge branch 'master' into dev/check_ssh-patches
-rw-r--r--plugins-scripts/Makefile.am4
-rw-r--r--plugins/check_snmp.c18
2 files changed, 12 insertions, 10 deletions
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am
index 088a4459..7879791f 100644
--- a/plugins-scripts/Makefile.am
+++ b/plugins-scripts/Makefile.am
@@ -16,13 +16,13 @@ VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/
16libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ 16libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
17 check_log check_oracle check_rpc check_sensors check_wave \ 17 check_log check_oracle check_rpc check_sensors check_wave \
18 check_ifstatus check_ifoperstatus check_mailq check_file_age \ 18 check_ifstatus check_ifoperstatus check_mailq check_file_age \
19 check_uptime \ 19 check_uptime check_mssql \
20 utils.sh utils.pm 20 utils.sh utils.pm
21 21
22EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ 22EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
23 check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \ 23 check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
24 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \ 24 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
25 check_uptime.pl \ 25 check_uptime.pl check_mssql.pl \
26 utils.sh.in utils.pm.in t 26 utils.sh.in utils.pm.in t
27 27
28EDIT = sed \ 28EDIT = sed \
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index d3968a27..aefda3d2 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;
157char* ip_version = ""; 158char* ip_version = "";
158double multiplier = 1.0; 159double multiplier = 1.0;
159char *fmtstr = ""; 160char *fmtstr = "";
161char buffer[DEFAULT_BUFFER_SIZE];
160 162
161static char *fix_snmp_range(char *th) 163static 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