Simple Network Management Protocol (SNMP) offers a way to collect information about network devices. Having been around for decades, it can be found in many different types of devices such as routers, switches, servers and printers. The HAProxy Enterprise SNMP module enables the load balancer to send metrics data to your network monitoring device or software.
Enable the SNMP module
Install the SNMP daemon for your operating system (
snmpd), which listens on UDP port 161 for requests from the SNMP management software (i.e. the monitoring device):
# On Debian/Ubuntu $ apt install install snmpd # On CentOS/RedHat $ yum install install net-snmp
Install the HAProxy Enterprise SNMP module. This collects data from HAProxy Enterprise for
$ # On Debian/Ubuntu $ sudo apt-get install hapee-extras-snmp-lb
$ # On CentOS/RedHat/Oracle $ sudo yum install hapee-extras-snmp-lb
In your HAProxy Enterprise configuration, add a new
stats socketline that points to /var/run/hapee-extras/hapee-lb.sock. to the
globalsection. The SNMP module connects to this socket to retrieve metrics data.
global stats socket
/var/run/hapee-extras/hapee-lb.sockuser hapee-lb group hapee mode 660 level user
On Debian and Ubuntu, set the
groupparameter on this line to Debian-snmp instead of hapee. That is the group within which the SNMP daemon runs.
Restart the HAProxy Enterprise service:
$ sudo systemctl restart hapee-1.8-lb
Edit the file /etc/snmp/snmpd.conf to have the SNMP daemon listen on all interfaces instead of 127.0.0.1:
Comment out the line agentAddress udp:127.0.0.1:161.
Uncomment the line agentAddress udp:161,udp6:[::1]:161.
# Listen for connections from the local system only # agentAddress udp:127.0.0.1:161 # Listen for connections on all interfaces (both IPv4 *and* IPv6) agentAddress udp:161,udp6:[::1]:161
Add the following
viewline to the Access Control section of the file. This creates a view of the HAProxy Enterprise data from a part of the larger SNMP tree of data. The first six numbers 1,3,6,1,4,1, map to iso.org.dod.internet.private.enterprise. This is the same for every network device and never changes. The last number, 23263, is the OID that identifies the device manufacturer HAProxy Technologies.
view systemonly included .18.104.22.168.4.1.23263
Add the following
pass_persistline to the end of the file. It configures the SNMP daemon to pass requests through to the HAProxy Enterprise module:
pass_persist .22.214.171.124.4.1.232126.96.36.199.3 /opt/hapee-extras/bin/hapee-snmp-lb
Restart the SNMP service:
$ sudo systemctl restart snmpd
Configure your SNMP monitoring software to collect metrics from the HAProxy Enterprise server.
How it works
The SNMP stack is split into two main components:
The Operating system SNMP daemon, called
snmpd. It listens on a network interface on port 161/UDP and handles SNMP requests from clients.
The SNMP module for HAProxy Enterprise, which collects data from the load balancer for
The diagram below illustrates how the SNMP deamon monitors the system's network, system disks, and HAProxy Enterprise:
The counters are defined in the file /opt/hapee-extras/misc/HAPEE.mib.