Page 1 of 1

Basic NRDP + Nagios configuration

Posted: Tue Jul 24, 2018 6:45 am
by josepm
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.

Re: Basic NRDP + Nagios configuration

Posted: Tue Jul 24, 2018 7:18 am
by scottwilkerson
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;"
        }
    ]
}

Re: Basic NRDP + Nagios configuration

Posted: Wed Jul 25, 2018 8:12 am
by josepm
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!

Re: Basic NRDP + Nagios configuration

Posted: Wed Jul 25, 2018 8:57 am
by scottwilkerson
Excellent! Glad it is resolved!

Locking