brunozrk brunozrk - 4 days ago 4x
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 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 port 6557 (tcp) failed: Connection refused

What should I do?


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       =
        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