brunozrk brunozrk - 1 month ago 16
Python Question

Nagios + MK Livestatus + port

I have already installed nagios and mk live status, nagios is working correctly and Im trying test mklive status with this command:

nc -v 127.0.0.1 6557 < nagios_query_file


nagios_query_file has that content:

GET hosts
Filter: name ~~ root
Filter: state = 0
OutputFormat: python


the output is:

nc: connect to 127.0.0.1 port 6557 (tcp) failed: Connection refused


What should I do?

Answer

It seems that your port is not opened. Just make sure you have configured Livestatus on xinetd.

  • Install xinetd
  • Create /etc/xinetd.d/livestatus with something like:

_

service livestatus
{
        type            = UNLISTED
        port            = 6557
        socket_type     = stream
        protocol        = tcp
        wait            = no
        cps             = 100 3
        instances       = 500
        per_source      = 250
        flags           = NODELAY
        user            = nagios
        server          = /usr/bin/unixcat
        server_args     = /var/lib/nagios/rw/live
#       only_from       = 127.0.0.1 192.168.0.0
        disable         = no
}

See Remote access to Livestatus via SSH or xinetd for a detailed example

  • Restart xinetd service

Then your example should work.

But that's only if you want to open your livestatus socket through the network (to have on one interface the results of several distributed nagios cores, for instance).

If you just want to test it locally, try with:

echo "GET hosts" | unixcat /var/lib/nagios/rw/live

where /var/lib/nagios/rw/live isyour livestatus socket

Comments