2
Dec/09
5

MKLivestatus and NagVis making the NDO needless

Nagios LogoMKLivestatus is a brand new Nagios Event Broker (NEB) Module which can be used to extend the core of Nagios. The MKLivestatus module provides access to the live status information kept in the running Nagios process. It serves a unix socket for data exchange with external scripts/addons.

NagVis is the first Nagios addon which makes use of the new livestatus module. The MKLivestatus backend has been introduced to NagVis in version 1.4.5. Comparing to the NDO it will give you a big performance boost switching from NDO to Livestatus.

Read more about the new MKLivestatus module and the NagVis integration…

General description of MKLivestatus

The main advantage of the Livestatus module compared to all existing NEB modules, like the NDO (Nagios Data Out), is that it provides direct access to the status information in the Nagios core without storing any information in a database or file.

<

p>It is extremely fast to get the live status information since it only uses CPU time to gather the requested status information. The MKLivestatus module is directly loaded into the Nagios Core and can access all status data directly from the memory of the Nagios process so there are no memory operations needed. There is no disk IO or memory processing at all.

The Livestatus module has been created by Mathias Kettner, the developer of check_mk.

Livestatus only handles live status information (atm)

At the moment the focus of the MKLivestatus module is to serve current status information. It does not handle historic information at all. Maybe this would be a nice feature for the future to have just one simple layer for accessing Nagios information.

MKLivestatus behind the scenes (Technical details)

The MKLivestatus module can handle multiple requests at the same time since it is multithreaded. Using pstree -a | grep nagios you will recognize several child threads in you Nagios process. Ten of those thread were created by the MKLivestatus module by default. For changing the number of threads you need to change an option in the code and recompile the module.

Since the Livestatus module does not need to progress any information to an external storage it is not blocking the Nagios process. It only reads the data from the Nagios core process. Fetching information from the Livestatus module can not block the scheduling of the Nagios process. This is one of the main advantages compared to the NDO.

It is possible to add the MKLivestatus module to your running Nagios installation for testing purposes while keeping the NDO up and running. Simply add a second broker_module line to your nagios.cfg.

The livestatus unix socket can be queried using a special query language called LQL (Livestatus Query Language). The language is explained in the official documentation in detail.

The default format of the Livestatus responses is CSV. The delimiters can easily be modified using special parameters in the request query. The second output format is JSON. The NagVis backend makes use of the JSON format, it easily be parsed using the PHP function json_decode().

First steps has been made to support sending external commands to Nagios. This feature is meant to replace the Nagios Command file (nagios.cmd). It is still experimental but works as designed.

Accessing MKLivestatus from remote

Since the current version of the Livestatus module only serves a unix socket it is not possible to connect to the livestatus module from remote out of the box. But this does not mean it is not possible.

It is easy to make the unix socket available using xinetd. The official documentation of MKLivestatus shows how to configure the xinetd to map the unix socket to a tcp port.

Remote access via tcp can also be served using netcat, ssh or other techniques, depending on your requirements.

Livestatus vs. NagVis

My first contact with the livestatus module was on the OSMC 2009 in Nuernberg / Germany. Mathias gave me a short demonstration of the possibilities and power of the Livestatus module. He also provided a first backend for NagVis. After the talk it was clear that we will add the and deliver the MKLivestatus backend in future NagVis releases.

We worked with the NagVis 1.5 code which is in early developement at the moment. Recognizing the big advantages of the MKLivestatus module we decided to backport the module to make it compatible with NagVis 1.4. The work was worth it. We were not able to backport the whole performance gain we can get in NagVis 1.5 but using the livestatus module is still a benefit compared to the NDO.

The NagVis MKLivestatus backend can be configured to access local unix sockets or tcp sockets. So it is possible to visualize information from the local Nagios and/or even a remote Nagios instance.

The NagVis livestatus backend is included in the latest release NagVis 1.4.5 which has been released on last Friday together with the first stable release of MKLivestatus.

Summary

The MKLivestatus module is a stable and extremely fast way of providing Nagios status information to Nagios addons and scripts. Moving from NDO to MKLivestatus for serving live status information will result in a big performance gain on most Nagios installations.

When you used the NDO just for storing the current status information for NagVis I strongly recommend to update your NagVis installation to the current 1.4.x release (At least 1.4.5) and replace the the NDO with MKLivestatus module. When using the MKLivestatus Backend in NagVis you don’t need the NDO anymore so you can a) Remove the ndomod.o eventbroker module from your nagios.cfg, stop and remove your ndo2db daemon and drop the NDO database.

Links

Filed under: Nagios