| 
									
										
										
										
											2016-08-24 08:12:20 +01:00
										 |  |  | source: Extensions/MIB-based-polling.md | 
					
						
							| 
									
										
										
										
											2018-10-27 23:04:34 +01:00
										 |  |  | path: blob/master/doc/ | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | ## WARNING ##
 | 
					
						
							| 
									
										
										
										
											2015-06-06 22:46:01 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-13 16:37:02 -06:00
										 |  |  | MIB-based polling is unmaintained and may be removed in the future.  It might overload your LibreNMS server, | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | destroy your data, set your routers on fire, and kick your cat.  It has been | 
					
						
							|  |  |  | tested against a very limited set of devices (namely Ruckus ZD1000 wireless | 
					
						
							| 
									
										
										
										
											2015-07-10 23:15:13 +05:30
										 |  |  | controllers, and `net-snmp` on Linux).  It may fail badly on other hardware. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | The approach taken is fairly simplistic and I claim no special expertise in | 
					
						
							| 
									
										
										
										
											2015-11-15 18:02:29 +10:00
										 |  |  | understanding MIBs.  Most of my knowledge of SNMP comes from reading net-snmp | 
					
						
							|  |  |  | man pages, and reverse engineering the output of snmptranslate and snmpwalk | 
					
						
							|  |  |  | and trying to make devices work with LibreNMS.  I may have made false | 
					
						
							|  |  |  | assumptions and probably use wrong terminology in many places.  Feel free to | 
					
						
							|  |  |  | offer corrections/suggestions via pull requests or email. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | Paul Gear <paul@librenms.org> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Overview ##
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | This is the 2nd experimental release of MIB polling.  If you used the 1st | 
					
						
							|  |  |  | release, you MUST perform a data conversion of the MIB-based polling files | 
					
						
							|  |  |  | using the script `contrib/convert-mib-graphs.sh`.  Failure to do so will | 
					
						
							|  |  |  | result in your data collection silently stopping. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | MIB-based polling is disabled by default; you must set | 
					
						
							| 
									
										
										
										
											2018-06-15 03:45:20 -05:00
										 |  |  |     `$config['poller_modules']['mib'] = true;` | 
					
						
							| 
									
										
										
										
											2015-07-10 23:15:13 +05:30
										 |  |  | in `config.php` to enable it. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | ## Preparation ##
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MIB-based polling results in the creation of a separate RRD file for each | 
					
						
							|  |  |  | device-MIB-OID-index combination encountered by LibreNMS.  Thus it can cause | 
					
						
							|  |  |  | your disk space requirements to grow enormously and rapidly.  As an example, | 
					
						
							|  |  |  | enabling MIB-based polling on my test Ruckus ZD1000 wireless controller with | 
					
						
							|  |  |  | one (1) AP and one (1) user on that AP resulted in a 5 MB increase in RRD | 
					
						
							|  |  |  | space usage for that device.  Each RRD file is around 125 KB in size (on | 
					
						
							| 
									
										
										
										
											2015-12-06 21:03:59 +10:00
										 |  |  | x64-64 systems) and is pre-allocated, so after the first discovery and poller | 
					
						
							| 
									
										
										
										
											2016-01-07 08:59:03 +10:00
										 |  |  | run of each device with MIB-based polling enabled, disk space should be stable. | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | However, monitoring disk usage is your responsibility.  (The good news: you | 
					
						
							|  |  |  | can do this with LibreNMS. :-) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Unless you are running LibreNMS on a powerful system with pure SSD for RRD | 
					
						
							|  |  |  | storage, it is strongly recommended that you enable rrdcached and ensure it is | 
					
						
							|  |  |  | working *before* enabling MIB-based polling. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Components ##
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The components involved in MIB-based polling are: | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Discovery ###
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |   - OS discovery determines whether there are MIBs which should be polled.  If | 
					
						
							|  |  |  |     so, they are registered in the `device_mibs` association table as relevant | 
					
						
							|  |  |  |     to that device.  MIB associations for each device can be viewed at: | 
					
						
							|  |  |  |     http://your.librenms.server/device/device=XXXX/tab=mib/ | 
					
						
							|  |  |  |     All MIBs used by MIB-based polling may be viewed at: | 
					
						
							|  |  |  |     http://your.librenms.server/mibs/ | 
					
						
							| 
									
										
										
										
											2015-12-06 21:05:02 +10:00
										 |  |  |     All device associations created by MIB-based polling may be viewed at: | 
					
						
							|  |  |  |     http://your.librenms.server/mib_assoc/ (Devices -> MIB associations) | 
					
						
							| 
									
										
										
										
											2015-06-06 22:46:01 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |   - In addition, all devices are checked for a MIB matching their sysObjectID. | 
					
						
							|  |  |  |     If there is a matching MIB available, it is automatically included. | 
					
						
							|  |  |  |     The sysObjectID for each device is now displayed on the overview page: | 
					
						
							|  |  |  |     http://your.librenms.server/device/device=XXXX/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   - Note that the above means that no MIB-based polling will occur until the | 
					
						
							|  |  |  |     devices in question are rediscovered.  If you want to begin MIB-based | 
					
						
							|  |  |  |     polling immediately, you must force rediscovery from the web UI, or run it | 
					
						
							|  |  |  |     from the CLI using `./discovery.php -h HOSTNAME` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   - During discovery, relevant MIBs are parsed using `snmptranslate`, and the | 
					
						
							|  |  |  |     data returned is used to populate a database which guides the poller in | 
					
						
							| 
									
										
										
										
											2016-01-14 13:40:37 +10:00
										 |  |  |     what to store.  At the moment, only OIDs of INTEGER, Integer32, Gauge32, | 
					
						
							|  |  |  |     Unsigned32, Counter32, and Counter64 data types are parsed, and negative | 
					
						
							|  |  |  |     values are untested. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |   - Devices may be excluded from MIB polling by changing the setting in the | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |     device edit screen: | 
					
						
							|  |  |  |     http://your.librenms.server/device/device=XXXX/tab=edit/section=modules/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Polling ###
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   - During polling the MIB associations for the device are looked up, and the | 
					
						
							|  |  |  |     MIB is polled for current values.  You can see the values which LibreNMS | 
					
						
							|  |  |  |     has retrieved from the MIB poller in the "Device MIB values" section of | 
					
						
							|  |  |  |     http://your.librenms.server/device/device=XXXX/tab=mib/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   - Data from the latest poll is saved in the table `device_oids`, and RRD | 
					
						
							|  |  |  |     files are saved in the relevant device directory as | 
					
						
							|  |  |  |     mibName-oidName-index.rrd | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Graphing ###
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 18:10:31 +10:00
										 |  |  |   - For each graph type defined in the database, a graph will appear in: | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | 	http://your.librenms.server/device/device=XXXX/tab=graphs/group=mib/ | 
					
						
							| 
									
										
										
										
											2015-06-14 18:10:31 +10:00
										 |  |  |   - MIB graphs are generated generically by | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | 	`html/includes/graphs/device/mib.inc.php` | 
					
						
							|  |  |  |     There is presently no customisation of graphs available. | 
					
						
							|  |  |  |   - If there is only one index under a given OID, it is displayed as a normal | 
					
						
							|  |  |  |     line graph; if there multiple OIDs, they are displayed as a stacked graph. | 
					
						
							|  |  |  |     At the moment, all indices are placed in the same graph.  This is | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  |     non-optimal for, e.g., wifi controllers with hundreds of APs attached. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | ### Alerting ###
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | There is no specific support for alerting in the MIB-based polling engine, but | 
					
						
							|  |  |  | the data it collects may be used in alerts.  Here's an example of an alert | 
					
						
							|  |  |  | which detects when a Ruckus wireless controller reports meshing disabled on an | 
					
						
							|  |  |  | access point: | 
					
						
							|  |  |  |     http://libertysys.com.au/imagebin/3btw98DR.png | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | ## Adding/testing other device types ##
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | One of the goals of this work is to help take out the heavy lifting of adding | 
					
						
							|  |  |  | new device types.  Even if you want fully-customised graphs or tables, you can | 
					
						
							|  |  |  | still use the MIB-based poller to make it easy to gather the data you want to | 
					
						
							|  |  |  | graph. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### How to add a new device MIB ###
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  1. Ensure the manufacturer's MIB is present in the mibs directory.  If you | 
					
						
							|  |  |  |     plan to submit your work to LibreNMS, make sure you attribute the source | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |     of the MIB, including the exact download URL if possible, or explicit | 
					
						
							|  |  |  |     instructions about how to obtain it. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  |  2. Check that `snmptranslate -Ts -M mibs -m MODULE | grep mibName` produces | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |     a named list of OIDs.  See the comments on `snmp_mib_walk()` in | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  |     `includes/snmp.inc.php` for an example. | 
					
						
							|  |  |  |  3. Check that `snmptranslate -Td -On -M mibs -m MODULE MODULE::mibName` | 
					
						
							|  |  |  |     produces a parsed description of the OID values.  An example can be | 
					
						
							|  |  |  |     found in the comments for `snmp_mib_parse()` in `includes/snmp.inc.php`. | 
					
						
							| 
									
										
										
										
											2015-07-10 23:15:13 +05:30
										 |  |  |  4. Get the `sysObjectID` from a device, for example: | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |     ```snmpget -v2c -c public -OUsb -m SNMPv2-MIB -M /opt/librenms/mibs -t 30 hostname sysObjectID.0``` | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  |  5. Ensure `snmptranslate -m all -M /opt/librenms/mibs OID 2>/dev/null` | 
					
						
							|  |  |  |     (where OID is the value returned for sysObjectID above) results in a | 
					
						
							|  |  |  |     valid name for the MIB.  See the comments for `snmp_translate()` in | 
					
						
							|  |  |  |     `includes/snmp.inc.php` for an example.  If this step fails, it means | 
					
						
							| 
									
										
										
										
											2015-07-10 23:15:13 +05:30
										 |  |  |     there is something wrong with the MIB and `net-snmp` cannot parse it. | 
					
						
							| 
									
										
										
										
											2015-06-14 18:15:00 +10:00
										 |  |  |  6. Add any additional MIBs you wish to poll for specific device types to | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |     `includes/discovery/os/OSNAME.inc.php` by calling `poll_mibs()` with the | 
					
						
							|  |  |  |     MIB module and name.  See `includes/discovery/os/ruckuswireless.inc.php` | 
					
						
							|  |  |  |     for an example. | 
					
						
							| 
									
										
										
										
											2015-06-14 18:15:00 +10:00
										 |  |  |  7. That should be all you need to see MIB graphs! | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |  8. If you want to develop more customised support for a particular OS, you | 
					
						
							|  |  |  |     can follow the above process, then use the resultant data collected by | 
					
						
							|  |  |  |     LibreNMS in the RRD files or the database tables `device_oids` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 10:19:07 +01:00
										 |  |  | ## Configuration
 | 
					
						
							| 
									
										
										
										
											2016-02-03 10:24:17 +01:00
										 |  |  | ### Main Configuration
 | 
					
						
							| 
									
										
										
										
											2018-06-15 03:45:20 -05:00
										 |  |  | In `/opt/librenms/config.php` add `$config['poller_modules']['mib'] = true;` to enable MIB polling globally. | 
					
						
							| 
									
										
										
										
											2017-01-03 17:12:39 +00:00
										 |  |  | Alternatively you can enable MIB polling per device by enabling it within the modules section for the specific device. | 
					
						
							| 
									
										
										
										
											2016-02-03 10:19:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Discovery
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 17:12:39 +00:00
										 |  |  | 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. | 
					
						
							| 
									
										
										
										
											2016-02-03 10:19:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #### Example
 | 
					
						
							| 
									
										
										
										
											2017-01-03 17:12:39 +00:00
										 |  |  | `/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 | 
					
						
							| 
									
										
										
										
											2016-02-03 10:19:07 +01:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 17:12:39 +00:00
										 |  |  | These OIDs and MIBs will then be registered as part of the OS discovery ready for mib polling to work. | 
					
						
							| 
									
										
										
										
											2016-02-03 10:19:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  | ## TODO ##
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  | What's not included in MIB-based polling at present?  These may be present in | 
					
						
							|  |  |  | future versions.  Pull requests gratefully accepted! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  |   - Parse and save integer and timetick data types. | 
					
						
							|  |  |  |   - Filter MIBs/OIDs from being polled and/or saved. | 
					
						
							| 
									
										
										
										
											2015-11-15 17:38:26 +10:00
										 |  |  |   - Move graphs from the MIB section to elsewhere. e.g. If a device uses a | 
					
						
							|  |  |  |     unique MIB for CPU utilisation, we should display it under the relevant | 
					
						
							|  |  |  |     health tab. | 
					
						
							| 
									
										
										
										
											2015-06-14 17:31:56 +10:00
										 |  |  |   - Combine multiple MIB values into graphs automatically on a predefined or | 
					
						
							|  |  |  |     user-defined basis. | 
					
						
							|  |  |  |   - Include MIB types in stats submissions. |