Version 1

    This template reports on the status and parameters of HAProxy by reading the Unix socket using Perl when provided with the proxy name, service name (FRONTEND for frontend, BACKEND for backend, any name for server/listener) and the parameter to be monitored.

    Prerequisites: SSH and Perl installed on the target server with Net::HAProxy module.

    Credentials: Root user on the target server.

    Monitored Components

    Status, Bytes In, Bytes Out

    Each monitored component needs to have arguments in the following format:

    perl ${SCRIPT} proxy_name service_name parameter
    where parameter could be any of the field names listed under section "9.1. CSV format" of "HAProxy Configuration Manual".


    You might want to name the monitors in the format, pxname-svname-parameter, to make it readable and easily understandable.


    The existing components can be cloned using the "Manage Component Monitors (within Templates)" option in SAM settings to monitor additional parameters.


    You need to check if Net::HAProxy is present on the target server. You can verify by typing 'perl -MNet::HAProxy -e1' ,

    If the module isn't present, you can do the following:

    1. Enter into cpan prompt by typing perl -MCPAN -e shell

    2. Enter o conf urllist to view the repositories already present.

    3. You might want to optionally add these two repositories if they aren't in the list.

    1. o conf urllist push
    2. o conf urllist push


    You can then type 'install Net::HAProxy' in cpan prompt to install the module.

    Within the component script, you can modify,

    1. the value of the socket key in following line to match your socket,

    socket => '/var/run/haproxy/admin.sock',

    2. the hastats file where statistics are stored temporarily,

    my $file = '/root/Documents/hastats';

    3. the numerical value of the parameters that return strings (like status which returns 'UP', 'DOWN', 'OPEN' etc.) in the %stat hash variable.

    4. the description of the parameters in %field hash. This would come up in the message field of the monitor.

    Storing hastats output in a file on the filesystem is entirely optional. It was added to use the recently-read socket statistics ($update_threshold of 6 minutes) instead of reading the socket repeatedly for every component.

    You can eliminate the if-else structure in search_px module and retain just the "$data = $haproxy->stats;" line to get the statistics.

    NOTE: This template was NOT tested with HAProxy directly. It was tested with sample data obtained by reading the socket.

    You can modify the script in the template as you wish to suit your requirements.