Hi Dirk,
I'm looking at implementing this (but somewhat differently than your code) into Observium, but most of my devices don't really report anything useful here. Do you happen to have a few example snmpwalks and types of devices that supply useful information in this table? Have you run into any that report supported MIBs we don't already link through our definitions?
Thanks, Tom
On 06/02/2016 16:00, Dirk-Willem van Gulik wrote:
On some systems SNMPv2-MIB:: sysORTable contains a list of MIBs supported by the agent. Of interest is the:
sysORID
entry which is defined as:
An authoritative identification of a capabilities statement with respect to various MIB modules supported by the local SNMPv2 entity acting in an agent role.
and has the OID of those MIBs.
Below tiny patch allows these to be
automatically included in the (sensor) scan.
Provides an option to have some skipped ($config['autodiscovery']['snmp_sysord']['ignore’]).
Dw
Index: include-dir-mib.inc.php
--- include-dir-mib.inc.php (revision HEAD) +++ include-dir-mib.inc.php (working copy) @@ -32,17 +32,39 @@
$include_lib = isset($include_lib) && $include_lib;
-foreach (get_device_mibs($device) as $mib) +$mibs = get_device_mibs($device);
+// Check for any (extra) advertized MIBs in the sysORD table; note that we are +// intentionally using 'all' - as we need the textual MIB name in order to +// create a possible file name. +// +$advertizedMIBs = snmpwalk_cache_multi_oid($device, "SNMPv2-MIB::sysORID", array(), "all"); +foreach($advertizedMIBs as $index=> $entry) {
- $mib = strtoupper(reset($entry));
- if (!strstr($mib,'-mib')) {
$mib = preg_replace('/MIB$/','-MIB',$mib);
- };
- if (!preg_grep('/'.$mib.'/i',$config['autodiscovery']['snmp_sysord']['ignore'])
&& !preg_grep('/'.$mib.'/i', $mibs))
- {
array_push($mibs, $mib);
- };
+};
+foreach ($mibs as $mib) { $inc_dir = $config['install_dir'] . '/' . $include_dir . '/' . strtolower($mib); $inc_file = $inc_dir . '.inc.php';
- if (is_device_mib($device, $mib))
- // We are bypassing the 'is part of the get_device_mibs list' check; as we are passing
- // a list sourced from get_device_mibs with possibly additional discovery.
- //
- if (is_device_mib($device, $mib, TRUE, FALSE)) { if (is_file($inc_file)) { if (OBS_DEBUG) { echo("[[$mib]]"); }
include($inc_file); if ($include_lib && is_file($inc_dir . '.lib.php’))
Index: common.inc.php
--- common.inc.php (revision HEAD) +++ common.inc.php (working copy) @@ -2172,11 +2174,14 @@ // DOCME needs phpdoc block // TESTME needs unit testing // MOVEME to includes/functions.inc.php -function is_device_mib($device, $mib, $check_permissions = TRUE) +function is_device_mib($device, $mib, $check_permissions = TRUE, $check_in_mib_list = TRUE) { global $config;
- $mib_permitted = in_array($mib, get_device_mibs($device)); // Check if mib available for device
- $mib_permitted = TRUE;
- if ($check_in_mib_list)
- $mib_permitted = in_array($mib, get_device_mibs($device)); // Check if mib available for device
- if ($check_permissions && $mib_permitted && (!isset($config['mibs'][$mib]['enable']) || $config['mibs'][$mib]['enable'])) { // Check if MIB permitted by config
Index: defaults.inc.php
--- defaults.inc.php (revision HEAD) +++ defaults.inc.php (working copy) @@ -174,6 +174,7 @@ $config['snmp']['v3'][0]['cryptopass'] = ""; // Privacy (Encryption) Passphrase $config['snmp']['v3'][0]['cryptoalgo'] = "AES"; // AES | DES
// Autodiscovery Settings
$config['autodiscovery']['xdp'] = TRUE; // Autodiscover hosts via discovery protocols (CDP, LLDP, FDP, AMAP and other)
@@ -186,6 +187,8 @@ $config['autodiscovery']['ip_nets'] = array("127.0.0.0/8", "192.168.0.0/16", "10.0.0.0/8", "172.16.0.0/12"); // Networks to permit autodiscovery $config['autodiscovery']['ping_skip'] = FALSE; // Skip icmp echo checks during autodiscovery (beware timeouts during discovery!)
+$config['autodiscovery']['snmp_sysord']['ignore'] = array('snmpMPDCompliance',' usmMIBCompliance','snmpFrameworkMIBCompliance','vacmBasicGroup','snmpNotifyFullCompliance');
$config['discover_services'] = FALSE; // Autodiscover services via SNMP on devices of type "server"
// Mailer backend Settings
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium