diff options
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 728d692a..97c86a3a 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -121,7 +121,9 @@ int retries = 0; | |||
121 | unsigned long eval_method[MAX_OIDS]; | 121 | unsigned long eval_method[MAX_OIDS]; |
122 | char *delimiter; | 122 | char *delimiter; |
123 | char *output_delim; | 123 | char *output_delim; |
124 | char *miblist; | 124 | char *miblist = NULL; |
125 | int needmibs = FALSE; | ||
126 | |||
125 | 127 | ||
126 | int | 128 | int |
127 | main (int argc, char **argv) | 129 | main (int argc, char **argv) |
@@ -158,7 +160,7 @@ main (int argc, char **argv) | |||
158 | output = strdup (""); | 160 | output = strdup (""); |
159 | delimiter = strdup (" = "); | 161 | delimiter = strdup (" = "); |
160 | output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); | 162 | output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); |
161 | miblist = strdup (DEFAULT_MIBLIST); | 163 | /* miblist = strdup (DEFAULT_MIBLIST); */ |
162 | timeout_interval = DEFAULT_TIMEOUT; | 164 | timeout_interval = DEFAULT_TIMEOUT; |
163 | retries = DEFAULT_RETRIES; | 165 | retries = DEFAULT_RETRIES; |
164 | 166 | ||
@@ -510,6 +512,15 @@ process_arguments (int argc, char **argv) | |||
510 | retries = atoi(optarg); | 512 | retries = atoi(optarg); |
511 | break; | 513 | break; |
512 | case 'o': /* object identifier */ | 514 | case 'o': /* object identifier */ |
515 | if ( strspn( optarg, "0123456789." ) != strlen( optarg ) ) { | ||
516 | /* | ||
517 | * we have something other than digits and periods, so we | ||
518 | * have a mib variable, rather than just an SNMP OID, so | ||
519 | * we have to actually read the mib files | ||
520 | */ | ||
521 | needmibs = TRUE; | ||
522 | } | ||
523 | |||
513 | for (ptr = optarg; (ptr = index (ptr, ',')); ptr++) | 524 | for (ptr = optarg; (ptr = index (ptr, ',')); ptr++) |
514 | ptr[0] = ' '; /* relpace comma with space */ | 525 | ptr[0] = ' '; /* relpace comma with space */ |
515 | for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) | 526 | for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) |
@@ -627,6 +638,8 @@ process_arguments (int argc, char **argv) | |||
627 | 638 | ||
628 | if (community == NULL) | 639 | if (community == NULL) |
629 | community = strdup (DEFAULT_COMMUNITY); | 640 | community = strdup (DEFAULT_COMMUNITY); |
641 | |||
642 | |||
630 | 643 | ||
631 | return validate_arguments (); | 644 | return validate_arguments (); |
632 | } | 645 | } |
@@ -640,13 +653,11 @@ process_arguments (int argc, char **argv) | |||
640 | 653 | ||
641 | <para>&PROTO_validate_arguments;</para> | 654 | <para>&PROTO_validate_arguments;</para> |
642 | 655 | ||
643 | <para>Given a database name, this function returns TRUE if the string | 656 | <para>Checks to see if the default miblist needs to be loaded. Also verifies |
644 | is a valid PostgreSQL database name, and returns false if it is | 657 | the authentication and authorization combinations based on protocol version |
645 | not.</para> | 658 | selected.</para> |
646 | 659 | ||
647 | <para>Valid PostgreSQL database names are less than &NAMEDATALEN; | 660 | <para></para> |
648 | characters long and consist of letters, numbers, and underscores. The | ||
649 | first character cannot be a number, however.</para> | ||
650 | 661 | ||
651 | </sect3> | 662 | </sect3> |
652 | -@@ | 663 | -@@ |
@@ -657,6 +668,15 @@ first character cannot be a number, however.</para> | |||
657 | int | 668 | int |
658 | validate_arguments () | 669 | validate_arguments () |
659 | { | 670 | { |
671 | /* check whether to load locally installed MIBS (CPU/disk intensive) */ | ||
672 | if (miblist == NULL) { | ||
673 | if ( needmibs == TRUE ) { | ||
674 | miblist = strdup (DEFAULT_MIBLIST); | ||
675 | }else{ | ||
676 | miblist = "''"; /* don't read any mib files for numeric oids */ | ||
677 | } | ||
678 | } | ||
679 | |||
660 | 680 | ||
661 | /* Need better checks to verify seclevel and authproto choices */ | 681 | /* Need better checks to verify seclevel and authproto choices */ |
662 | 682 | ||
@@ -913,9 +933,11 @@ Check status of remote machines and obtain sustem information via SNMP\n\n")); | |||
913 | /* OID Stuff */ | 933 | /* OID Stuff */ |
914 | printf (_("\ | 934 | printf (_("\ |
915 | -o, --oid=OID(s)\n\ | 935 | -o, --oid=OID(s)\n\ |
916 | Object identifier(s) whose value you wish to query\n\ | 936 | Object identifier(s) or SNMP variables whose value you wish to query\n\ |
917 | -m, --miblist=STRING\n\ | 937 | -m, --miblist=STRING\n\ |
918 | List of MIBS to be loaded (default = ALL)\n -d, --delimiter=STRING\n\ | 938 | List of MIBS to be loaded (default = none if using numeric oids or 'ALL'\n\ |
939 | for symbolic oids.)\n\ | ||
940 | -d, --delimiter=STRING\n\ | ||
919 | Delimiter to use when parsing returned data. Default is \"%s\"\n\ | 941 | Delimiter to use when parsing returned data. Default is \"%s\"\n\ |
920 | Any data on the right hand side of the delimiter is considered\n\ | 942 | Any data on the right hand side of the delimiter is considered\n\ |
921 | to be the data that should be used in the evaluation.\n"), DEFAULT_DELIMITER); | 943 | to be the data that should be used in the evaluation.\n"), DEFAULT_DELIMITER); |