Nagios.cmd file continually goes missing

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
brent20
Posts: 4
Joined: Tue Aug 15, 2017 8:00 am

Nagios.cmd file continually goes missing

Post by brent20 »

Hi everyone,

I've been working on this issue for the past week. We've been running Nagios Core 3.5.1 on RHEL for some time until it seems like Core 4.3.2 was available in the RHEL package repository and it was updated unexpectedly when we were doing our standard linux patching process. After the shock of finding out Nagios wouldn't start after the patching we worked to resolve that (lock file permissions). Now that we've gotten past that, we seem to continue to have problems with the external command file where it will suddenly be deleted and we recieve this error in the web UI when trying to execute any command:
Error: Could not stat() command file '/var/spool/nagios/cmd/nagios.cmd'

Naturally, if I go look in /var/spool/nagios/cmd -the file is missing.
After plenty of research, performing the commands that I found from someone else on this support form do resolve this:
$ sudo service nagios stop
$ sudo killall nagios
$ sudo service nagios start

Upon restart- the Nagios.cmd file is recreated in /var/spool/nagios/cmd/and everything works as usual again. This will go on for maybe a day or 2 until I get the missing file error again and preform the same 3 commands to restore it. We don't have any issues writing commands to the file from the web UI (httpd/apache user, which is in our nagios group)

Permissions in the cmd directory are as follows:

$ ls -l /var/spool/nagios/cmd
total 0
prw-rw----. 1 nagios nagios 0 Aug 18 10:01 nagios.cmd
srw-rw----. 1 nagios nagios 0 Aug 18 10:01 nagios.qh


Permissions in the nagios directory:
$ ls -l /var/spool/nagios/
total 8
drwxrwsr-x. 2 nagios nagios 4096 Jun 28 11:43 checkresults
drwxrwsr-x. 2 nagios nagios 4096 Aug 18 10:01 cmd


and permissions on the nagios directory in /var/spool:
drwxrwsr-x. 4 nagios nagios 4096 Aug 12 09:08 nagios

The nagios group contains the user that nagios runs under as well as the apache user.

We never had this issue when running Core 3.5.1 so this very perplexing. Any help would be greatly appreciated!
Thanks!
bolson

Re: Nagios.cmd file continually goes missing

Post by bolson »

Hello brent20,

Is it here?

/usr/local/nagios/var/rw/nagios.cmd

What does the:
command_file=
directive in /usr/local/nagios/etc/nagios.cfg say?
brent20
Posts: 4
Joined: Tue Aug 15, 2017 8:00 am

Re: Nagios.cmd file continually goes missing

Post by brent20 »

bolson wrote:Hello brent20,

Is it here?

/usr/local/nagios/var/rw/nagios.cmd

What does the:
command_file=
directive in /usr/local/nagios/etc/nagios.cfg say?
Hi Brian,
For the record we have Nagios installed on a RHEL 7 server, my configuration is located in /etc/nagios/
the directive for the command file location in our nagios.cfg file is:
# EXTERNAL COMMAND FILE
# This is the file that Nagios checks for external command requests.
# It is also where the command CGI will write commands that are submitted
# by users, so it must be writeable by the user that the web server
# is running as (usually 'nobody'). Permissions should be set at the
# directory level instead of on the file, as the file is deleted every
# time its contents are processed.
command_file=/var/spool/nagios/cmd/nagios.cmd

This is how it's always been setup after installation via the RHEL packages- it was working fine with Core 3.5.1 this way as well. Did something change in 4x?

Thanks!
bolson

Re: Nagios.cmd file continually goes missing

Post by bolson »

The location of the command file changed from Nagios Core version 3 to 4.

Put command_file=/usr/local/nagios/var/rw/nagios.cmd

in your nagios.cfg and let me know if this resolves your issue.
brent20
Posts: 4
Joined: Tue Aug 15, 2017 8:00 am

Re: Nagios.cmd file continually goes missing

Post by brent20 »

Thanks Brian,

i'll have to create this directory - what are the permissions I should apply to it?

Thanks again!
bolson

Re: Nagios.cmd file continually goes missing

Post by bolson »

For the directory:

Code: Select all

drwxrwsr-x. 2 nagios nagios  4096 Aug 16 14:37 rw
And for the files:

Code: Select all

prw-rw----. 1 nagios nagios 0 Aug 16 14:37 nagios.cmd
srw-rw----. 1 nagios nagios 0 Aug 16 14:37 nagios.qh
Let me know if this resolves your issue.

Thank you!
brent20
Posts: 4
Joined: Tue Aug 15, 2017 8:00 am

Re: Nagios.cmd file continually goes missing

Post by brent20 »

Hi Brian,

After a week or two of not having any missing command file errors I think it's safe to say that this resolved it! Thanks again for all your help! It was strange that the file was still being created and modified after the service started before we changed the path.

Thanks again!
bolson

Re: Nagios.cmd file continually goes missing

Post by bolson »

Glad to hear that things are now working as expected!

Closing this topic as resolved.

Thank you for visiting the Nagios Support Forum.
Locked