manios / docker-nagios

Docker image for Nagios Core in Alpine Linux with basic plugins, available for x86, x64 , ARM v6, ARM v7 and ARM64.
https://www.nagios.org/
Other
60 stars 28 forks source link

Error: Could not open command file '/opt/nagios/var/rw/nagios.cmd' for update! #38

Closed civodul999 closed 2 years ago

civodul999 commented 2 years ago

Hi, I'm trying this nagios container, when I want to force a check through web interface, I have this error :

Error: Could not open command file '/opt/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.

I read the differents issues, I have seen this one but, for me with the build manios/nagios:latest (nagios version 4.4.6), I have the error.

I don't have nagcmd group inside the container, I have nagios user and nagios group like the dockerfile.

The permissions are like this :

/opt/nagios # ls -lt var/
total 2752
-rw-rw-r--    1 nagios   nagios      151476 Jan  5 21:26 status.dat
-rw-r--r--    1 nagios   nagios     2385521 Jan  5 21:07 nagios.log
-rw-------    1 nagios   nagios      151087 Jan  5 21:07 retention.dat
-rw-r--r--    1 nagios   nagios      108547 Jan  5 20:07 objects.cache
drwxr-xr-x    2 nagios   nagios        4096 Jan  5 20:07 rw
drwxr-xr-x    2 nagios   nagios        4096 Jan  5 00:00 archives
drwxr-xr-x    3 nagios   nagios        4096 Dec 30 22:47 spool
/opt/nagios # ls -lt var/rw/
total 0
srw-rw----    1 nagios   nagios           0 Jan  5 20:07 nagios.qh
prw-r-----    1 nagios   nagios           0 Dec 30 22:47 nagios.cmd

Is it a bug I can fix with some command or it should be fixed in a future release ?

Thank you for your help.

manios commented 2 years ago

Hi @civodul999 !

I have tried to schedule a forced check by the web interface and it works , as you can see in the logs:

2022-01-06T12:34:01.602503+00:00 2bf6a8ff89ed : EXTERNAL COMMAND: SCHEDULE_FORCED_HOST_CHECK;localhost;1641472450
2022-01-06T12:34:12.192946+00:00 2bf6a8ff89ed : EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;Current Load;1641472459

I have used the linux/amd64 os variant of the manios/nagios:latest image. Can you please provide me with the following information?

  1. Steps to reproduce
  2. Image information

    Can you please give us some information about the image you are using? In order to achieve this, please post here the output of the command:

    docker inspect --format='{{range $k,$v := .Config.Labels}}{{printf "* %s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v}}{{end}}{{"\n"}}{{end}}'  manios/nagios:[TAG]

    Example output:

    * build: 5
    * gitCommit: c34e48cb6866b1a2bb77adf4d69feeab534ecc84
    * homepage: https://www.nagios.com/
    * maintainer: Christos Manios <maniopaido@gmail.com>
    * nagiosPluginsVersion: 2.3.3
    * nagiosVersion: 4.4.6
    * name: Nagios
    * nrpeVersion: 4.0.3
  3. Image architecture

    What is the architecture your docker image is using? You can easily find out by executing this

    docker exec -it [container-name] /bin/sh -c 'apk --print-arch'

    in your running container.

    Example output:

    amd64
  4. Relevant log output

Thanks, Christos

civodul999 commented 2 years ago

Hello, thank you for your help. Here the answers to your questions

1) on web interface, when I click on a service, then "Re-schedule the next check of this service", "commit". Next screen is the error.

2)

docker inspect --format='{{range $k,$v := .Config.Labels}}{{printf "* %s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v}}{{end}}{{"\n"}}{{end}}'  manios/nagios:latest
* build: 8
* gitCommit: 69c1a3a190b865ecaf765c50c5b2dcb1042bb9e8
* homepage: https://www.nagios.com/
* maintainer: Christos Manios <maniopaido@gmail.com>
* nagiosPluginsVersion: 2.3.3
* nagiosVersion: 4.4.6
* name: Nagios
* nrpeVersion: 4.0.3

3)

docker exec -it nagios /bin/sh -c 'apk --print-arch'
aarch64

4) sorry, no relevant logs. When a force a check, nothing happens in nagios.log

manios commented 2 years ago

Hi!

The docker image you use looks up to date. Since your architecture is aarch64 I suspect that you use a board like Raspberry Pi 4. Unfortunately I do not own one so I cannot test and reproduce the issue in this architecture. Maybe @DimmiDonger, @roe-ur-boat , @meanwhile28 can have a look too?

Last but not least can you try to create a forced check and send me the output of the following commands?

docker exec -it nagios /bin/sh -c 'cat /var/log/apache2/error.log'

and

docker exec -it nagios /bin/sh -c 'cat /var/log/apache2/access.log | egrep force'

Maybe these logs show something.

Thanks, Christos

civodul999 commented 2 years ago

yes, I'm using a raspberry pi 4.

for the commands, nothing relevant in the logs.

In access.log, I see the get and post request, but no error.

manios commented 2 years ago

Hi @civodul999 ,

I am closing the issue due to inactivity. If you can share any steps to reproduce the issue, we can reopen it.

Thanks, Christos

blacktav commented 1 year ago

Hello, can I re-open this? I have the problem on a regular xf86_64 system using the latest docker image

Apache log reports this "POST /nagios/cgi-bin/cmd.cgi HTTP/1.0" 200 1614 "http://netmon.datactics.net/nagios/cgi-bin/cmd.cgi?cmd_typ=7&host=bavaria&service=PIT+Website+9255&force_check" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"

while on the web-page, the user sees:

Error: Could not stat() command file '/opt/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.
An error occurred while attempting to commit your command for processing.

[Return from whence you came](javascript:window.history.go(-2))

Note: nagios.cmd does not exist