Page 1 of 1

Error: Could not stat() command file '/usr/local/nagios/var/

Posted: Tue Nov 25, 2014 11:11 am
by mpleasant
I had my server up and running but had an issue with a VM host which caused some crashes. Now am having an issue with email notifications, and commands.

I am getting this whenever trying to execute something:

Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!
The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.

I have seen this could be due to permissions, among other things. Below is some info from my setup. Any help would be greatly appreciated.

[root@uhc-ng01 ~]# service nagios status
nagios (pid 1049) is running...

[root@uhc-ng01 ~]# ls -l /usr/local/nagios/var/rw
total 0
prw-rw----. 1 nagios nagcmd 0 Nov 25 10:51 nagios.cmd
srw-rw----. 1 nagios nagcmd 0 Nov 25 10:51 nagios.qh

[root@uhc-ng01 ~]# grep nag /etc/group
nagios:x:1000:nagios
nagcmd:x:1001:apache

Re: Error: Could not stat() command file '/usr/local/nagios/

Posted: Tue Nov 25, 2014 4:14 pm
by abrist
The nagios user should be a member of the nagcmd group:

Code: Select all

usermod -a -G nagcmd nagios

Re: Error: Could not stat() command file '/usr/local/nagios/

Posted: Tue Apr 21, 2015 3:25 pm
by mbalmaceda
I've the same problem than you... and when i insert this command "#usermod -a -G nagcmd nagios" (obviously after "#service nagios restart"), no changes take place. :oops: i was searching a lot of forums, and nobody can help me.

I'm trying to update mi httpd since the web page of nagios, because i need that when this service is turn off, send me a notification.

Please help me!!!

Re: Error: Could not stat() command file '/usr/local/nagios/

Posted: Tue Apr 21, 2015 3:31 pm
by jolson
Let's take a look at your users/groups:

Code: Select all

cat /etc/passwd
cat /etc/group
Does nagios.cmd exist, and is it a named pipe?

Code: Select all

ls -l /usr/local/nagios/var/rw/nagios.cmd
file /usr/local/nagios/var/rw/nagios.cmd
Feel free to PM me if any of the above is sensitive. Thanks!

Re: Error: Could not stat() command file '/usr/local/nagios/

Posted: Tue Apr 21, 2015 3:53 pm
by mbalmaceda
jolson wrote:Let's take a look at your users/groups:

Code: Select all

cat /etc/passwd
cat /etc/group
Does nagios.cmd exist, and is it a named pipe?

Code: Select all

ls -l /usr/local/nagios/var/rw/nagios.cmd
file /usr/local/nagios/var/rw/nagios.cmd
Ok, this was the output

Code: Select all

cat /etc/passwd
nagios:x:532:533::/home/nagios:/bin/bash

Code: Select all

cat /etc/group
nagios:x:533:
nagcmd:x:534:nagios,apache


And the others...

Code: Select all

ls -l /usr/local/nagios/var/rw/nagios.cmd
prw-rw----. 1 nagios nagcmd 0 abr 21 16:31 /usr/local/nagios/var/rw/nagios.cmd

Code: Select all

file /usr/local/nagios/var/rw/nagios.cmd
/usr/local/nagios/var/rw/nagios.cmd: fifo (named pipe)

Thanks for help!

Re: Error: Could not stat() command file '/usr/local/nagios/

Posted: Tue Apr 21, 2015 4:04 pm
by jolson
cat /etc/group
nagios:x:533:


It looks like the nagios user is not in the nagios group. Please add it with the following command:

Code: Select all

usermod -G nagios -a nagios
Then restart nagios and httpd:

Code: Select all

service nagios restart

Code: Select all

service httpd restart
Let's see if that helps. Thanks![/s]

Please ignore this post - I forgot for a moment that users are tied to their own groups via UID/GUID.

Re: Error: Could not stat() command file '/usr/local/nagios/

Posted: Tue Apr 21, 2015 4:21 pm
by jolson
Do you have selinux enabled by chance?

Code: Select all

sestatus