Nagios is a widely used monitoring software for systems and networks. It provides the flexibility to monitor anything on your systems or networks using a script or plugin. Known for having plugins and scripts available to monitor your needs, Nagios’ the interface and user friendliness leaves much to be desired. Plus you have to maintain and monitor another server to store and analyze the data provided through your Nagios plugins and scripts. And worst of all, if your Nagios server or network fail – you may not get an alert at all when you need them the most.
A hosted system monitor gathering your stats is a good way to ensure that alerts get to you, and having it have nice tools and interfaces is definitely a bonus. Monitis is a hosted systems and networks monitoring solution that offers a simple user interface, with powerful tools, and a distributed network to prevent any service failures blocking your alerts. It will free up your sysadmins from monitoring their monitoring servers, and will allow them to focus on the issues rather than looking for the issues.
But suppose you already rely on Nagios scripts and plugins. There is a simple way to utilize these already known and popular plugins and scripts with a simple wrapper script loading data to your Monitis account.
Monitis provides you with the ability to measure any metric you want through the Custom Monitor. I will demonstrate by creating a Custom Monitor that accepts data from the Load plugin of Nagios. The Load plugin for Nagios monitors the average load in 1 minute, 5 minute, and 15 minute increments and will alert on user-defined Warning and Critical levels for each of the 3 average load increments.
Create Monitis Custom Monitors
The first thing you need when sending data to Monitis is a Custom Monitor. The Custom Monitor is where you will store your information for analysis or alerting purposes. In order to quickly setup the Custom Monitor download this script: https://github.com/monitisexchange/Monitis-Linux-Scripts/blob/master/API/monitis_create_monitor.sh.
To use the above script, you will need your API Key and Secret Key available from your Monitis Account page. If you do not have a Monitis Account, you can get a free trial by going here.
Now we are set to create our Custom Monitor where we can load data from the Load plugin for Nagios. The Load plugin for Nagios monitors 3 results plus has a state value (OK, WARNING or CRITICAL). So the Custom Monitor that we need to create will monitor these same values, plus use a numeric state value for graphing. You can run the check_load plugin without the use of nagios to see its default values and expected parameters.
The -w sets the warning level of the avg load and the -c sets the critical level. You have three options for 1, 5, 15 minute intervals. So run the plugin with some values in -w and -c. In the output, you should notice that it gives you State, the load averages results, and then after the | is the performance data. Performance data is not present for every plugin.
We want to capture the load averages and state for our Custom Monitor. So we need to setup a Custom Monitor that has 5 columns – load1, load5, load15, state, and state_val. State_val is used for graphing the different states of OK, WARNING, or CRITICAL. Here is how to run monitis_create_monitor.sh:
$ ./monitis_create_monitor.sh -n "Load Monitor" -m loadMonitor -r "state:State:state:3;state_val:State Value:state:2;load1:Load 1 Min:load:2;load5:Load 5 Min:load:2;load15:Load 15 Min:load:2" -a API_KEY -s SECRET_KEY
The -n is the Name of the Custom Monitor, -m is the Tag of the Custom Monitor, -r is the ResultParams of the Custom Monitor, -a is your API Key, and -s is the Secret Key. Definitions for the ResultParams and other necessary Custom Monitor API requests, are available here: http://www.monitis.com/api/api.html#addCustomMonitor
Now you should be able to log into your Monitis account and go to Monitors -> Manage Monitors -> Custom Monitors and add your newly created monitor.
In front of you is your customizable systems monitoring Dashboard. You are able to place the monitors that are most important to you right in front of your face, not amongst a list of never-ending checks and monitors. You can have graphs and status checks mixed on the same Dashboard. The interface is intuitive and has many possibilities for server and network health analysis.
Create Nagios Wrapper Script to Send Data to Monitis
Since a Custom Monitor without any data is not all that interesting, we want to populate it with some data, from the Nagios plugin. The simplest way is to wrap the plugin script with a custom wrapper script. Here is an example for the check_load plugin: https://github.com/monitisexchange/Monitis-Linux-Scripts/blob/master/nagios/monitis_nagios_load_wrapper.sh
This script relies on the script found here to upload data to your Custom Monitor: https://github.com/monitisexchange/Monitis-Linux-Scripts/blob/master/API/monitis_add_data.sh
Using these two scripts, you are able to quickly upload data to your Custom Monitor.
Basically this script runs the plugin then parses through the data and sends the results off to your Custom Monitor. We are now able to call this script from the command-line and send output to Monitis Custom Monitor. Here is an example:
$ ./monitis_nagios_load_wrapper.sh -w 5,3,3 -c10,5,4 OK - load average: 0.88, 0.74, 0.65|load1=0.880;5.000;10.000;0; load5=0.740;3.000;5.000;0; load15=0.650;3.000;4.000;0;
As you notice, it outputs the same value as the original check_load plugin. We are now able to utilize this script to run without Nagios and send data to the Custom Monitor we created. This frees up the Nagios server we used to have for other services, such as that overloaded webserver, that you have been meaning to scale up for load balancing.
For checking load on a regular basis, we could set the wrapper up in a cronjob. Since we are also outputting the original output of the check_load plugin, we are able to place this script directly into Nagios and replace the check_load plugin. This would allow you to utilize both your internal monitoring server and your Monitis account during the transition from Nagios to Monitis, or as a second layer of monitoring.
Here is a sample output from a graph of the Custom Monitor we created. I put a nice load on the end there by doing a large bzip2 process, while copying files to a different filesystem. Much nicer than any graph displayed in Nagios.
Setting Up Alerts from Monitis:
OK, we have the data graphing, we all think the interface is beautiful, but we need to setup alerts. Relying on Nagios to alert you is not always the most comforting solution, if the alert is due to network failure or if the Nagios server is not functioning properly, the alert will never get to you.
Monitis has a distributed framework, which means a single failure on a monitoring server will not prevent you from receiving your alert. You get to leverage the benefits of this network for alerting from within your Custom Monitor. In the Dashboard, from your Custom Monitor we can go to Notification rules and setup a new notification:
Here you can setup alerts based on the numeric values we captured in the wrapper script. So we can have an alert on Load 1 Min > 10 or Load 5 Mins > 8. We can also setup an alert if the load is too low, i.e. you are not receiving requests on your web server that always runs at >1 in the 1 min average.
That’s it, you now have hosted monitoring utilizing the plugins you already know and trust, but with the added benefit of an easy to use interface, and a distributed network ensuring alert delivery.
The Monitis account is flexible, allowing for integration with many other systems.
Utilizing Nagios plugins and scripts is just one way to monitor your servers. It has many other tools and monitoring agents available. But most of all the easy to use interface allows system administrators to focus on using their tools rather than learning their tools. The distributed network that Monitis has built up around the tool, ensures that your alerts will get to you when you need them. Get started utilizing Monitis: https://www.monitis.com/sign-up.