How to monitor an Aspera Node with Nagios

How to monitor an Aspera Node with Nagios

The goal of this article is to describe how to put in place a custom plug-in for Nagios in order to monitor the Aspera Node web service running on a host.

Features

The custom plug-in connects to the Aspera Node web service on a specific host, and then determines if the service is up by sending a simple ping request (using the Web API), and by checking if a valid response is received from that host.

Checklist

This plug-in uses the curl command and this one must therefore be correctly installed on your system for this plug-in to work.

Useful links

Nagios plug-in development guidelines

Aspera Developer Network (subscription required)

Let's get started!

Create the script for the plug-in

Create a file named check_aspera_node in the folder where nagios keeps its plug-ins.

Some typical locations:

  • Linux: /usr/lib/nagios/plugins/
  • FreeBSD: /usr/local/libexec/nagios/

Edit the file and copy/paste this content into it:

#!/bin/sh
result=`/usr/local/bin/curl -s -m 3 -i -k -X GET https://$1:9092/ping | /usr/bin/awk '/HTTP\/1.1 200 OK/ {print $0}' | /usr/bin/tr -d "\n\r\t"`
if [ "$result" = "HTTP/1.1 200 OK" ]
then
echo $result
return 0
else
echo "Failure $result"
return 2
fi

Make sure you save the content of the file before exiting the text editor.

Please note that you may have to adapt this script in order to have it reflect the actual locations of the sh, curl, awk and tr commands on your system.

Make that file executable:

# chmod +x check_aspera_node
# ls -l check_aspera_node
-rwxr-xr-x 1 root wheel 266 Nov 12 15:38 check_aspera_node

Modify the Nagios configuration files to let it use this new plug-in

Some typical locations where Nagios keeps its configuration files:

  • Linux: /etc/nagios-plugins/config/
  • FreeBSD: /usr/local/etc/nagios/

Create this entry in the command section:

# Aspera plug-ins
define command{
    command_name check_aspera_node
    command_line $USER1$/check_aspera_node $HOSTADDRESS$
}

Then define a service for one of your hosts:

define service{
    use local-service
    host_name hostname
    service_description ASPERA_NODE
    check_command check_aspera_node
    notifications_enabled 0
}

Replace the hostname value by any hostname value valid in your Nagios environment.

When you are done editing the configuration files, make sure you save them, and then verify the Nagios configuration using this command:

# nagios -v nagios.cfg

Nagios Core 3.3.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 07-25-2011
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/etc/nagios/objects/commands.cfg'...
Processing object config file '/usr/local/etc/nagios/objects/contacts.cfg'...
Processing object config file '/usr/local/etc/nagios/objects/timeperiods.cfg'...
Processing object config file '/usr/local/etc/nagios/objects/templates.cfg'...
Processing object config file '/usr/local/etc/nagios/objects/localhost.cfg'...
Processing object config file '/usr/local/etc/nagios/objects/servers.cfg'...
Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Checked 11 services.
Checking hosts...
Checked 2 hosts.
Checking host groups...
Checked 2 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 25 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

Make sure you get no error (if there is none, then you should get something like the lines in bold).

Restart the Nagios daemon.

After a while, you should observe something like this in Nagios:

screen_shot_nagios.png

In that case, there are two instances of the plug-in configured for the hosts "localhost" and "windows-2k8" . 

Host "localhost" does not run the Aspera Node Web service and therefore the plug-in reports a CRITICAL status.

Host "windows-2k8" does run the service on its side, and the plug-in reports the OK status accordingly.

1 Comments

  • Avatar
    Milton Barell

    I had trouble getting the return value on exit so I put it in a function and that fixed it.

     

    #!/bin/sh

    result=`/usr/bin/curl -s -m 3 -i -k -X GET https://$1:9092/ping | /usr/bin/awk '/HTTP\/1.1 200 OK/ {print $0}' | /usr/bin/tr -d "\n\r\t"`

    aspera(){

    if [ "$result" = "HTTP/1.1 200 OK" ]

    then

    echo OK: $result

    return 0

    else

    echo "Failure: $result"

    return 1

    fi

    }

    aspera

    Edited by Milton Barell
Article is closed for comments.
Powered by Zendesk