Page 1 of 1

nagios restart from process info page not working

Posted: Fri Aug 05, 2016 8:30 am
by avraham
when clicking process info->restart the nagios process->commit

i get the following error :
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.

Return from whence you came
-------------------
/usr/local/nagios/var/rw# ls -l
total 0
srw-rw---- 1 nagios nagcmd 0 Aug 5 08:59 nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Aug 5 08:59 nagios.qh


drwxr-xr-x 10 root root 4096 Oct 4 2015 /usr
drwxrwsr-x 20 root root 4096 Mar 19 16:08 /usr/local
drwxr-sr-x 9 root root 4096 Feb 29 18:01 /usr/local/nagios
drwxrwsr-x 8 nagios nagios 4096 Aug 5 09:25 /usr/local/nagios/var
drwxrwsr-x 2 nagios nagcmd 4096 Aug 5 08:59 /usr/local/nagios/var/rw

i didn't c anything in the faq related to this. i suppose there's are other faq's.
any hints would be appreciated.

i'm running nagios 4.1.1 on debian 8 (jessie)

"service nagios restart" works just fine.

tnx,
ams

Re: nagios restart from process info page not working

Posted: Fri Aug 05, 2016 10:30 am
by rkennedy
Did you follow a specific guide when installing that you can link to us? It sounds like a permission issue at this point.

Looking at my file, it has a p flag and you're seems to have a sticky bit. This will affect how the nagios.cmd file functions.

Code: Select all

[root@localhost rw]# ls -l
total 0
prw-rw---- 1 nagios nagcmd 0 Aug  4 15:02 nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Aug  4 15:01 nagios.qh

Re: nagios restart from process info page not working

Posted: Mon Aug 08, 2016 10:20 am
by avraham
hi r.k.,
tnx 4 u'r rapid response.

yes, i noticed that p (socket/pipe) instead of s (SUID isn't it? not sticky, which would be indicated by t?)

anyway, it's a socket, not a reg file:
/usr/local/nagios/var/rw# file nagios.cmd
nagios.cmd: socket

attempting to obliterate the s bit is ineffective:
/usr/local/nagios/var/rw# ls -l !$
ls -l nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Aug 8 10:35 nagios.cmd
/usr/local/nagios/var/rw# chmod u-s !$
chmod u-s nagios.cmd
/usr/local/nagios/var/rw# !ls
ls -l nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Aug 8 10:35 nagios.cmd
/usr/local/nagios/var/rw# chmod 660 !$
chmod 660 nagios.cmd
/usr/local/nagios/var/rw# !ls
ls -l nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Aug 8 10:35 nagios.cmd
/usr/local/nagios/var/rw#

deleting nagios.cmd and restarting nagios also results in a new nagios.cmd socket w/ the s bit set:
/usr/local/nagios/var/rw# rm nagios.cmd
/usr/local/nagios/var/rw# ls -l nagios.cmd
ls: cannot access nagios.cmd: No such file or directory
/usr/local/nagios/var/rw# service nagios restart
/usr/local/nagios/var/rw# service npcd restart
/usr/local/nagios/var/rw# service apache2 restart
/usr/local/nagios/var/rw# ls -l nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Aug 8 10:59 nagios.cmd
/usr/local/nagios/var/rw#

any suggestions?

tnx,
ams

Re: nagios restart from process info page not working

Posted: Mon Aug 08, 2016 3:17 pm
by ssax
Are you seeing anything in your /usr/local/nagios/var/nagios.log or in /var/log/messages that may be related?

What is the output of these commands:

Code: Select all

chage -l nagios
grep nag /etc/group
sestatus
Are you doing a lot of SNMP traps or passive checks?

Re: nagios restart from process info page not working

Posted: Tue Aug 09, 2016 5:11 am
by avraham
problem solved.
i was erroneously using the same filename for both the socket which livestatus uses, and the pipe, used for external commands.
the socket is nagios.qh. the pipe is nagios.cmd by default.

tnx,
ams

Re: nagios restart from process info page not working

Posted: Tue Aug 09, 2016 9:23 am
by tmcdonald
Great to hear! Can we lock this up now?