4

I'm trying to disable active check for a service through Nagios web interface, but I cant make it. The Nagios instance is running on a Centos 5 distribution

Each time I try to stop the service I get this message : Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!

Although I tried several proposals found on the web :

usermod -a -G nagios apache
chmod 666 /usr/local/nagios/var/rw/nagios.cmd
chown nagios.nagcmd /usr/local/nagios/var/rw
chmod u+rwx /usr/local/nagios/var/rw
chmod g+rwx /usr/local/nagios/var/rw  
chmod g+s /usr/local/nagios/var/rw 

Each time rebooting nagios service afterwards of course.

Thanks for your help ! Cheers

Matt
  • 45,022
  • 8
  • 78
  • 119
renard
  • 1,368
  • 6
  • 20
  • 40
  • What are the nagios_user and nagios_group [config values](http://nagios.sourceforge.net/docs/3_0/configmain.html#nagios_user) set to? What are the latest permissions on nagios.cmd and each of the directories on the way down to it? – Alain Collins Oct 09 '14 at 06:13
  • nagios_user and nagios_group are both set to nagios. Permissions on nagios.cmd are `prw-rw---- nagios nagcmd`. thx – renard Oct 14 '14 at 10:23

7 Answers7

10

This command is wrong:

usermod -a -G nagios apache

The group permissions on your rw directory and nagios.cmd file are nagcmd, not nagios. You need this, instead:

usermod -a -G nagcmd apache

This is what worked for me - or more specifically, on Ubuntu, it's:

usermod -a -G nagios www-data

jlemley
  • 533
  • 1
  • 4
  • 15
9

Selinux can also cause this problem. You can check its status with:

sestatus

If current mode is enforcing, change it to permissive with:

setenforce 0

Then you may be able to commit your changes into nagios.cmd.

Umut Uzun
  • 807
  • 11
  • 13
  • Looks like indeed SELinux enforcing mode has been causing me nagios.cmd issues, as suggested here. Any idea of how to make the Nagios command interface work consistently with enforcing mode enabled? – Isac Casapu Jun 05 '17 at 10:58
6

This is how you have to follow

service httpd stop

service nagios stop


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


service httpd start

service nagios start
Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
decimal
  • 312
  • 4
  • 8
0

The following should fix the issue in Debian:

chown -R www-data:www-data /usr/local/nagios/var/
mech
  • 2,775
  • 5
  • 30
  • 38
0

I haven't seen this mentioned and it caught me out, it's worth checking the apache child processes are running as the apache user.

I built my apache from source and this uses daemon as the default user and group for the child processes so this had to be changed for this to work.

Rich J
  • 31
  • 4
0

What worked for me is :

chmod ugo+rw /usr/local/nagios/var/rw/ /usr/local/nagios/var/rw/nagios.cmd

and restarting apache and nagios.

-1

The only issue with this is selinux. Stop it and it will work fine. Credit goes to Nagios team.