summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_snmp.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 5344b93..7e574c5 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -34,7 +34,7 @@
34-H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\ 34-H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\
35 [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\ 35 [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\
36 [-l label] [-u units] [-p port-number] [-d delimiter]\n\ 36 [-l label] [-u units] [-p port-number] [-d delimiter]\n\
37 [-D output-delimiter]" 37 [-D output-delimiter] [-m miblist]"
38 38
39#define LONGOPTIONS "\ 39#define LONGOPTIONS "\
40 -H, --hostname=HOST\n\ 40 -H, --hostname=HOST\n\
@@ -70,9 +70,9 @@
70 -l, --label=STRING\n\ 70 -l, --label=STRING\n\
71 Prefix label for output from plugin (default -s 'SNMP')\n\ 71 Prefix label for output from plugin (default -s 'SNMP')\n\
72 -v, --verbose\n\ 72 -v, --verbose\n\
73 Debugging the output\n\ 73 Debugging the output\n\
74 74 -m, --miblist=STRING\n\
75 " 75 List of MIBS to be loaded (default = ALL)\n"
76 76
77#define NOTES "\ 77#define NOTES "\
78- This plugin uses the 'snmpget' command included with the NET-SNMP package.\n\ 78- This plugin uses the 'snmpget' command included with the NET-SNMP package.\n\
@@ -99,6 +99,7 @@ This plugin gets system information on a remote server via snmp.\n"
99#define DEFAULT_COMMUNITY "public" 99#define DEFAULT_COMMUNITY "public"
100#define DEFAULT_PORT "161" 100#define DEFAULT_PORT "161"
101#define DEFAULT_TIMEOUT 10 101#define DEFAULT_TIMEOUT 10
102#define DEFAULT_MIBLIST "ALL"
102 103
103#include "common.h" 104#include "common.h"
104#include "utils.h" 105#include "utils.h"
@@ -181,6 +182,7 @@ int check_critical_value = FALSE;
181int eval_method[MAX_OIDS]; 182int eval_method[MAX_OIDS];
182char *delimiter = NULL; 183char *delimiter = NULL;
183char *output_delim = NULL; 184char *output_delim = NULL;
185char *miblist = NULL;
184 186
185 187
186int 188int
@@ -209,8 +211,8 @@ main (int argc, char **argv)
209 usage ("Incorrect arguments supplied\n"); 211 usage ("Incorrect arguments supplied\n");
210 212
211 /* create the command line to execute */ 213 /* create the command line to execute */
212 asprintf (&command_line, "%s -m ALL -v 1 -c %s %s:%s %s", 214 asprintf (&command_line, "%s -m %s -v 1 -c %s %s:%s %s",
213 PATH_TO_SNMPGET, community, server_address, port, oid); 215 PATH_TO_SNMPGET, miblist, community, server_address, port, oid);
214 if (verbose) 216 if (verbose)
215 printf ("%s\n", command_line); 217 printf ("%s\n", command_line);
216 218
@@ -422,10 +424,10 @@ process_arguments (int argc, char **argv)
422 while (1) { 424 while (1) {
423#ifdef HAVE_GETOPT_H 425#ifdef HAVE_GETOPT_H
424 c = 426 c =
425 getopt_long (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:", 427 getopt_long (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:",
426 long_options, &option_index); 428 long_options, &option_index);
427#else 429#else
428 c = getopt (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:"); 430 c = getopt (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:");
429#endif 431#endif
430 432
431 if (c == -1 || c == EOF) 433 if (c == -1 || c == EOF)
@@ -602,6 +604,9 @@ process_arguments (int argc, char **argv)
602 case 'p': /* TCP port number */ 604 case 'p': /* TCP port number */
603 port = strscpy(port, optarg); 605 port = strscpy(port, optarg);
604 break; 606 break;
607 case 'm': /* List of MIBS */
608 miblist = strscpy(miblist, optarg);
609 break;
605 610
606 } 611 }
607 } 612 }
@@ -645,6 +650,9 @@ validate_arguments ()
645 if (output_delim == NULL) 650 if (output_delim == NULL)
646 asprintf (&output_delim, DEFAULT_OUTPUT_DELIMITER); 651 asprintf (&output_delim, DEFAULT_OUTPUT_DELIMITER);
647 652
653 if (miblist == NULL)
654 asprintf (&miblist, DEFAULT_MIBLIST);
655
648 if (label == NULL) 656 if (label == NULL)
649 asprintf (&label, "SNMP"); 657 asprintf (&label, "SNMP");
650 658