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

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
mpleasant
Posts: 1
Joined: Tue Nov 25, 2014 10:38 am

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

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post by abrist »

The nagios user should be a member of the nagcmd group:

Code: Select all

usermod -a -G nagcmd nagios
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mbalmaceda
Posts: 2
Joined: Tue Apr 21, 2015 3:16 pm

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

Post 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!!!
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

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

Post 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!
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
mbalmaceda
Posts: 2
Joined: Tue Apr 21, 2015 3:16 pm

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

Post 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!
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

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

Post 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.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

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

Post by jolson »

Do you have selinux enabled by chance?

Code: Select all

sestatus
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
Locked