External command to nagios.cmd not working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Pradeeps
Posts: 38
Joined: Thu Dec 22, 2016 11:05 am

External command to nagios.cmd not working

Post 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
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: External command to nagios.cmd not working

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Pradeeps
Posts: 38
Joined: Thu Dec 22, 2016 11:05 am

Re: External command to nagios.cmd not working

Post 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 3066 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: External command to nagios.cmd not working

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Pradeeps
Posts: 38
Joined: Thu Dec 22, 2016 11:05 am

Re: External command to nagios.cmd not working

Post 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!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: External command to nagios.cmd not working

Post by scottwilkerson »

Glad it is resolved!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked