In our recent article, we looked at How to Install and Configure LibreNMS on Ubuntu 18.04 LTS with Nginx. Here we will cover how to monitor VMware ESXi hosts using LibreNMS. LibreNMS is a community-based fork of the last GPL-licensed version of Observium with plenty of features. The tool is based on PHP/MySQL/SNMP and monitors the network together with your servers.
If you’re new to LibreNMS, check out our guide on Top Opensource Network and Server Monitoring Tools, it describes the features of LibreNMS in detail.
Step 1: Configure SNMP on VMware ESXi host
First SSH or Telnet to your ESXi host with root user credentials.
Once logged in, check the current SNMP configurations
# esxcli system snmp get Authentication: Communities: Enable: false Engineid: Hwsrc: indications Loglevel: info Notraps: Port: 161 Privacy: Remoteusers: Syscontact: Syslocation: Targets: Users: V3targets:
Start the configuration by setting the community string(s).
esxcli system snmp set --communities <community>
esxcli system snmp set --communities MY_SNMP_STRING
Configure SNMP Port
esxcli system snmp set --port 161
Enable SNMP on the server
esxcli system snmp set --enable true
esxcli system snmp set --syscontact email@example.com
Set Server Location:
esxcli system snmp set --syslocation DC-01
Check SNMP firewall rules:
If you would like to limit access to SNMP from the trusted subnets or IP addresses only, set it as below:
# esxcli network firewall ruleset allowedip add --ruleset-id snmp \ --ip-address 192.168.3.10 # esxcli network firewall ruleset allowedip add --ruleset-id snmp \ --ip-address 192.168.1.0/24 # esxcli network firewall ruleset set --ruleset-id snmp --enabled true
To allow from any source IP:
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true
To test that the snmpd service is working fine, use the
snmpwalk command on LibreNMS host:
$ snmpwalk -v 1 -c <SNMP-COMMUNITY-STRING> <ESXi-host-ip>
Restart snmp service after making the changes:
# /etc/init.d/snmpd restart
Step 2: Adding VMware ESXi host to LibreNMS
Once you’re done with the configuration of SNMP on ESXi hosts, you can start adding the hosts to LibreNMS for monitoring. LibreNMS provides the ability to automatically add devices on your network using Auto Discovery feature. All discovery methods run when discovery runs (every 6 hours by default and within 5 minutes for new devices
Login to LibreNMS as the librenms user, and navigate to.
/opt/librenms This should be the home folder of
$ cd /opt/librenms
The first thing to do though is add the required configuration options to config.php.
Add SNMP Details
To add devices automatically, LibreNMS needs to know your snmp details, examples of SNMP v1, v2c and v3 are below:
// v1 or v2c $config['snmp']['community'] = "my_custom_community"; $config['snmp']['community'] = "another_community"; // v3 $config['snmp']['v3']['authlevel'] = 'authPriv'; $config['snmp']['v3']['authname'] = 'my_username'; $config['snmp']['v3']['authpass'] = 'my_password'; $config['snmp']['v3']['authalgo'] = 'MD5'; $config['snmp']['v3']['cryptopass'] = 'my_crypto'; $config['snmp']['v3']['cryptoalgo'] = 'AES';
These details will be attempted when adding devices, you can specify any mixture of these.
Define you subnets to be scanned using:
$config['nets'] = '192.168.0.0/24'; $config['nets'] = '172.20.4.0/23';
You can also run a manual SNMP Scan, the syntax is:
$ ./snmp-scan.py [-h] [-r NETWORK] [-t THREADS] [-l] [-v]
$ ./snmp-scan.py 10.245.2.2 Scanning IPs: * Scanned 1 IPs: 1 known devices, added 0 devices, failed to add 0 devices Runtime: 0.39 seconds
This device should appear under Devices > All Devices > Server on LibreNMS admin dashboard.
Give it like 5 minutes to collect Server facts and start creating graphs,
Logs and host events will start to appear as well.