Page 1 of 1

External command to nagios.cmd not working

Posted: Sun Jan 27, 2019 1:38 pm
by Pradeeps
Hello Folks,

I have installed Nagios core version 4.2.4 and running nagiosql version 3.4.0.

I have configured hosts with active checks and see them working fine. However for the passive (snmp trap) i see the trap goes into eventhandler (submit_check_ then to the nagios.cmd however, I dont see any change in the service status. I tried manually but no luck. Any idea what could be causing this?

Code: Select all

[code]echo "[`date +%s`] PROCESS_SERVICE_CHECK_RESULT;<IP>;AU_COMM_LOST-Trap;2;"Critical""  >> /usr/local/nagios/var/rw/nagios.cmd
[/code]

Code: Select all

drwxrwsr-x 2 nagios nagcmd   50 Jan 27 18:21 rw

Code: Select all

[root@nagios-core-4 rw]# ls -lh
total 512K
srw-rw---- 1 nagios nagcmd    0 Jan 27 18:21 live
-rw-rw-r-- 1 root   nagcmd 322K Jan 27 18:37 nagios.cmd
srw-rw---- 1 nagios nagcmd    0 Jan 27 18:21 nagios.qh

Re: External command to nagios.cmd not working

Posted: Mon Jan 28, 2019 4:03 pm
by cdienger
Do you see anything in nagios.log when these events come in? It sounds like a passive service hasn't been configured and it will say as much in this log if this is the case. See https://assets.nagios.com/downloads/nag ... hecks.html.

Re: External command to nagios.cmd not working

Posted: Tue Jan 29, 2019 1:29 pm
by Pradeeps
I don't see any error in nagios.log. I see the trap being handled and send the "PROCESS_SERVICE_CHECK_RESULT" to nagios.cmd properly. However its not being processed. Also I noticed nagios creates zombie/defunct process whenever any command being written to nagios.cmd file externally. Not sure where to check for this.

Code: Select all

tail -f /usr/local/nagios/var/rw/nagios.cmd | grep <IP>
[1548785926] PROCESS_SERVICE_CHECK_RESULT;<IP>;Cell_Blocked-Cell_1;2;
Here is the configured service status which is still in Pending state
Capture.JPG
Capture.JPG (9.59 KiB) Viewed 4078 times

Re: External command to nagios.cmd not working

Posted: Tue Jan 29, 2019 5:34 pm
by scottwilkerson
/usr/local/nagios/var/rw/nagios.cmd is supposed to be a pipe but you have somehow written an actual file..

Run the following to remove the file and re-create the command pipe

Code: Select all

service nagios stop
rm -f /usr/local/nagios/var/rw/nagios.cmd
service nagios start
Now you would run the command like the following

Code: Select all

/bin/printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;host1;service1;0;OK- Everything Looks Great\n" `date +%s` > /usr/local/nagios/var/rw/nagios.cmd

https://assets.nagios.com/downloads/nag ... and_id=114

Re: External command to nagios.cmd not working

Posted: Thu Jan 31, 2019 9:22 am
by Pradeeps
I found the issue. The "nagios.cmd" file was not created a "pipe" file rather a regular one. This is due to my eventhandler script which keep writing file to nagios.cmd.

Here is what i did to fix incase anyone is interested.

Code: Select all

systemctl stop snmptrapd
systemctl stop snmptt
rm -f nagios.cmd
systemctl restart nagios
Wait for nagios.cmd to create itself as a pipe file
Then start snmptrapd and snmptt (make sure the event handler script is just appending (>>) command to nagios.cmd )

Thanks for your ideas. Much appreciated!

Re: External command to nagios.cmd not working

Posted: Thu Jan 31, 2019 9:49 am
by scottwilkerson
Glad it is resolved!

Locking thread