Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems running custom plugins (check_nrpe) #15

Open
tr1plus opened this issue Jan 5, 2020 · 6 comments
Open

problems running custom plugins (check_nrpe) #15

tr1plus opened this issue Jan 5, 2020 · 6 comments

Comments

@tr1plus
Copy link

tr1plus commented Jan 5, 2020

Hey

I decided to switch from a dedicated machine running nagios to a docker.
docker is running fine and I'm able to connect to the dashboard. All "standard" plugins (check_ping, ...) are also running fine.

I do have a few 'custom' plugins (check_nrpe, ...) that I used to run. However I keep getting the following error when running them via the nagios dashboard

(No output on stdout) stderr: execvp(/opt/nagios/libexec/custom/check_nrpe, ...) failed. errno is 2: No such file or directory

Running the command manually via ssh on the host returns correct results, so the plugin does work. It seems a 'translation' from the host to the docker is preventing some things from running correctly.

NOTE: this set-up used to work outside of docker, so I'm assuming it's related to authorizations or something like that, but even setting chmod 777 doesn't seem to work...

commands.cfg
define command{ command_name check_nrpe command_line $USER1$/custom/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }

resource.cfg
$USER1$=/usr/local/nagios/libexec

calling the plugin
define service{ use generic-service ; Name of service template to use host_name dockerpi service_description Current Users check_command check_nrpe!check_users }

plugin file stats
pi@dockerpi2:~/docker/containers/nagios/libexec/custom $ stat check_nrpe File: check_nrpe Size: 102112 Blocks: 200 IO Block: 4096 regular file Device: b302h/45826d Inode: 129480 Links: 1 Access: (0755/-rwxr-xr-x) Uid: ( 100/systemd-timesync) Gid: ( 101/systemd-journal) Access: 2020-01-05 17:22:49.000000000 +0100 Modify: 2017-10-29 16:56:32.000000000 +0100 Change: 2020-01-05 17:37:03.604777318 +0100 Birth: -

Docker is set to bind
/home/pi/docker/containers/nagios/libexec/custom --> /opt/nagios/libexec/custom

@manios
Copy link
Owner

manios commented Jan 8, 2020

Hi @tr1plus ,

In our image the resource.cfg should contain:

# Sets $USER1$ to be the path to the plugins                             
$USER1$=/opt/nagios/libexec  

Nagios is installed in /opt/nagios/. As I see in your configuration you try to use:

$USER1$=/usr/local/nagios/libexec

Can you please check if this configuration change fixes your issue?
Thank you,
Christos

@tr1plus
Copy link
Author

tr1plus commented Jan 8, 2020

I'm sorry, that was copied over from my old set-up. On the docker image I didn't make any change and I can confirm it is indeed
$USER1$=/opt/nagios/libexec

As mentioned I think nagios/the docker can indeed see and find the plugin. If I make some changes to the authorization of the check_nrpe plugin I get a different error:

If I remove the executable (CHMOD 644) I see the following in Nagios dashboard
(Return code of 13 for service 'Current Load' on host 'dockerpi' was out of bounds)

If I make it exacutable again (CHMOD 755) I get the mentioned error:
(No output on stdout) stderr: execvp(/opt/nagios/libexec/custom/check_nrpe, ...) failed. errno is 2: No such file or directory

My feeling is that for whatever reason the docker is unable to successfully get the "reply" from running the command.
To my understanding nagios tried to execute the following command (which I did via SSH on the host)

pi@dockerpi2:~/docker/containers/nagios/libexec/custom $ ./check_nrpe -H 192.168.1.100 -c check_users

USERS OK - 0 users currently logged in |users=0;5;10;0

@manios
Copy link
Owner

manios commented Jan 8, 2020

Hi @tr1plus ,

I have a suspicion. You use check_nrpe, which is an executable which was compiled outside Docker for Raspbian OS. If that is the case, then it is possible that it does not run correctly as the binary is not compiled for Alpine Linux which we use inside the Docker container. In any case, if this binary is your sole problem, then you can use check_nrpe instead which is already available in /opt/nagios/libexec directory.

I have tested other external plugins such as mzupan/nagios-plugin-mongodb as a subdirectory mounted in /opt/nagioslibexec/mongodb and do not throw that kind of error. Also the container sets the nagios user ownership correctly to the external plugin when it starts.

If you continue to have problems, can you please provide me with steps to reproduce it? I will need:

  1. Full Docker run command
  2. The plugin you use (link to download it).
  3. Nagios configuration (service, host and command definitions).
  4. Any other special configuration.

Thank you ,
Christos

@tr1plus
Copy link
Author

tr1plus commented Jan 8, 2020

oh my oh my. You are totally right! It was indeed compiled on the raspberry pi itself, and not on alpine linux. My bad!

Changing everything to the already available plugin seems to be working and everything is reporting green once again!

I assume this docker contains all the same 'custom' plugins as JasonRivers/Docker-Nagios? I didn't realize this...

Thank you sooo much for helping on this one :) This saved me a lot of hair pulling and time!

P.S. one small question, do python plugins work out of the box? I see you referencing the mongodb one and it is python. Anything special I need to do?

@manios
Copy link
Owner

manios commented Jan 8, 2020

Hi @tr1plus !

Thanks for testing this in such a short notice! As far as the image is concerned, it is inspired by JasonRivers/Docker-Nagios but follows a different approach targeted to a very lightweight size and basic features.

That said, I tried to make a small, yet operational base image which contains:

  1. Nagios Core
  2. Nagios plugins (base plugins provided by Nagios)
  3. NRPE

To use Python plugins you can either install Python inside the container, or create a custom Dockerfile with FROM manios/nagios:latest as its base image. Maybe in the future (time permitting), we could think of making an image variant with Python and/or Perl preinstalled.

I hope that it helps,
Best regards,
Christos

@tr1plus
Copy link
Author

tr1plus commented Jan 8, 2020

That clears up a whole lot! it would be nice if you would put that in the read-me file, but otherwise I am really enjoying this container. Time to start monitoring my home set-up again with all the bells & whistles ;)

Many thanks once more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants