diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_snmp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 7851631c..35e1f339 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
| @@ -516,6 +516,7 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
| 516 | char *port = NULL; | 516 | char *port = NULL; |
| 517 | char *miblist = NULL; | 517 | char *miblist = NULL; |
| 518 | char *connection_prefix = NULL; | 518 | char *connection_prefix = NULL; |
| 519 | bool snmp_version_set_explicitely = false; | ||
| 519 | // TODO error checking | 520 | // TODO error checking |
| 520 | while (true) { | 521 | while (true) { |
| 521 | int option_char = getopt_long( | 522 | int option_char = getopt_long( |
| @@ -567,6 +568,8 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
| 567 | } else { | 568 | } else { |
| 568 | die(STATE_UNKNOWN, "invalid SNMP version/protocol: %s", optarg); | 569 | die(STATE_UNKNOWN, "invalid SNMP version/protocol: %s", optarg); |
| 569 | } | 570 | } |
| 571 | snmp_version_set_explicitely = true; | ||
| 572 | |||
| 570 | break; | 573 | break; |
| 571 | case 'N': /* SNMPv3 context name */ | 574 | case 'N': /* SNMPv3 context name */ |
| 572 | config.snmp_session.contextName = optarg; | 575 | config.snmp_session.contextName = optarg; |
| @@ -858,6 +861,11 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
| 858 | setenv("MIBS", miblist, 1); | 861 | setenv("MIBS", miblist, 1); |
| 859 | } | 862 | } |
| 860 | 863 | ||
| 864 | // Historical default is SNMP v2c | ||
| 865 | if (!snmp_version_set_explicitely && config.snmp_session.community != NULL) { | ||
| 866 | config.snmp_session.version = SNMP_VERSION_2c; | ||
| 867 | } | ||
| 868 | |||
| 861 | if ((config.snmp_session.version == SNMP_VERSION_1) || | 869 | if ((config.snmp_session.version == SNMP_VERSION_1) || |
| 862 | (config.snmp_session.version == SNMP_VERSION_2c)) { /* snmpv1 or snmpv2c */ | 870 | (config.snmp_session.version == SNMP_VERSION_2c)) { /* snmpv1 or snmpv2c */ |
| 863 | /* | 871 | /* |
