summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_snmp.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index bfc49aa..13e12ff 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -146,8 +146,8 @@ main (int argc, char **argv)
146 /* create the command line to execute */ 146 /* create the command line to execute */
147 command_line = ssprintf 147 command_line = ssprintf
148 (command_line, 148 (command_line,
149 "%s -m ALL -v 1 %s %s %s", 149 "%s -p %s -m ALL -v 1 %s -c %s %s",
150 PATH_TO_SNMPGET, server_address, community, oid); 150 PATH_TO_SNMPGET, port, server_address, community, oid);
151 151
152 /* run the command */ 152 /* run the command */
153 child_process = spopen (command_line); 153 child_process = spopen (command_line);
@@ -221,7 +221,8 @@ main (int argc, char **argv)
221 p2 = strpbrk (p2, "0123456789"); 221 p2 = strpbrk (p2, "0123456789");
222 response_value[i] = strtoul (p2, NULL, 10); 222 response_value[i] = strtoul (p2, NULL, 10);
223 iresult = check_num (i); 223 iresult = check_num (i);
224 show = ssprintf (show, "%lu", response_value[i]); 224 /*For consistency- full SNMP response every time */
225 show = ssprintf (show, "%d", response);
225 } 226 }
226 227
227 else if (eval_method[i] & CRIT_STRING) { 228 else if (eval_method[i] & CRIT_STRING) {
@@ -260,7 +261,7 @@ main (int argc, char **argv)
260 iresult = STATE_WARNING; 261 iresult = STATE_WARNING;
261 } 262 }
262 263
263 result = max_state (result, iresult); 264 result = max (result, iresult);
264 265
265 if (nlabels > 1 && i < nlabels && labels[i] != NULL) 266 if (nlabels > 1 && i < nlabels && labels[i] != NULL)
266 outbuff = ssprintf 267 outbuff = ssprintf
@@ -291,14 +292,14 @@ main (int argc, char **argv)
291 292
292 /* WARNING if output found on stderr */ 293 /* WARNING if output found on stderr */
293 if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) 294 if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
294 result = max_state (result, STATE_WARNING); 295 result = max (result, STATE_WARNING);
295 296
296 /* close stderr */ 297 /* close stderr */
297 (void) fclose (child_stderr); 298 (void) fclose (child_stderr);
298 299
299 /* close the pipe */ 300 /* close the pipe */
300 if (spclose (child_process)) 301 if (spclose (child_process))
301 result = max_state (result, STATE_WARNING); 302 result = max (result, STATE_WARNING);
302 303
303 if (nunits > 0) 304 if (nunits > 0)
304 printf ("%s %s -%s\n", label, state_text (result), outbuff); 305 printf ("%s %s -%s\n", label, state_text (result), outbuff);
@@ -352,9 +353,6 @@ process_arguments (int argc, char **argv)
352 if (port == NULL) 353 if (port == NULL)
353 port = strscpy(NULL,"161"); 354 port = strscpy(NULL,"161");
354 355
355 if (port == NULL)
356 port = strscpy(NULL,"161");
357
358 return c; 356 return c;
359} 357}
360 358
@@ -385,6 +383,7 @@ call_getopt (int argc, char **argv)
385 {"eregi", required_argument, 0, 'R'}, 383 {"eregi", required_argument, 0, 'R'},
386 {"label", required_argument, 0, 'l'}, 384 {"label", required_argument, 0, 'l'},
387 {"units", required_argument, 0, 'u'}, 385 {"units", required_argument, 0, 'u'},
386 {"port", required_argument, 0, 'p'},
388 {0, 0, 0, 0} 387 {0, 0, 0, 0}
389 }; 388 };
390#endif 389#endif
@@ -392,10 +391,10 @@ call_getopt (int argc, char **argv)
392 while (1) { 391 while (1) {
393#ifdef HAVE_GETOPT_H 392#ifdef HAVE_GETOPT_H
394 c = 393 c =
395 getopt_long (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:", 394 getopt_long (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:p:",
396 long_options, &option_index); 395 long_options, &option_index);
397#else 396#else
398 c = getopt (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:"); 397 c = getopt (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:p:");
399#endif 398#endif
400 399
401 if (c == -1 || c == EOF) 400 if (c == -1 || c == EOF)
@@ -576,6 +575,10 @@ call_getopt (int argc, char **argv)
576 unitv[nunits - 1] = ptr; 575 unitv[nunits - 1] = ptr;
577 } 576 }
578 break; 577 break;
578 case 'p': /* TCP port number */
579 port = strscpy(port, optarg);
580 break;
581
579 } 582 }
580 } 583 }
581 return i; 584 return i;
@@ -587,7 +590,7 @@ print_usage (void)
587 printf 590 printf
588 ("Usage: check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n" 591 ("Usage: check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n"
589 " [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n" 592 " [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n"
590 " [-l label] [-u units] [-d delimiter] [-D output-delimiter]\n" 593 " [-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"
591 " check_snmp --help\n" " check_snmp --version\n"); 594 " check_snmp --help\n" " check_snmp --version\n");
592} 595}
593 596
@@ -617,7 +620,7 @@ print_help (char *cmd)
617 " -u, --units=STRING\n" 620 " -u, --units=STRING\n"
618 " Units label(s) for output data (e.g., 'sec.').\n" 621 " Units label(s) for output data (e.g., 'sec.').\n"
619 " -p, --port=STRING\n" 622 " -p, --port=STRING\n"
620 " TCP port number target is listening on.\n" 623 " UDP port number target is listening on.\n"
621 " -d, --delimiter=STRING\n" 624 " -d, --delimiter=STRING\n"
622 " Delimiter to use when parsing returned data. Default is \"%s\"\n" 625 " Delimiter to use when parsing returned data. Default is \"%s\"\n"
623 " Any data on the right hand side of the delimiter is considered\n" 626 " Any data on the right hand side of the delimiter is considered\n"