These instructions are based on using the Debian distribution; some of the information might be different for another distribution.
Nagios is a popular open source computer system and network monitoring software application. It watches hosts and services, alerting users when things go wrong and again when they get better. Nagios allows you to monitor anything. All hosts and services are monitored through plug-ins which are simple shell-scripts and programs. plug-ins can written in any language. The language you choose needs the ability to print using stdout and return exit codes.
Learn more about Nagios by referring the other links at the bottom of this page.
- Linux (or UNIX variant)
- Configured network (Most of the monitoring plug-ins works over the network)
- When using CGIs you also need:
- A webserver (e.g. Apache HTTPD)
- gd library for "statusmap" and "trends" CGIs
There are many ways to install Nagios including using a package-manager or building from source. Datameer recommends building from source, because it's easier to understand how Nagios works and where the different files are stored.
If you don't want to build from source, read the next sub-section(s).
Install Nagios on Debian5 with apt
Words such as <address> or <port> are placeholders and needs to be replaced with your settings.
Install packages using the following command:
Configure Apache to allow access to the Nagios web interface:
Update permissions for Nagios and Apache:
Look at the Nagios UI:
Install Datameer Job Status plug-in
Create file /
If you need to change your configurations frequently, then refer to http://www.ubuntugeek.com/nagios-configuration-tools-web-frontends-or-gui.html.
/usr/lib/nagios/plug-ins/check_dasfile and paste the
check_dascode from Job Status plug-in section of this page.
Set execute permissions
This is the most useful command for nagios; job-history is more interesting for munin or nagiosgrapher, and job-details just returns the job-configuration details.
Refer to Nagios Configuration.
Adding a command
A command is a predefined configuration for a shell script which acts as a Nagios plug-in. It defines the name for that command and the parameters used. The values for the command parameters are placeholders, which are replaced later with the correct values. By default, you can find the Command-Configuration-File in
In this example, we define a
my_command. The name is used later to describe which command we want to use for monitoring a service. The
command_name doesn't need to be the same as the name of the program (it is only usee for identifying the command). Next, define the
command_line. This parameter tells Nagios how the program is used. Nagios supports macros which allows you to avoid editing the command every time you want to use an another parameter for that command. Macros are similar to variables which are replaced later with the correct values. In this example, $USER1$ contains the path to the Nagios plug-ins. Then, define the file name of the program and the parameters for that program. Replace the parameter values through macros called $ARGn$ (where n = order number). These argument-macros are replaced later (inside the service-definition) with correct values in the same order described in the command.
Further information about configuration.
Adding a service
A service definition is used to identify a service. The term "service" is used very loosely. It can mean an actual service that runs on the host (POP, SMTP, HTTP, etc.) or some other type of metric associated with the host (such as the response to a ping, number of logged in users, amount of free disk space, etc.). By default, you can find the Service-Configuration-File for the local machine in
In this example,
use specifies to use the Service-Template
local-service. It's a template containing settings used for all local services. Define
host_name to be the names of machines which runs or are associated with that service. The
service_description is a description displayed inside Nagios. The
check_command option runs the command
my_command with some parameters. Those parameters are separated with a "!" (exclamation mark). The service shown in this example uses three parameters (the three we defined in the command definition) for that command. In this case,
my_command!value_a!value_b!value_c executes (internally)
<path-to-plug-ins>/myprogram -a value_a -b value_b -c value_c
This plug-in monitors the status of a job from Datameer and requires php5-cli installed. It's getting the JSON value from REST-API through accessing
It writes a string to stdout which can be parsed by Nagios and returns an exit code which is used as the current status of the service you are monitoring.
Command line parameters:
Read buffer length for the JSON-Output, which contains the JobStatus information.
The job ConfigurationID from the job you want to monitor
Shows the Help for this script
The machine where the Datameer application has been installed
The port which Datameer uses
Shows the version of this script
You can execute each Nagios plug-in manually, they all return a standardized line, which might be useful for testing.
Monitor Job-ConfigurationID "0" from "127.0.0.1:8080"
/usr/lib/nagios/plug-ins/check_das -d 42
Monitor JobConfigurationID "42" from "127.0.0.1:8080"
/usr/lib/nagios/plug-ins/check_das -m mydomain.com -s 8043 -d 61
Monitor JobConfigurationID "61" from "mydomain.com:8043"
/usr/lib/nagios/plug-ins/check_das -m myusername:firstname.lastname@example.org -s 443 -d 89
Monitor JobConfigurationID "89" from "mydomain.com:443" with User "myusername" and Password "mypwd"
The parameters below
check_command are used to send the failure notification only one time.