Library

Docs
Beta

Projects

NRDP - Using the send_nrdp Client

Overview

This KB article explains the send_nrdp NRDP clients that are available and how to use them. In the current release of NRDP the following client scripts are available:

The following topics are also discussed:

Requirements

To use the NRDP client you require the following:

  • NRDP URL

    • This is the address that the NRDP server can be contacted on, for example:

    • http://10.25.5.2/nrdp

  • NRDP Token

    • The token is the authentication method to connect to the NRDP server, it's like a password, for example:

    • XXXXX

send_nrdp.php

This client is a PHP script, which means that the PHP language needs to be installed on the machine you are executing it on.

Usage

./send_nrdp.php --url=<url> --token=<token> --host=<hostname> [--service=<servicename>] --state=<state> --output=<output> [--usestdin] [--delim=\t]

   <url>         = The URL used to access the remote NRDP agent.
   <token>       = The secret token used to access the remote NRDP agent.
   <hostname>    = The name of the host associated with the passive host/service check result.
   <servicename> = For service checks, the name of the service associated with the passive check result.
   <state>       = An integer indicating the current state of the host or service.
   <output>      = Text output to be sent as the passive check result. Newlines should be encoded with encoded newlines (\n).
   <usestdin>    = Accept check result data from STDIN instead of --host,--service,--state,--output flags
                   Each line contains a check result in the format of:
                   host[DELIM]state[DELIM]output[DELIM]
                   or
                   host[DELIM]service[DELIM]state[DELIM]output[DELIM]
   <delim>       = The delimeter (DELIM above) to use when processing from STDIN. The default is \t (TAB)

Send a passive host or service check result to a remote Nagios instance using the NRDP agent.

Host example with an UP state:

./send_nrdp.php --url=http://10.25.5.2/nrdp --token=XXXXX --host=centos01 --state=0 --output="The host is up and OK"

Service example with a WARNING state:

./send_nrdp.php --url=http://10.25.5.2/nrdp --token=XXXXX --host=centos01 --service="Disk Usage" --state=1 --output="WARNING: The disk is 75% full"

send_nrdp.py

This client is a Python script, which means that the Python language needs to be installed on the machine you are executing it on.

Usage

./send_nrdp.py --help
usage: send_nrdp.py [-h] [-u URL] [-t TOKEN] [-H HOSTNAME] [-s SERVICE]
                    [-S STATE] [-o OUTPUT] [-f FILE] [-d DELIM] [-c CHECKTYPE]

optional arguments:
  -h, --help            show this help message and exit
  -u URL, --url URL      REQUIRED  The URL used to access the remote NRDP agent.
  -t TOKEN, --token TOKEN
                         REQUIRED  The authentication token used to access the
                        remote NRDP agent.
  -H HOSTNAME, --hostname HOSTNAME
                        The name of the host associated with the passive host/service
                        check result.
  -s SERVICE, --service SERVICE
                        For service checks, the name of the service associated with the
                        passive check result.
  -S STATE, --state STATE
                        An integer indicating the current state of the host or service.
  -o OUTPUT, --output OUTPUT
                        Text output to be sent as the passive check result.
                        Newlines should be encoded with encoded newlines (\n).
  -f FILE, --file FILE  This file will be sent to the NRDP server specified in -u
                        The file should be an XML file in the following format:
                        ##################################################
                        <?xml version='1.0'?>
                        <checkresults>
                          <checkresult type="host" checktype="1">
                            <hostname>YOUR_HOSTNAME</hostname>
                            <state>0</state>
                            <output>OK|perfdata=1.00;5;10;0</output>
                          </checkresult>
                          <checkresult type="service" checktype="1">
                            <hostname>YOUR_HOSTNAME</hostname>
                            <servicename>YOUR_SERVICENAME</servicename>
                            <state>0</state>
                            <output>OK|perfdata=1.00;5;10;0</output>
                          </checkresult>
                        </checkresults>
                        ##################################################
  -d DELIM, --delim DELIM
                        With only the required parameters send_nrdp.py is capable of
                        processing data piped to it either from a file or other process.
                        By default, we use t (\t) as the delimiter however this may be
                        specified with the -d option data should be in the following
                        formats of one entry per line:
                        printf "<hostname>\t<state>\t<output>\n"
                        printf "<hostname>\t<service>\t<state>\t<output>\n"
  -c CHECKTYPE, --checktype CHECKTYPE
                        1 for passive 0 for active

Host example with an UP state:

./send_nrdp.py -u http://10.25.5.2/nrdp/ -t XXXXX -H centos01 -S 0 -o "The host is up and OK"

Service example with a WARNING state:

./send_nrdp.py -u http://10.25.5.2/nrdp/ -t XXXXX -H centos01 -s "Disk Usage" -S 1 -o "WARNING: The disk is 75% full"

With the Python script it is important that the URL ends with a /

send_nrdp.sh

This client is a shell script, which means that the shell language needs to be installed on the machine you are executing it on.

Usage

./send_nrdp.sh -h

send_nrdp.sh Revision 0.6.1 - Send NRDP script for Nagios

Usage: send_nrdp.sh -u URL -t token [options]

Usage: send_nrdp.sh -h display help


This script is used to send NRDP data to a Nagios server

Required:
    -u,    URL of NRDP server.  Usually http://<IP_ADDRESS>/nrdp/
    -t,    Shared token.  Must be the same token set in NRDP Server

Options:
    Single Check:
        -H    host name
        -s    service name
        -S    State
        -o     output

    STDIN:
        [-d    delimiter] (default -d "\t")
        With only the required parameters send_nrdp.sh is capable of
        processing data piped to it either from a file or other
        process.  By default, we use \t as the delimiter however this
        may be specified with the -d option data should be in the
        following formats one entry per line.
        For Host checks:
        hostname    State    output
        For Service checks
        hostname    servicename    State    output

    File:
        -f /full/path/to/file
        This file will be sent to the NRDP server specified in -u
        The file should be an XML file in the following format
        ##################################################

        <?xml version='1.0'?>
        <checkresults>
          <checkresult type="host" checktype="1">
            <hostname>YOUR_HOSTNAME</hostname>
            <state>0</state>
            <output>OK|perfdata=1.00;5;10;0</output>
          </checkresult>
          <checkresult type="service" checktype="1">
            <hostname>YOUR_HOSTNAME</hostname>
            <servicename>YOUR_SERVICENAME</servicename>
            <state>0</state>
            <output>OK|perfdata=1.00;5;10;0</output>
          </checkresult>
        </checkresults>
        ##################################################

    Directory:
        -D /path/to/temp/dir
        This is a directory that contains XML files in the format
        above.  Additionally, if the -d flag is specified, send_nrdp.sh
        will create temp files here if the server could not be reached.
        On additional calls with the same -D path, if a connection to
        the server is successful, all temp files will be sent.

Host example with an UP state:

./send_nrdp.sh -u http://10.25.5.2/nrdp/ -t XXXXX -H centos01 -S 0 -o "The host is up and OK"

Service example with a WARNING state:

./send_nrdp.sh -u http://10.25.5.2/nrdp/ -t XXXXX -H centos01 -s "Disk Usage" -S 1 -o "WARNING: The disk is 75% full"

These commands will produce output like:

Sent 1 checks to http://10.25.5.2/nrdp/

Using STDIN

The scripts are capable of using the standard input (STDIN), commonly done by piping a correctly formatted text string to the send_nrdp client.

By default, \t (tab) is the delimiter. The string should be in the following formats.

Host Checks:

hostname    State    output

Service Checks:

hostname    servicename    State    output

The printf command allows you to generate that format. In addition, it is good practice to add a new line \n to the end of the string.

A Host Check:

printf "centos01\t0\tThe host is up and OK\n"

A Service Check:

printf "centos01\tDisk Usage\t1\tWARNING: The disk is 75%% full\n"

It's also important to note that I needed to use a %% twice so that it is escaped, otherwise it would generate WARNING: The disk is 75 0.000000ull due to how printf works.

Now that you have the format, piping the text string to the send_nrdp client is done like so.

send_nrdp.php

printf "centos01\t0\tThe host is up and OK\n" | ./send_nrdp.py -u http://10.25.5.2/nrdp/ -t XXXXX

send_nrdp.py

printf "centos01\t0\tThe host is up and OK\n" | ./send_nrdp.php --url=http://10.25.5.2/nrdp --token=XXXXX --usestdin

send_nrdp.sh

printf "centos01\t0\tThe host is up and OK\n" | ./send_nrdp.sh -u http://10.25.5.2/nrdp/ -t XXXXX

This command will produce output like:

Sent 1 checks to http://10.25.5.2/nrdp/

Multiple checks can be sent in the one text string:

printf "centos01\t0\tThe host is up and OK\ncentos01\tDisk Usage\t1\tWARNING: The disk is 75%% full\n" | ./send_nrdp.sh -u http://10.25.5.2/nrdp/ -t XXXXX

This command will produce output like:

Sent 2 checks to http://10.25.5.2/nrdp/

Using An XML File

The send_nrdp.sh script is capable of using an XML formatted file. Here is an example of an XML file with a host check result:

<?xml version='1.0'?>
<checkresults>
  <checkresult type="host" checktype="1">
    <hostname>centos01</hostname>
    <state>0</state>
    <output>The host is up and OK</output>
  </checkresult>
</checkresults>

Multiple check results can be included in an XML file. Here is an example of an XML file with a host AND service check result:

<?xml version='1.0'?>
<checkresults>
  <checkresult type="host" checktype="1">
    <hostname>centos01</hostname>
    <state>0</state>
    <output>The host is up and OK</output>
  </checkresult>
  <checkresult type="service" checktype="1">
    <hostname>centos01</hostname>
    <servicename>Disk Usage</servicename>
    <state>1</state>
    <output>WARNING: The disk is 75% full</output>
  </checkresult>
</checkresults>

Now that you have the format, using the send_nrdp client with the file is done like so.

send_nrdp.php

The send_nrdp.php script does not currently support check results from an XML file.

send_nrdp.py

./send_nrdp.py -u http://10.25.5.150/nrdp/ -t XXXXX -f /tmp/nrdp.xml

send_nrdp.sh

./send_nrdp.sh -u http://10.25.5.2/nrdp/ -t XXXXX -f /tmp/nrdp.xml

Multiple check results can be included in an XML file. Here is an example of an XML file with a host AND service check result:

<?xml version='1.0'?>
<checkresults>
  <checkresult type="host" checktype="1">
    <hostname>centos01</hostname>
    <state>0</state>
    <output>The host is up and OK</output>
  </checkresult>
  <checkresult type="service" checktype="1">
    <hostname>centos01</hostname>
    <servicename>Disk Usage</servicename>
    <state>1</state>
    <output>WARNING: The disk is 75% full</output>
  </checkresult>
</checkresults>

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/

Nagios Enterprises, LLC

© All rights reserved. 2026