Basic NRDP + Nagios configuration

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Basic NRDP + Nagios configuration

Postby josepm » Tue Jul 24, 2018 6:45 am

Hi,
I'm new using nagios.
I'm configuring a test nagios environment with NRDP.
I'm using an Ubuntu 18.04 machine, nagios 4.4.1, nagios plugins 2.2.1 and nrdp 1.5.1.
I followed several tutorials and everything seems to be up and running.
The issue I'm experiencing is that I'm not able to perform a simple
test check via http://[ip_from_my_nagios]/nrdp

I've defined this command:
Code: Select all
define command {
   command_name   check_dummy
   command_line   $USER1$/check_dummy $ARG1$
}


I've defined this host:

Code: Select all
define host {
   use         generic-host
   name         passive_host
   active_checks_enabled   0
   passive_checks_enabled   1
   flap_detection_enabled   0
   register      0
   check_period      24x7
   max_check_attempts   1
   check_interval      5
   retry_interval      1
   check_freshness      0
   contact_groups      admins
   check_command      check_dummy!0
   notification_interval   60
   notification_period   24x7
   notification_options   d,u,r
}

define service {
   use         generic-service
   name         passive_service
   active_checks_enabled   0
   passive_checks_enabled   1
   flap_detection_enabled   0
   register      0
   check_period      24x7
   max_check_attempts   1
   check_interval      5
   retry_interval      1
   check_freshness      0
   contact_groups      admins
   check_command      check_dummy!0
   notification_interval   60
   notification_period   24x7
   notification_options   w,u,c,r
}

define host {
   use      passive_host
   host_name   jmHost
}

define service {
   use         passive_service
   service_description   CPU usage
   host_name      jmHost
}

define service {
   use         passive_service
   service_description   Swap Usage
   host_name      jmHost
}

define service {
   use         passive_service
   service_description   Memory Usage
   host_name      jmHost
}

define service {
   use         passive_service
   service_description   Process Count
   host_name      jmHost
}

define service {
   use         passive_service
   service_description   foo
   host_name      jmHost
}




When I submit this json message (for test purpouses)
Code: Select all
{
    "checkresults": [
        {
            "host": {
                "hostname": "jmHost",
                "state": 0,
                "output": "Everything looks okay! | perfdata=1;"
            }
        },
        {
            "service": {
                "hostname": "jmHost",
                "servicename": "foo",
                "state": 1,
                "output": "WARNING: Danger Will Robinson! | perfdata=1;"
            }
        }
    ]
}


Nothing happend (I mean no changes appearing on the services o hosts section
on the main Nagios web page).

In the /usr/local/nagios/var/nagios.log file I see the following lines:

[1532421791] Auto-save of retention data completed successfully.
[1532424131] Error: Got host checkresult for '', but no such host can be found
[1532424131] Error: Got host checkresult for '', but no such host can be found



Additionally, if I subbmit the same json check form with a hostname that
doesn't exist (to force an error), for instance this one:
Code: Select all
{
    "checkresults": [
        {
            "host": {
                "hostname": "noExists",
                "state": 0,
                "output": "Everything looks okay! | perfdata=1;"
            }
        },
        {
            "service": {
                "hostname": "noExists",
                "servicename": "wrongService",
                "state": 1,
                "output": "WARNING: Danger Will Robinson! | perfdata=1;"
            }
        }
    ]
}


I'm obtaining the same message (on nagios.log file):

[1532431293] Error: Got host checkresult for '', but no such host can be found
[1532431293] Error: Got host checkresult for '', but no such host can be found


I've, also, observed that if I perfom a 'Submit Nagios Command' (on the NRDP web
interface). (DISABLE_HOST_NOTIFICATIONS;localhost) It work's fine and I get
this line on nagios.log:

[1532431440] EXTERNAL COMMAND: DISABLE_HOST_NOTIFICATIONS;localhost


So, I'm suspecting a missconfiguration from my part but I cant find
any clue to solve it.

Thanks in advance for your help.
----
Josep M. Vidal
josepm
 
Posts: 2
Joined: Tue Jul 24, 2018 4:50 am

Re: Basic NRDP + Nagios configuration

Postby scottwilkerson » Tue Jul 24, 2018 7:18 am

Try the following:

Code: Select all
{
    "checkresults": [
        {
            "checkresult": {
                "type": "host",
                "checktype": "1"
            },
            "hostname": "jmHost",
            "state": "0",
            "output": "Everything looks okay! | perfdata=1;"
        },
        {
            "checkresult": {
                "type": "service",
                "checktype": "1"
            },
            "hostname": "jmHost",
            "servicename": "foo",
            "state": "1",
            "output": "WARNING: Danger Will Robinson! | perfdata=1;"
        }
    ]
}
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11144
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Basic NRDP + Nagios configuration

Postby josepm » Wed Jul 25, 2018 8:12 am

Hi,
I found out what was wrong. So I post the solution if it helps other people.
I saw in the apache's error.log (/var/log/apache2/error.log) this line:

[php7:error] [pid 1239] [client 192.168.1.62:64134] PHP Fatal error: Uncaught Error: Call to undefined function simplexml_load_string() in /usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php:63\nStack trace:\n#0 /usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php(25): nagioscorepassivecheck_submit_check_data()\n#1 /usr/local/nrdp/server/includes/utils.inc.php(326): nagioscorepassivecheck_process_request('PROCESS_REQUEST', Array)\n#2 /usr/local/nrdp/server/index.php(83): do_callbacks('PROCESS_REQUEST', Array)\n#3 /usr/local/nrdp/server/index.php(54): route_request()\n#4 {main}\n thrown in /usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php on line 63, referer: http://192.168.1.67/nrdp/


A google search made me realize that the php xml module was missing on my system. So I installed it:

Code: Select all
sudo apt-get install php7.2-xml


Once rebooted services it works fine!

Important: Only works xml messages. Json messages doen't wok, but, by now, it fits to my needs.

Thanks for your help!
----
Josep M. Vidal
josepm
 
Posts: 2
Joined: Tue Jul 24, 2018 4:50 am

Re: Basic NRDP + Nagios configuration

Postby scottwilkerson » Wed Jul 25, 2018 8:57 am

Excellent! Glad it is resolved!

Locking
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11144
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests