Install Nagios with Docker
Configure the BigPanda agent to send monitoring alerts from Nagios.
The BigPanda agent is a low-footprint utility installed on the master host of your monitoring tool. It consumes alerts from the tool in real-time and then transmits them to BigPanda via TLS-encrypted HTTP calls.
Python Compatibility
To use the Open Integration Manager for Agent-based integrations, Python version>= 3.8.0 and an Agent version >= 10.2 are required.
Prerequisites
Docker Desktop or Docker Engine must be installed prior to installing the BigPanda agent docker image
.
-
Follow the Docker Installation Guide for your system.
-
If using
Docker Compose
, follow the Install Docker Compose guide to ensure the latest version of compose is installed on your system.Docker Compose
is built with the latest version ofDocker Desktop
.- If using
Docker CLI
, ensureDocker CLI's Compose Plugin
is installed separately.
Note: If you have issues running any of the docker commands, you either need to run docker with sudo
, or add your user to run in the docker group as a non-root user.
Environment Variables
The docker image provides the following environment variables, which can be used to initialize the agent with the appropriate plugin.
- BP_TOKEN: Initializes the BigPanda Agent Bearer Token
- SNMP_APP_KEY: Initializes the BigPanda Agent Bearer Token
- HTTP_PROXY: Adds the proxy settings to bigpanda.conf
- FORCE_APP_KEY: Set to
true
to override the existing plugin app key - NAGIOS_APP_KEY: Sets the Nagios App Key and configures the plugin
- NAGIOS_USER: Sets the Nagios Username and is required to set up Nagios plugin
- ZABBIX_APP_KEY: Sets the Zabbix App Key and configures the plugin
- ZENNOSS_APP_KEY: Sets the Zenoss App Key and configures the plugin
- ICINGA_APP_KEY: Sets the Icinga App Key and configures the plugin
Pull the BigPanda docker image
-
Pull the
latest
BigPanda agent docker image from the BigPanda JFrog Docker Registry:docker pull bigpandaio-int-docker.jfrog.io/bigpanda-agent:latest
-
Check that the latest image was downloaded successfully:
docker image ls
Optional:
You can configure a dedicated docker network for the agent. This is useful if you require the agent to communicate with other docker services.
-
Create the docker network:
docker network create <network-name>
-
Check that the network was created:
docker network ls
Configure Nagios
Configure Nagios to send notifications to BigPanda.
-
Edit the main configuration file (
nagios.cfg
). The default location is:/usr/local/nagios/etc/nagios.cfg
.- Add the following line:
cfg_file=/etc/bigpanda/bigpanda-contact.cfg
- Ensure that notifications are enabled
enable_notifications=1
- Add the following line:
-
In the file where your host objects are defined (for example,
templates.cfg
):- Add the
bigpanda
contact to thecontact_groups
. - Set the
notification_options
for the host to:d,r,u,f,s
.
For example:
define host{ name generic-host contact_groups admins,bigpanda notification_period 24x7 notification_options d,r,u,f,s }
If the
contact_groups
option is not already listed in your definitions, you can add it. - Add the
-
In the file where your service objects are defined (for example,
templates.cfg
):- Add the
bigpanda
contact to thecontact_groups
. - Set the
notification_options
for the service to:c,r,w,u,f,s
.
For example:
define service{ name generic-service check_period 24x7 contact_groups admins,bigpanda notification_interval 60 notification_period 24x7 notification_options c,r,w,u,f,s }
If you have already configured notification options on a more specific template or definition, those settings will take precedence over the generic settings.
To get the most out of this integration, ensure all of the desired notifications are sent to BigPanda.
- Add the
-
Restart the Nagios service.
sudo service nagios restart
Configure a docker container to work with Nagios
-
Run the container in detached mode, passing both BP_TOKEN and NAGIOS_APP_KEY environment variables to docker run.
docker run -dit \ --name bp_agent \ -e BP_TOKEN=<Your Org Bearer Token> \ -e NAGIOS_APP_KEY=<Your App Key> \ -e NAGIOS_USER=<nagios user> \ -v /usr/local/nagios/etc:/usr/local/nagios/etc \ -v /etc/bigpanda/bigpanda-contact.cfg:/etc/bigpanda/bigpanda-contact.cfg \ bigpandaio-int-docker.jfrog.io/bigpanda-agent:latest
-
View the logs of the running docker container:
docker container logs -f bp_agent
Optional - Docker Compose
Services can be managed via Docker Compose
, which requires either the Docker Compose Plugin or the latest Docker Desktop installed.
-
Create a file called
docker-compose.yml
:vim docker-compose.yml
-
Add the BigPanda agent service configuration to
docker-compose.yml
:version: '3.9' services: bp_agent: image: bigpandaio-int-docker.jfrog.io/bigpanda-agent:latest container_name: bp_agent restart: always stdin_open: true tty: true environment: - BP_TOKEN=<Your Org Bearer Token> - NAGIOS_APP_KEY=<Your App Key> - NAGIOS_USER=<nagios user> volumes: - /usr/local/nagios/etc:/usr/local/nagios/etc - /etc/bigpanda/bigpanda-contact.cfg:/etc/bigpanda/bigpanda-contact.cfg networks: - bigpanda networks: bigpanda: external: true
It's important to note that the following commands are based on having Docker Engine 19+ installed, or Docker Desktop installed which has Docker Compose support. If the docker-compose plugin is installed separately, then the command will start with
docker-compose
vsdocker compose
. -
Bring up the agent container:
docker compose up -d
-d
is used to run the container in detached mode. -
View the logs of the running docker container:
docker compose logs -f
-
You can bring down the container with the
down
command:docker compose down
Configure the Nagios plugin
The Nagios plugin requires configuration, which means that we need an interactive session to set it up. The problem when running a docker container in detached mode is the entrypoint script is running the shell session in the background. For this, we can attach to the running session to complete the configuration.
-
Attach to the shell session to continue setting up Nagios
docker attach --detach-keys="ctrl-q" agent
Since
ctrl-c
will send a kill signal to the shell, stopping the container,--detach-keys
passes an alternate key sequence.
Test the Integration
-
Run the following command inside the container:
docker exec -it bp_agent /usr/bin/bigpanda-notification --send-test
docker exec
executes a command inside a container.- A test alert should arrive in a few moments.
-
In BigPanda, click the Incidents tab at the top of the screen.
-
Confirm that the test alert was received.
-
Since it's a test alert, it won't be resolved automatically. Click Resolve incident to manually resolve it.
Success
The next time Nagios sends a notification for an alert, you will see the alert in the Incident Dashboard.
Updated about 1 month ago