Monitis (M3) & Nagios – a very simple integration

Nagios Web Site

Nagios, a systems monitoring software

What’s Nagios? – Nagios is a rather simplistic monitoring software. And I like simple things. Nagios’ responsibility is not necessarily to draw nice graphs for your boss or collect data you may or may not need.

Nagios simply decides whether your system runs properly. And for this question there is a very explicit answer – a YES or a NO. Nagios will alert you if the answer is a NO.

In the following article I’m going to show how easy it is to integrate Nagios with Monitis.

M3 – a Universal monitoring framework for Monitis custom scripts

M3 (Monitis Monitor Manager) design and usage examples were outlined in this previous article – which I suggest reading before proceeding with this one.

I had a claim in the previous article that M3 is fairly versatile and not much longer after comitting M3 came the challenge – integrate M3 with Nagios.

OK, why hosted monitoring?

Yes, it’s a good question, if Nagios gives you the nice functionality, then why export this data to Monitis and start all over again?

Honestly, Monitis‘ hosted monitoring will give you much more than Nagios. In addition to the invaluable alerts, it’ll give your enterprise a much more comprehensive and centralized monitoring solution than Nagios.

Let me please ask you one simple quest -what’s monitoring your nagios server? – I’m sorry to hear it is a single point of failure. Please consider Monitis then.

Not only that by using cloud-based monitoring you can (and should) eliminate the need for another dedicated monitoring server in your business, Monitis, being a hosted service rather than a piece of software is much more tolerant to network or server failures. The headache of taking care for a rock solid monitoring solution is ours – we’ll do it for you – and we love it.

Slight code changes to M3 framework

M3 was designed to collect data counters from various applications using regular expressions and parse the desired data.

However, with Nagios, it is less about collecting “89MB” or “29 r/s”. With Nagios it’s more about deciding whether the desired check is OK or not. 2.0

For example, lets have a look at the infamous check_ssh plugins. It’ll simply check if SSH is reachable on a host – usually used to make sure a host is alive. Upon success we’ll have:

 SSH OK - OpenSSH_5.6 (protocol) 

And on failure:

 Connection refused 


 CRITICAL - Socket timeout after 10 seconds 

From our point of view, only if we had “SSH OK” then the test succeeded, upon any other case we consider the test as a failure.

In Monitis API we can define a boolean variable for checks. M3 reflects Monitis API, thus, if we’ll define a boolean check in M3 we’ll get a slightly different behavior than any other check (integer, string or float) – and this was the only code change required. In the next example we’ll delve into it.

Quick start

In the previous article about M3 I outlined how to use M3. This time the only change is that you have to use the config_nagios.xml sample file instead. I suggest having a look at config_nagios.xml as it might just be self-explanatory for many people.

First Nagios plugin: check_ssh

We’ve already shown what values check_ssh might return. Here comes an XML configuration snippet for M3 if you want to integrate check_ssh:

<monitor name="Nagios check_ssh">
	<exectemplate>/usr/lib/nagios/plugins/check_ssh monkey
	<metric name="SSH check">
		<uom>SSH Connectivity</uom>
		<regex>^SSH OK</regex>
What happens here is very simple. M3 will execute “/usr/lib/nagios/plugins/check_ssh monkey” and if the string returned contains “SSH OK”, we'll simply report this check to Monitis as a success. If there's no “SSH OK” in the string we'll declare it as a failure.

Simple, isn’t it?

Second Nagios plugin: check_load

In a previous article the integration of Nagios and Monitis was outlined, integrating the check_load plugin. M3 can do it just as well. The configuration for the check_load plugin would produce 3 counters that we will parse them all and send their data to Monitis: There is nothing special about this example, it’s a simple M3 capability.

<monitor name="Nagios check_load">
	<exectemplate>/usr/lib/nagios/plugins/check_load -w 0,0,0 -c 0,0,0
	<metric name="Load1">
		<uom>Processes in queue</uom>
	<metric name="Load5">
		<uom>Processes in queue</uom>
		<regex>load5=([0-9.]+);</regex> </metric>
	<metric name="Load15"> <type>integer</type>
		<uom>Processes in queue</uom>

However, it is recommended later to set your limits in Monitis and decide when and how to receive alerts. Setting your limits and alerts are described in this article.

More Nagios plugin examples

config_nagios.xml provide some more examples for integrating nagios plugins with Monitis, among them are check_mysql, check_procs, check_users and some others.
There’s no real need in my opinion to delve into them as they merely represent some more regular expressions that’ll parse some different output.

Monitis Systems Monitoring Platform

Liked it? Sign up for Monitis and try it now! Don’t forget to check (and follow) also monitis exchange – our github open source repository for some more surprises.