Wednesday, July 3, 2024
HomeServerMonitoring & ManagementHow To Monitor VMware ESXi Host Using LibreNMS

How To Monitor VMware ESXi Host Using LibreNMS

In our recent article, we looked at Install and Configure LibreNMS on Ubuntu. 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>

e.g

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

Set syscontact

esxcli system snmp set --syscontact [email protected]

Set Server Location:

esxcli system snmp set --syslocation DC-01

Check SNMP firewall rules:

# esxcli network firewall get
   Default Action: DROP
   Enabled: true
   Loaded: true

# esxcli network firewall ruleset rule list  | grep snmp
snmp                Inbound    UDP       Dst               161       161

# esxcli network firewall ruleset allowedip list | grep snmp
snmp                All

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>

E.g

# snmpwalk -v 1 -c AADHrptO472lQo 10.245.2.2 | more
SNMPv2-MIB::sysDescr.0 = STRING: VMware ESXi 5.1.0 build-2000251 VMware, Inc. x86_64
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.6876.4.1
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (126700) 0:21:07.00
SNMPv2-MIB::sysContact.0 = STRING: [email protected]
SNMPv2-MIB::sysName.0 = STRING: esxi-01.local
SNMPv2-MIB::sysLocation.0 = STRING: DC-01
SNMPv2-MIB::sysServices.0 = INTEGER: 72
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: IF-MIB::ifMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: IP-FORWARD-MIB::ipForward
SNMPv2-MIB::sysORID.5 = OID: UDP-MIB::udp
SNMPv2-MIB::sysORID.6 = OID: TCP-MIB::tcp
SNMPv2-MIB::sysORID.7 = OID: SNMPv2-SMI::mib-2.47
SNMPv2-MIB::sysORID.8 = OID: SNMPv2-SMI::org.111.2.802.1.1.2
SNMPv2-MIB::sysORID.9 = OID: SNMPv2-SMI::org.111.2.802.1.1.4
SNMPv2-MIB::sysORID.10 = OID: iso.2.840.10006.300.43
SNMPv2-MIB::sysORID.11 = OID: SNMPv2-SMI::org.111.2.802.1.1.13
SNMPv2-MIB::sysORID.12 = OID: HOST-RESOURCES-MIB::hostResourcesMibModule
SNMPv2-MIB::sysORID.13 = OID: SNMPv2-SMI::enterprises.6876.1.10
SNMPv2-MIB::sysORID.14 = OID: SNMPv2-SMI::enterprises.6876.2.10
SNMPv2-MIB::sysORID.15 = OID: SNMPv2-SMI::enterprises.6876.3.10
SNMPv2-MIB::sysORID.16 = OID: SNMPv2-SMI::enterprises.6876.4.90.10
SNMPv2-MIB::sysORID.17 = OID: SNMPv2-SMI::enterprises.6876.4.20
SNMPv2-MIB::sysORDescr.1 = STRING: SNMPv2-MIB, RFC 3418
SNMPv2-MIB::sysORDescr.2 = STRING: IF-MIB, RFC 2863
SNMPv2-MIB::sysORDescr.3 = STRING: IP-MIB, RFC 4293
SNMPv2-MIB::sysORDescr.4 = STRING: IP-FORWARD-MIB, RFC 4292
SNMPv2-MIB::sysORDescr.5 = STRING: UDP-MIB, RFC 4113
SNMPv2-MIB::sysORDescr.6 = STRING: TCP-MIB, RFC 4022
SNMPv2-MIB::sysORDescr.7 = STRING: ENTITY-MIB, RFC 4133
SNMPv2-MIB::sysORDescr.8 = STRING: IEEE8021-BRIDGE-MIB, REVISION 200810150000Z
SNMPv2-MIB::sysORDescr.9 = STRING: IEEE8021-Q-BRIDGE-MIB, REVISION 200810150000Z
SNMPv2-MIB::sysORDescr.10 = STRING: IEEE8023-LAG-MIB, REVISION 200706200000Z
SNMPv2-MIB::sysORDescr.11 = STRING: LLDP-V2-MIB, REVISION 200906080000Z
SNMPv2-MIB::sysORDescr.12 = STRING: HOST-RESOURCES-MIB, RFC 2790
SNMPv2-MIB::sysORDescr.13 = STRING: VMWARE-SYSTEM-MIB, REVISION 201008020000Z
SNMPv2-MIB::sysORDescr.14 = STRING: VMWARE-VMINFO-MIB, REVISION 201006220000Z
SNMPv2-MIB::sysORDescr.15 = STRING: VMWARE-RESOURCES-MIB, REVISION 200810150000Z

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 librenms user.

$  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'][0]['authlevel'] = 'authPriv';
$config['snmp']['v3'][0]['authname'] = 'my_username';
$config['snmp']['v3'][0]['authpass'] = 'my_password';
$config['snmp']['v3'][0]['authalgo'] = 'MD5';
$config['snmp']['v3'][0]['cryptopass'] = 'my_crypto';
$config['snmp']['v3'][0]['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]

Example:

$ ./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.

librenms add device 03 min

Give it like 5 minutes to collect Server facts and start creating graphs,

librenms add device 01 min

Logs and host events will start to appear as well.

librenms add device 02 min

More on monitoring:

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments