461631 - [RHEL 5] snmpd to allow disk mount configuration Source: upstream, SVN rev. 15249, 15251, and 16393 Backport skipNFSInHostResources option diff -Naurp net-snmp-5.3.2.2/include/net-snmp/agent/ds_agent.h.vanhoof net-snmp-5.3.2.2/include/net-snmp/agent/ds_agent.h --- net-snmp-5.3.2.2/include/net-snmp/agent/ds_agent.h.vanhoof 2008-08-25 17:15:38.000000000 -0400 +++ net-snmp-5.3.2.2/include/net-snmp/agent/ds_agent.h 2008-08-25 17:15:48.000000000 -0400 @@ -20,6 +20,7 @@ #define NETSNMP_DS_AGENT_DONT_RETAIN_NOTIFICATIONS 10 /* 1 = disable trap logging */ #define NETSNMP_DS_AGENT_DONT_LOG_TCPWRAPPERS_CONNECTS 12 /* 1 = disable logging */ #define NETSNMP_DS_APP_DONT_LOG NETSNMP_DS_AGENT_DONT_RETAIN_NOTIFICATIONS /* compat */ +#define NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES 13 /* 1 = don't store NFS entries in hrStorageTable */ /* WARNING: The trap receiver uses DS flags and must not conflict with these! If you use a value above 15, change the minimimum DS bool diff -Naurp net-snmp-5.3.2.2/agent/mibgroup/host/hr_storage.c.vanhoof net-snmp-5.3.2.2/agent/mibgroup/host/hr_storage.c --- net-snmp-5.3.2.2/agent/mibgroup/host/hr_storage.c.vanhoof 2008-08-25 17:10:51.000000000 -0400 +++ net-snmp-5.3.2.2/agent/mibgroup/host/hr_storage.c 2008-08-25 17:10:56.000000000 -0400 @@ -348,9 +348,17 @@ init_hr_storage(void) myHost = mach_host_self(); #endif + char *appname; + REGISTER_MIB("host/hr_storage", hrstore_variables, variable4, hrstore_variables_oid); + appname = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, + NETSNMP_DS_LIB_APPTYPE); + netsnmp_ds_register_config(ASN_BOOLEAN, appname, "skipNFSInHostResources", + NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES); + snmpd_register_config_handler("storageUseNFS", parse_storage_config, NULL, "1 | 2\t\t(1 = enable, 2 = disable)"); } @@ -553,6 +561,12 @@ really_try_next: if (store_idx == MATCH_FAILED) return NULL; + if (HRFS_entry && + netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) && + Check_HR_FileSys_NFS()) + return NULL; + if (store_idx > HRS_TYPE_FIXED_MAX) { if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) { snmp_log_perror(HRFS_entry->HRFS_mount); @@ -956,12 +970,18 @@ Get_Next_HR_Store(void) /* * File-based storage */ - HRS_index = Get_Next_HR_FileSys(); - - if (HRS_index >= 0) - return HRS_index + HRS_TYPE_FIXED_MAX; - - return -1; + for (;;) { + HRS_index = Get_Next_HR_FileSys(); + if (HRS_index >= 0) { + if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) && + Check_HR_FileSys_NFS())) { + return HRS_index + HRS_TYPE_FIXED_MAX; + } + } else { + return -1; + } + } } #ifdef linux diff --git a/net-snmp/man/snmpd.conf.5.def b/net-snmp/man/snmpd.conf.5.def index 3a238de..b74deab 100644 --- net-snmp/man/snmpd.conf.5.def +++ net-snmp/man/snmpd.conf.5.def @@ -400,6 +400,11 @@ to determine the list of devices that will be scanned. .IP The pattern can include one or more wildcard expressions. See \fIsnmpd.examples(5)\fR for illustration of the wildcard syntax. +.IP "skipNFSInHostResources true" +controls whether NFS and NFS-like file systems should be omitted +from the hrStorageTable (true or 1) or not (false or 0, which is the default). +If the Net-SNMP agent gets hung on NFS-mounted filesystems, you +can try setting this to '1'. .IP "storageUseNFS [1|2]" controls how NFS and NFS-like file systems should be reported in the hrStorageTable.