Nagiosmodule for HAProxy Health monitoring

This is just a quick hack, and it could certainly be better. I.E. it could get the list af active backends automaticly, and this assumes that you only have one websites with these backends in.

I plan a projekt where im going to upgrade til Icinga … and if i do that i might rewrite all my homemade plugins and publish them on Github, but for now this is it:

    $backends[] = "app01-40";
    $backends[] = "app01-50";
    $backends[] = "app02-51";
    $backends[] = "app02-41";


    foreach ($backends as $backend)
        if (preg_match("/UP/",exec("haproxyctl show health | grep $backend")))
        } else {
    $percentage = (count($up)/count($backends)*100);

    $msg = "Operating backends percentage: ".$percentage."%  |  active_backends=".count($up)."\n";

    if ($percentage != 100)
        print "WARNING: $msg";
        print "OK: $msg";

I ran it though NRPE and i had to give my NRPE user access to “/var/run/haproxy/admin.sock”.

Dette indlæg blev udgivet i Knowledge Base, Monitoring, Nagios, Networking, Old Base. Bogmærk permalinket.

Skriv et svar