check_mk Livestatus API for Nagios
January 15, 2021•205 words
Build the Livestatus api server
Install the build deps
Build deps Ubuntu 18.04:
- librrd-dev
- libboost-all-dev
Browse to https://checkmk.com/download/sources-download
Grab the latest "Stand-alone source code of MK Livestatus" link
wget https://download.checkmk.com/checkmk/1.5.0p25/mk-livestatus-1.5.0p25.tar.gz
Unpack it, configure it for Nagios4 support, build it
tar -xvzf mk-livestatus-1.5.0p25.tar.gz
cd mk-livestatus-1.5.0p25/
./configure --with-nagios4
make
Snag the built file from the src directory src/livestatus.o
Install the Livestatus api server
Install deps Ubuntu 18.04:
- libboost-system1.65.1
- check-mk-livestatus
- xinetd
Replace the original livestatus.o executable in /usr/lib/check_mk/
Define it as a Nagios broker module in nagios.cfg:
broker_module=/usr/lib/check_mk/livestatus.o /run/nagios/livestatus.sock
Restart nagios to ensure that Nagios can create the socket in the /run/nagios
path which should already exist if NRPE is running on the system.
Create the livestatus xinetd service
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 = /run/nagios/livestatus.sock
disable = no
# only_from = 127.0.0.1
}
Enable xinetd:
systemctl enable --now xinetd
Test the socket service locally to make sure that livestatus is working OK
echo 'GET contacts' | unixcat /run/nagios/livestatus.sock
address1;address2;address3;address4;address5;address6;alias;can_submit_commands;custom_variable_names;custom_variable_values;custom_variables;email;host_notification_period;host_notifications_enabled;in_host_notification_period;in_service_notification_period;modified_attributes;modified_attributes_list;name;pager;service_notification_period;service_notifications_enabled