From 7f5c555ba59af0c37b3bc57c7acbd18ccecb7436 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 3 Jan 2017 17:12:39 +0000 Subject: [PATCH] refactor: Move mib based polling into yaml config files (#5234) * refactor: More mib based polling into yaml config files * doc update * Update MIB-based-polling.md --- doc/Extensions/MIB-based-polling.md | 30 ++++++++------------ html/pages/device/mib.inc.php | 2 +- includes/common.php | 2 +- includes/definitions/ios.yaml | 2 ++ includes/definitions/iosxe.yaml | 2 ++ includes/definitions/iosxr.yaml | 2 ++ includes/definitions/lenovoemc.yaml | 5 ++++ includes/definitions/linux.yaml | 9 ++++++ includes/definitions/routeros.yaml | 2 ++ includes/definitions/ruckuswireless.yaml | 5 ++++ includes/definitions/serveriron.yaml | 8 ++++++ includes/discovery/functions.inc.php | 3 ++ includes/discovery/os/ios.inc.php | 5 ---- includes/discovery/os/iosxe.inc.php | 5 ---- includes/discovery/os/iosxr.inc.php | 5 ---- includes/discovery/os/lenovoemc.inc.php | 8 ------ includes/discovery/os/linux.inc.php | 11 ------- includes/discovery/os/routeros.inc.php | 7 ----- includes/discovery/os/ruckuswireless.inc.php | 8 ------ 19 files changed, 52 insertions(+), 69 deletions(-) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index 7a707ef1eb..1687569df5 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -147,32 +147,26 @@ graph. ## Configuration ### Main Configuration -In `/opt/librenms/config.php` add `$config['poller_modules']['mib'] = 1;` +In `/opt/librenms/config.php` add `$config['poller_modules']['mib'] = 1;` to enable MIB polling globally. +Alternatively you can enable MIB polling per device by enabling it within the modules section for the specific device. ### Discovery -You need to add your desired MIBs to `/opt/librenms/mibs` folder. Afterwards you need to register your MIBs to the discovery function. +You need to add your desired MIBs to `/opt/librenms/mibs` folder. +You will then need to create a list of the OIDs you wish to use in the OS definition. #### Example -`/opt/librenms/includes/discovery/os/f5.inc.php` - -``` - 'F5-BIGIP-LOCAL-MIB', -); - -### Actual registering of the MIB -register_mibs($device, $f5_mibs, "includes/discovery/os/f5.inc.php"); +`/opt/librenms/includes/definitions/ruckuswireless.yaml` +```yaml +register_mibs: + ruckusZDSystemStats: RUCKUS-ZD-SYSTEM-MIB + ruckusZDWLANTable: RUCKUS-ZD-WLAN-MIB + ruckusZDWLANAPTable: RUCKUS-ZD-WLAN-MIB + ruckusZDWLANAPRadioStatsTable: RUCKUS-ZD-WLAN-MIB ``` -The important thing is the array $f5_mibs where you define which parts (ltmVirtualServStatEntry) of the MIB (F5-BIGIP-LOCAL-MIB) you are going to add. The registering is also important, otherwise poller cannot make use of the MIB. +These OIDs and MIBs will then be registered as part of the OS discovery ready for mib polling to work. ## TODO ## diff --git a/html/pages/device/mib.inc.php b/html/pages/device/mib.inc.php index 5e7f2c0a97..284e1008fa 100644 --- a/html/pages/device/mib.inc.php +++ b/html/pages/device/mib.inc.php @@ -16,7 +16,7 @@ if (!isset($vars['section'])) { $vars['section'] = "mib"; } -if (is_module_enabled('poller', 'mib')) { +if (is_mib_poller_enabled($device)) { ?>

Device MIB associations

diff --git a/includes/common.php b/includes/common.php index cbc8e73001..10686fbaa8 100644 --- a/includes/common.php +++ b/includes/common.php @@ -1041,7 +1041,7 @@ function print_mib_poller_disabled() { echo '

MIB polling is not enabled

-Set $config[\'poller_modules\'][\'mib\'] = 1; in config.php to enable. +Set $config[\'poller_modules\'][\'mib\'] = 1; in config.php or enable for this device specifically to enable.

'; } // print_mib_poller_disabled diff --git a/includes/definitions/ios.yaml b/includes/definitions/ios.yaml index ee756182bf..bbc988fd69 100644 --- a/includes/definitions/ios.yaml +++ b/includes/definitions/ios.yaml @@ -35,3 +35,5 @@ discovery_modules: cisco-pw: 1 cisco-vrf: 1 cisco-vrf-lite: 1 +register_mibs: + ciscoAAASessionMIB: CISCO-AAA-SESSION-MIB \ No newline at end of file diff --git a/includes/definitions/iosxe.yaml b/includes/definitions/iosxe.yaml index 9235528ad7..f7f9f6cf70 100644 --- a/includes/definitions/iosxe.yaml +++ b/includes/definitions/iosxe.yaml @@ -31,3 +31,5 @@ discovery_modules: cisco-pw: 1 cisco-vrf: 1 cisco-vrf-lite: 1 +register_mibs: + ciscoAAASessionMIB: CISCO-AAA-SESSION-MIB \ No newline at end of file diff --git a/includes/definitions/iosxr.yaml b/includes/definitions/iosxr.yaml index 34dcfd0ac7..c560fd308c 100644 --- a/includes/definitions/iosxr.yaml +++ b/includes/definitions/iosxr.yaml @@ -31,3 +31,5 @@ discovery_modules: cisco-pw: 1 cisco-vrf: 1 cisco-vrf-lite: 1 +register_mibs: + ciscoAAASessionMIB: CISCO-AAA-SESSION-MIB \ No newline at end of file diff --git a/includes/definitions/lenovoemc.yaml b/includes/definitions/lenovoemc.yaml index 70c2917832..179b1a0b88 100644 --- a/includes/definitions/lenovoemc.yaml +++ b/includes/definitions/lenovoemc.yaml @@ -9,3 +9,8 @@ over: - { graph: device_bits, text: 'Device Traffic' } - { graph: device_processor, text: 'CPU Usage' } - { graph: device_mempool, text: 'Memory Usage' } +register_mibs: + fanValue: IOMEGANAS-MIB + tempValue: IOMEGANAS-MIB + raidStatus: IOMEGANAS-MIB + diskStatus: IOMEGANAS-MIB \ No newline at end of file diff --git a/includes/definitions/linux.yaml b/includes/definitions/linux.yaml index e412ffb984..d86cdbb7d9 100644 --- a/includes/definitions/linux.yaml +++ b/includes/definitions/linux.yaml @@ -22,3 +22,12 @@ discovery_modules: toner: 0 vmware-vminfo: 1 processor_stacked: 1 +register_mibs: + rxCounter: GANDI-MIB + txCounter: GANDI-MIB + dropCounter: GANDI-MIB + acldropCounter: GANDI-MIB + ratedropCounter: GANDI-MIB + KNIrxCounter: GANDI-MIB + KNItxCounter: GANDI-MIB + KNIdropCounter: GANDI-MIB \ No newline at end of file diff --git a/includes/definitions/routeros.yaml b/includes/definitions/routeros.yaml index 6065ace039..87689f3d0c 100644 --- a/includes/definitions/routeros.yaml +++ b/includes/definitions/routeros.yaml @@ -8,3 +8,5 @@ over: - { graph: device_bits, text: 'Device Traffic' } - { graph: device_processor, text: 'CPU Usage' } - { graph: device_mempool, text: 'Memory Usage' } +register_mibs: + ciscoAAASessionMIB: CISCO-AAA-SESSION-MIB \ No newline at end of file diff --git a/includes/definitions/ruckuswireless.yaml b/includes/definitions/ruckuswireless.yaml index d74d96fbda..f0ded8d545 100644 --- a/includes/definitions/ruckuswireless.yaml +++ b/includes/definitions/ruckuswireless.yaml @@ -6,3 +6,8 @@ mib_dir: - ruckus over: - { graph: device_bits, text: Traffic } +register_mibs: + ruckusZDSystemStats: RUCKUS-ZD-SYSTEM-MIB + ruckusZDWLANTable: RUCKUS-ZD-WLAN-MIB + ruckusZDWLANAPTable: RUCKUS-ZD-WLAN-MIB + ruckusZDWLANAPRadioStatsTable: RUCKUS-ZD-WLAN-MIB \ No newline at end of file diff --git a/includes/definitions/serveriron.yaml b/includes/definitions/serveriron.yaml index 6431d9d801..e5ac39e451 100644 --- a/includes/definitions/serveriron.yaml +++ b/includes/definitions/serveriron.yaml @@ -7,3 +7,11 @@ over: - { graph: device_processor, text: 'CPU Usage' } - { graph: device_mempool, text: 'Memory Usage' } icon: brocade +register_mibs: + snL4slbTotalConnections: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB + snL4slbLimitExceeds: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB + snL4slbForwardTraffic: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB + snL4slbReverseTraffic: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB + snL4slbFinished: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB + snL4FreeSessionCount: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB + snL4unsuccessfulConn: FOUNDRY-SN-SW-L4-SWITCH-GROUP-MIB \ No newline at end of file diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 2f3dd8a573..9236fec306 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -111,6 +111,9 @@ function discover_device($device, $options = null) } $config['os'][$device['os']] = load_os($device); + if (is_array($config['os'][$device['os']]['register_mibs'])) { + register_mibs($device, $config['os'][$device['os']]['register_mibs'], 'includes/discovery/os/' . $device['os'] . '.inc.php'); + } // Set type to a predefined type for the OS if it's not already set if ($device['type'] == 'unknown' || $device['type'] == '') { diff --git a/includes/discovery/os/ios.inc.php b/includes/discovery/os/ios.inc.php index ab79b7fb5b..bdbf51f0bc 100644 --- a/includes/discovery/os/ios.inc.php +++ b/includes/discovery/os/ios.inc.php @@ -2,9 +2,4 @@ if (str_contains($sysDescr, array('Cisco Internetwork Operating System Software', 'IOS (tm)', 'Cisco IOS Software', 'Global Site Selector')) && !str_contains($sysDescr, array('IOS-XE', 'X86_64_LINUX_IOSD'))) { $os = 'ios'; - - $extra_mibs = array( - "ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB", - ); - register_mibs($device, $extra_mibs, "includes/discovery/os/ios.inc.php"); } diff --git a/includes/discovery/os/iosxe.inc.php b/includes/discovery/os/iosxe.inc.php index 5e337bf4da..e30e8a9192 100644 --- a/includes/discovery/os/iosxe.inc.php +++ b/includes/discovery/os/iosxe.inc.php @@ -2,9 +2,4 @@ if (str_contains($sysDescr, array('IOS-XE', 'X86_64_LINUX_IOSD'))) { $os = 'iosxe'; - - $extra_mibs = array( - "ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB", - ); - register_mibs($device, $extra_mibs, "includes/discovery/os/iosxe.inc.php"); } diff --git a/includes/discovery/os/iosxr.inc.php b/includes/discovery/os/iosxr.inc.php index 05c21e8eb3..fe79eaa261 100644 --- a/includes/discovery/os/iosxr.inc.php +++ b/includes/discovery/os/iosxr.inc.php @@ -2,9 +2,4 @@ if (str_contains($sysDescr, 'IOS XR')) { $os = 'iosxr'; - - $extra_mibs = array( - "ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB", - ); - register_mibs($device, $extra_mibs, "includes/discovery/os/iosxr.inc.php"); } diff --git a/includes/discovery/os/lenovoemc.inc.php b/includes/discovery/os/lenovoemc.inc.php index 33c984139f..1eec47a4d2 100644 --- a/includes/discovery/os/lenovoemc.inc.php +++ b/includes/discovery/os/lenovoemc.inc.php @@ -2,12 +2,4 @@ if (str_contains($sysDescr, 'EMC SOHO-NAS Storage.')) { $os = 'lenovoemc'; - - $lenovoemc_mibs = array( - "fanValue" => "IOMEGANAS-MIB", - "tempValue" => "IOMEGANAS-MIB", - "raidStatus" => "IOMEGANAS-MIB", - "diskStatus" => "IOMEGANAS-MIB" - ); - register_mibs($device, $lenovoemc_mibs, "includes/discovery/os/lenovoemc.inc.php"); } diff --git a/includes/discovery/os/linux.inc.php b/includes/discovery/os/linux.inc.php index 1639f65356..19a0d72265 100644 --- a/includes/discovery/os/linux.inc.php +++ b/includes/discovery/os/linux.inc.php @@ -33,17 +33,6 @@ if (starts_with($sysDescr, 'Linux') && !starts_with($sysObjectId, $skip_oids)) { } } elseif (snmp_get($device, 'GANDI-MIB::rxCounter.0', '-Osqnv', 'GANDI-MIB') !== false) { $os = 'pktj'; - $pktj_mibs = array( - "rxCounter" => "GANDI-MIB", // RX Packets - "txCounter" => "GANDI-MIB", // TX Packets - "dropCounter" => "GANDI-MIB", // Dropped counters - "acldropCounter" => "GANDI-MIB", // ACL Dropped counter - "ratedropCounter" => "GANDI-MIB", // Rate Dropped counter - "KNIrxCounter" => "GANDI-MIB", // KNI RX counter - "KNItxCounter" => "GANDI-MIB", // KNI TX counter - "KNIdropCounter" => "GANDI-MIB", // KNI DROP counter - ); - register_mibs($device, $pktj_mibs, "include/discovery/os/linux.inc.php"); } elseif (starts_with($sysObjectId, '.1.3.6.1.4.1.40310')) { $os = 'cumulus'; } elseif (str_contains($sysDescr, array('g56fa85e', 'gc80f187', 'g829be90', 'g63c0044', 'gba768e5'))) { diff --git a/includes/discovery/os/routeros.inc.php b/includes/discovery/os/routeros.inc.php index 43e84f3940..e501c34a76 100644 --- a/includes/discovery/os/routeros.inc.php +++ b/includes/discovery/os/routeros.inc.php @@ -7,10 +7,3 @@ if (starts_with($sysDescr, 'router') && is_numeric(snmp_get($device, 'SNMPv2-SMI if (starts_with($sysDescr, 'RouterOS')) { $os = 'routeros'; } - -if (!empty($os)) { - $extra_mibs = array( - "ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB", - ); - register_mibs($device, $extra_mibs, "includes/discovery/os/routeros.inc.php"); -} diff --git a/includes/discovery/os/ruckuswireless.inc.php b/includes/discovery/os/ruckuswireless.inc.php index 5790ccd8f8..54cdfd124c 100644 --- a/includes/discovery/os/ruckuswireless.inc.php +++ b/includes/discovery/os/ruckuswireless.inc.php @@ -14,12 +14,4 @@ if (starts_with($sysObjectId, '.1.3.6.1.4.1.25053.3.1')) { $os = 'ruckuswireless'; - - $ruckus_mibs = array( - "ruckusZDSystemStats" => "RUCKUS-ZD-SYSTEM-MIB", - "ruckusZDWLANTable" => "RUCKUS-ZD-WLAN-MIB", - "ruckusZDWLANAPTable" => "RUCKUS-ZD-WLAN-MIB", - "ruckusZDWLANAPRadioStatsTable" => "RUCKUS-ZD-WLAN-MIB", - ); - register_mibs($device, $ruckus_mibs, "includes/discovery/os/ruckuswireless.inc.php"); }