summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-07 14:30:08 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-07 14:30:08 (GMT)
commitfb59d108e9c72ad2782ae4bc0967f24c96bca03a (patch)
tree744a538c754249cfa4713b85d420fc310ec97c90
parent3d88b61d1048c7117e79ba4ea78dc29ea058e814 (diff)
downloadmonitoring-plugins-fb59d108e9c72ad2782ae4bc0967f24c96bca03a.tar.gz
bugfixes to command format and (null) text created by asprintf switch
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@171 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_snmp.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 38ce940..4a51a29 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -155,7 +155,7 @@ int errcode, excode;
155 155
156char *server_address = NULL; 156char *server_address = NULL;
157char *community = NULL; 157char *community = NULL;
158char *oid = NULL; 158char *oid = "";
159char *label = NULL; 159char *label = NULL;
160char *units = NULL; 160char *units = NULL;
161char *port = NULL; 161char *port = NULL;
@@ -189,7 +189,7 @@ main (int argc, char **argv)
189 char input_buffer[MAX_INPUT_BUFFER]; 189 char input_buffer[MAX_INPUT_BUFFER];
190 char *command_line = NULL; 190 char *command_line = NULL;
191 char *response = NULL; 191 char *response = NULL;
192 char *outbuff = NULL; 192 char *outbuff = "";
193 char *output = NULL; 193 char *output = NULL;
194 char *ptr = NULL; 194 char *ptr = NULL;
195 char *p2 = NULL; 195 char *p2 = NULL;
@@ -197,7 +197,6 @@ main (int argc, char **argv)
197 197
198 labels = malloc (labels_size); 198 labels = malloc (labels_size);
199 unitv = malloc (unitv_size); 199 unitv = malloc (unitv_size);
200 outbuff = strscpy (outbuff, "");
201 for (i = 0; i < MAX_OIDS; i++) 200 for (i = 0; i < MAX_OIDS; i++)
202 eval_method[i] = CHECK_UNDEF; 201 eval_method[i] = CHECK_UNDEF;
203 i = 0; 202 i = 0;
@@ -206,8 +205,8 @@ main (int argc, char **argv)
206 usage ("Incorrect arguments supplied\n"); 205 usage ("Incorrect arguments supplied\n");
207 206
208 /* create the command line to execute */ 207 /* create the command line to execute */
209 asprintf (&command_line, "%s -p %s -m ALL -v 1 %s -c %s %s", 208 asprintf (&command_line, "%s -m ALL -v 1 -c %s %s:%s %s",
210 PATH_TO_SNMPGET, port, server_address, community, oid); 209 PATH_TO_SNMPGET, community, server_address, port, oid);
211 if (verbose) 210 if (verbose)
212 printf ("%s\n", command_line); 211 printf ("%s\n", command_line);
213 212
@@ -368,9 +367,9 @@ main (int argc, char **argv)
368 result = max_state (result, STATE_WARNING); 367 result = max_state (result, STATE_WARNING);
369 368
370 if (nunits > 0) 369 if (nunits > 0)
371 printf ("%s %s -%s\n", label, state_text (result), outbuff);
372 else
373 printf ("%s %s -%s %s\n", label, state_text (result), outbuff, units); 370 printf ("%s %s -%s %s\n", label, state_text (result), outbuff, units);
371 else
372 printf ("%s %s -%s\n", label, state_text (result), outbuff);
374 373
375 return result; 374 return result;
376} 375}