Boosting check_haproxy monitoring plugin to ignore backend(s), add bytes in/out to performance data

Written by - 2 comments

Published on - last updated on December 8th 2021 - Listed in HAProxy Monitoring


The monitoring plugin check_haproxy (the one written in Perl by Stéphane Urbanovski) is a very important helper to monitor a dynamic and scalable (web-) infrastructure. I have been using HAProxy for at least 6 years and a couple dozen HAProxies run across multiple environments, architectures, customers, etc. HAProxy is not only very powerful, it also gives great live statistics. These statistics are read from check_haproxy.

Today I came across a "problem" when a backend, configured for a test environment only, reported the backend server down:

# /usr/lib/nagios/plugins/check_haproxy.pl -u "http://myhaproxy.example.com:8099/;csv"
HAPROXY CRITICAL - Active service 'testserver01' is DOWN on 'app-test-out' proxy ! | t=0.036252s;2;10;0; monitoring-out=0;;;0;0 bigdata-out=0;;;0;0 dks-out=0;;;0;0 icingaweb2-out=1;;;0;0 direct-https-out=0;;;0;0 direct-http-out=0;;;0;0 app-test-out=0;;;0;0

But for that test environment alerts are not really needed. What if the plugin could simply ignore some backends?

Well, that's what I just did: I added a -i/--ignore-backends parameter to ignore one or more backends (comma-separated list).

Additionally to this, the performance data output was adjusted to correctly interpret the maximum number of concurrent sessions on the backends and added bytes in/out to the performance data. The output of the plugin now looks like this:

 # ./check_haproxy.pl -u "http://inf-lbi01-p.nzzmg.local:8099/;csv" -i app-test-out
HAPROXY OK -  monitoring-out (Active: 2/2) icingaweb2-out (Active: 1/1 , Backup: 1/1) direct-https-out (Active: 2/2) indesign-out (Active: 16/16) direct-http-out (Active: 2/2) dks-out (Active: 1/1 , Backup: 1/1) bigdata-out (Active: 4/4) | t=0.038859s;2;10;0; sess_monitoring-out=0;;;0;200 bytes_in_monitoring-out=3296950B;;;0; bytes_out_monitoring-out=71611346B;;;0; sess_icingaweb2-out=0;;;0;200 bytes_in_icingaweb2-out=743271171B;;;0; bytes_out_icingaweb2-out=2325993950B;;;0; sess_direct-https-out=0;;;0;200 bytes_in_direct-https-out=2523470B;;;0; bytes_out_direct-https-out=14888444B;;;0; sess_direct-http-out=0;;;0;200 bytes_in_direct-http-out=434659463B;;;0; bytes_out_direct-http-out=2458654176B;;;0; sess_dks-out=0;;;0;200 bytes_in_dks-out=425243B;;;0; bytes_out_dks-out=44848551B;;;0; sess_bigdata-out=0;;;0;200 bytes_in_bigdata-out=7677834B;;;0; bytes_out_bigdata-out=278220925B;;;0;

Unfortunately I could not find an original repository for the original plugin by Stéphane to commit to the "upstream" code. For now this version of check_haproxy can be found on my check_haproxy repository on GitHub.

Update: Changes are available upstream

Updated August 14th 2020: The plugin's original author, Stéphane Urbanovski, created a public repository for check_haproxy. As he is the original author, I'm more than happy to contribute the changes to the original script and therefore "upstream". So please download check_haproxy.pl from the official repo on GitHub from now on.


Add a comment

Show form to leave a comment

Comments (newest first)

Claudio Kuenzler from Switzerland wrote on Dec 8th, 2021:

Thanks someone. I updated the link in the article.


someone from wrote on Dec 8th, 2021:

The linked "official repo" does not contain the haproxy check.
You may need to clarify the updated part of this post

cheers


RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder