Add Custom Nagios Plugin to Icinga2 and use in Director

I’m using the latest Icinga2 stack from the Icinga2 Playground w/ compose → lippserd/docker-compose-icinga: docker-compose Icinga stack (github.com)

I’m trying to add a custom nagios plugin as my understanding is that icinga is compatible w/ nagios plugins. I’m fine to hear alternatives really, but as I want to master being able to insert nagios plugins in general I will want to learn this method.

timdaman/check_docker: Nagios plugin to check docker containers (github.com)

So far I’ve added the check_docker.py (named check_docker) to /usr/lib/nagios/plugins and restarted the stack, but I can’t seem to get it to show up in the Director/WebUI.

Do I need to do something further so I can configure it via WebUI? I expected it would show after downloading/adjust permissions and restarting stack.

Thanks in advance.

Well I got it to work but it wasn’t easy! I had to modify the original image, but thankfully they leave apt configured so I was able to install sudo and python3-pip and use pip to install check_docker

I then added icinga to sudo group and granted passwordless sudo as “check_docker” wouldn’t work without root.

I bind mounted the /var/run/docker.sock

Final setup looks like this →

Updated notes →

ICINGA - Docker - Monitor Docker via check_docker - FreeSoftwareServers - FreeSoftwareServers

ICINGA - Docker - Add SUDO Capabiltiy - FreeSoftwareServers - FreeSoftwareServers

I guess I’ll be building a Dockerfile and pushing a custom image to my repo. I generally prefer to use base image, but installing python3 via outside dependency seems ridiculous, should be a simple Dockerfile w/ basic ability to add packages via APT which I can see needing later anyway.

Thanks All, let me know if there is a better way

1 Like

I’m trying to add a custom nagios plugin as my understanding is that icinga is compatible w/ nagios plugins

Icinga is compatible with the nagios plugin output so installing all dependencies is a must for any plugin to work. even the monitoring-plugins are distribution specific.

Final setup looks like this →

Have a look at the argument section. Since the container name can be different, or you want to check other containers with check_docker you should use --containers as an argument and add it as a field to your check.
That way you can reuse the check for other containers.

You can also have the --version as a boolean, but that’s to much writing right now not knowing how you will proceed further.

There are also more arguments you want to use like cpu or memory checks.

Best regards.