z

Commercial Support Clients: Clients with support contracts can get escalated support assistance by visiting Nagios Answer Hub. These forums are for community support services. Although we at Nagios try our best to help out on the forums here, we always give priority support to our support clients.

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.

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

Postby paul.tyler1 » Wed Jun 11, 2014 7:48 pm

Hello,

I am having the same error as in this post, but following the steps people have posted I am still not able to resolve the error and enable notifications for a service or make notes.

Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!
The permissions on the external command file and/or directory may be incorrect. Read the FAQs on how to setup proper permissions.
An error occurred while attempting to commit your command for processing.

Here is some of my system information, please advise what I can do next:

Linux i-2743-8087-VM 2.6.18-348.el5 #1 SMP Tue Jan 8 17:53:53 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

[root@i-2743-8087-VM tmp]# getenforce
Enforcing
[root@i-2743-8087-VM tmp]# setenforce 0
[root@i-2743-8087-VM tmp]# service nagios restart
Running configuration check...Stopping nagios: .done.
Starting nagios: done.
[root@i-2743-8087-VM tmp]# ps -auxww | grep nagios
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
nagios 4053 0.0 0.0 16112 1384 ? Ss 09:37 0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
nagios 4054 0.0 0.0 9628 784 ? S 09:37 0:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 4055 0.0 0.0 9628 784 ? S 09:37 0:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 4056 0.0 0.0 9628 784 ? S 09:37 0:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 4057 0.0 0.0 9112 700 ? S 09:37 0:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 4059 0.0 0.0 15468 668 ? S 09:37 0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root 4073 0.0 0.0 61216 768 pts/1 S+ 09:39 0:00 grep nagios
[root@i-2743-8087-VM tmp]# ps -auxww | grep httpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
apache 3570 0.0 0.2 236108 9596 ? S 09:08 0:00 /usr/sbin/httpd
apache 3686 0.0 0.2 236108 9600 ? S 09:19 0:00 /usr/sbin/httpd
root 4077 0.0 0.0 61216 764 pts/1 S+ 09:39 0:00 grep httpd
root 9428 0.0 0.3 235916 15668 ? Ss May28 0:00 /usr/sbin/httpd
apache 11301 0.0 0.2 236244 10396 ? S Jun08 0:00 /usr/sbin/httpd
apache 27779 0.0 0.3 237020 12576 ? S Jun08 0:00 /usr/sbin/httpd
apache 27781 0.0 0.2 236908 11888 ? S Jun08 0:00 /usr/sbin/httpd
apache 27782 0.0 0.2 236108 9656 ? S Jun08 0:00 /usr/sbin/httpd
apache 27783 0.0 0.2 236392 11496 ? S Jun08 0:00 /usr/sbin/httpd
apache 27784 0.0 0.2 236108 9648 ? S Jun08 0:00 /usr/sbin/httpd
apache 27786 0.0 0.2 236256 10408 ? S Jun08 0:00 /usr/sbin/httpd
apache 27787 0.0 0.2 236248 10404 ? S Jun08 0:00 /usr/sbin/httpd
apache 27788 0.0 0.2 237000 12028 ? S Jun08 0:00 /usr/sbin/httpd

Thank you in advance!
Paul
Interested in Monitoring directories, files and services
paul.tyler1
 
Posts: 5
Joined: Wed Jun 11, 2014 7:11 pm

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

Postby Stuart Watts » Thu Jun 12, 2014 7:34 am

What are the permissions on nagios.cmd, and the directories it sits in?
Code: Select all
ls -l /usr/local/nagios/var/rw/nagios.cmd
ls -ld /usr/local/nagios/var/rw
ls -ld /usr/local/nagios/var
ls -ld /usr/local/nagios
ls -ld /usr/local
Stuart Watts
 
Posts: 40
Joined: Wed Sep 25, 2013 7:01 am

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

Postby Box293 » Thu Jun 12, 2014 4:14 pm

I found this blog fixed the same problem (after trying lots of other similar sites).

http://linux.101hacks.com/unix/nagios-cmd-file-error/

I assume the group nagcmd already exists, so do the following:

Code: Select all
usermod -G nagcmd nagios
usermod -G nagcmd apache
chown nagios:nagcmd /usr/local/nagios/var/rw
chown nagios:nagcmd /usr/local/nagios/var/rw/nagios.cmd


Finally, restart the Apache and Nagios, you should not get that nagios.cmd error message anymore.

Code: Select all
service httpd restart
service nagios restart
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
Box293
Too Basu
 
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia

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

Postby paul.tyler1 » Thu Jun 12, 2014 6:33 pm

Stuart Watts wrote:What are the permissions on nagios.cmd, and the directories it sits in?
Code: Select all
ls -l /usr/local/nagios/var/rw/nagios.cmd
ls -ld /usr/local/nagios/var/rw
ls -ld /usr/local/nagios/var
ls -ld /usr/local/nagios
ls -ld /usr/local



Here are the permissions:
[root@i-2743-8087-VM local]# ls -ld
drwxr-xr-x 14 root root 4096 Jun 12 12:20 .
[root@i-2743-8087-VM local]# cd nagios/
[root@i-2743-8087-VM nagios]# ls -ld
drwxrwxr-x 9 nagios nagios 4096 May 15 12:14 .
[root@i-2743-8087-VM nagios]# ls -lhart
total 72K
drwxrwxr-x 2 nagios nagios 4.0K May 15 12:05 bin
drwxrwxr-x 2 nagios nagios 4.0K May 15 12:05 sbin
drwxr-xr-x 2 root root 4.0K May 15 12:14 include
drwxrwxr-x 9 nagios nagios 4.0K May 15 12:14 .
drwxrwxr-x 11 nagios nagios 4.0K May 15 12:14 share
drwxrwxr-x 3 nagios nagios 4.0K May 15 12:14 libexec
drwxrwxr-x 3 nagios nagios 4.0K May 23 12:46 etc
drwxr-xr-x 14 root root 4.0K Jun 12 12:20 ..
drwxrwxr-x 5 nagios nagios 4.0K Jun 13 08:31 var
[root@i-2743-8087-VM nagios]# cd var/
[root@i-2743-8087-VM var]# ls -lhart
total 1.6M
drwxrwxr-x 3 nagios nagios 4.0K May 15 12:05 spool
drwxrwxr-x 9 nagios nagios 4.0K May 15 12:14 ..
drwxrwxr-x 2 nagios nagios 4.0K Jun 7 23:59 archives
-rw-r--r-- 1 nagios nagios 1.4M Jun 12 12:01 nagios.debug
-rw-r--r-- 1 nagios nagios 21K Jun 12 15:26 objects.precache
-rw-r--r-- 1 nagios nagios 6 Jun 12 15:26 nagios.lock
drwxrwsr-x 2 nagios nagcmd 4.0K Jun 12 15:26 rw
-rw-r--r-- 1 nagios nagios 21K Jun 12 15:26 objects.cache
-rw------- 1 nagios nagios 27K Jun 13 08:26 retention.dat
-rw-r--r-- 1 nagios nagios 41K Jun 13 08:26 nagios.log
-rw-rw-r-- 1 nagios nagios 28K Jun 13 08:31 status.dat
drwxrwxr-x 5 nagios nagios 4.0K Jun 13 08:31 .
[root@i-2743-8087-VM var]# cd rw/
[root@i-2743-8087-VM rw]# ls -lhart
total 24K
srw-rw---- 1 nagios nagcmd 0 Jun 12 15:26 nagios.qh
prw-rw---- 1 nagios nagcmd 0 Jun 12 15:26 nagios.cmd
drwxrwsr-x 2 nagios nagcmd 4.0K Jun 12 15:26 .
drwxrwxr-x 5 nagios nagios 4.0K Jun 13 08:32 ..
Paul
Interested in Monitoring directories, files and services
paul.tyler1
 
Posts: 5
Joined: Wed Jun 11, 2014 7:11 pm

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

Postby paul.tyler1 » Thu Jun 12, 2014 6:43 pm

Box293 wrote:I found this blog fixed the same problem (after trying lots of other similar sites).

http://linux.101hacks.com/unix/nagios-cmd-file-error/

I assume the group nagcmd already exists, so do the following:

Code: Select all
usermod -G nagcmd nagios
usermod -G nagcmd apache
chown nagios:nagcmd /usr/local/nagios/var/rw
chown nagios:nagcmd /usr/local/nagios/var/rw/nagios.cmd


Finally, restart the Apache and Nagios, you should not get that nagios.cmd error message anymore.

Code: Select all
service httpd restart
service nagios restart


It looks like the correct permissions are in place already.
srw-rw---- 1 nagios nagcmd 0 Jun 12 15:26 nagios.qh
prw-rw---- 1 nagios nagcmd 0 Jun 12 15:26 nagios.cmd

I am stumped on this.
Paul
Interested in Monitoring directories, files and services
paul.tyler1
 
Posts: 5
Joined: Wed Jun 11, 2014 7:11 pm

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

Postby lmiltchev » Fri Jun 13, 2014 2:13 pm

Can you run the following command and show us the output?

Code: Select all
grep nag /etc/group
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
Former Nagios Staff
 
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

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

Postby paul.tyler1 » Mon Jun 16, 2014 6:55 pm

[root@i-2743-8087-VM ~]# grep nag /etc/group
nagios:x:500:apache
nagcmd:x:501:nagios
Paul
Interested in Monitoring directories, files and services
paul.tyler1
 
Posts: 5
Joined: Wed Jun 11, 2014 7:11 pm

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

Postby sreinhardt » Tue Jun 17, 2014 9:52 am

Looks like the usermod commands from above were not run. Could you run:

Code: Select all
usermod -G nagios nagios
usermod -G nagcmd apache
service nagios restart
service httpd restart


This is just so that both user account have proper access to the files they need.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
sreinhardt
-fno-stack-protector
 
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

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

Postby paul.tyler1 » Tue Jun 17, 2014 7:28 pm

I see now... Sorry, I was confused when I was looking at the permissions. Thank you, that did fix the notifications.
Paul
Interested in Monitoring directories, files and services
paul.tyler1
 
Posts: 5
Joined: Wed Jun 11, 2014 7:11 pm

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

Postby Box293 » Tue Jun 17, 2014 7:40 pm

Happy days :D
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
Box293
Too Basu
 
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia

Next

Return to Open Source Nagios Projects

Who is online

Users browsing this forum: Fess [Nagios Bot], Majestic-12 [Bot] and 16 guests