2026-01-14 08:37:12 +01:00
2021-07-16 16:11:33 -05:00
2026-01-13 13:14:53 +01:00
2021-07-16 18:19:58 -05:00

Systemd units and Docker containers monitoring for PRTG

Monitor one or more systemd units and/or Docker services for PRTG using the HTTP Push Data Advanced sensor.

Set an OK status for units that are active or an Error status for units that are not active. The units monitored can be services or any other type of units.

Give full usage details for Docker containers on host.

Tested on

  • Debian 13 with latest docker
  • Latest release of PRTG

How to use

Both script outputs XML suitable for PRTG's advanced sensor types. It can be used with HTTP Push Data Advanced sensor using the prtg_push_advanced.sh script.

For the systemd part, the units you want to monitor can be specified staticly inside the script systemd_units.sh, for example:

units=(sshd httpd firewalld)

Unit types other than services must have their type suffix specified. You may also be able to specify mount units by their mount point path instead of their unit name.

For the docker part, the containers you want to monitor can be specified staticly inside the script DockerStats4PRTGxml.sh, for example:

CONTAINERS="paperless_db_1 paperless_broker_1 paperless_webserver_1 watchtower paperless_tika_1 paperless_gotenberg_1"

Setup

Download all scripts :

mkdir -p /var/prtg/scriptsxml
cd /var/prtg/scriptsxml
wget https://raw.githubusercontent.com/stylersnico/prtg_systemd_docker_http_push/refs/heads/main/DockerStats4PRTGxml.sh
wget https://raw.githubusercontent.com/stylersnico/prtg_systemd_docker_http_push/refs/heads/main/prtg_push_advanced.sh
wget https://raw.githubusercontent.com/stylersnico/prtg_systemd_docker_http_push/refs/heads/main/systemd_units.sh
chmod +x *

Configure DockerStats4PRTGxml.sh and systemd_units.sh to monitor what you need. Create a new HTTP Push Data Advanced sensor in PRTG, then enter the settings and grab the "Identification token" in PRTG.

Then launch the following command to test it (adapt to the script you want to use):

/var/prtg/scriptsxml/DockerStats4PRTGxml.sh | /var/prtg/scriptsxml/prtg_push_advanced.sh -a "http://PRTGSERVER:5050" -t "token"

The feedback of the command should look like this:

{"status":"Ok","Matching Sensors":"1"}

Crontab

Open your crontab:

crontab -e

Configure the launch every minute like this:

* * * * * /var/prtg/scriptsxml/systemd_units.sh | /var/prtg/scriptsxml/prtg_push_advanced.sh -a "http://PRTGSERVER:5050" -t "xxx" > /dev/null 2>&1
* * * * * /var/prtg/scriptsxml/DockerStats4PRTGxml.sh | /var/prtg/scriptsxml/prtg_push_advanced.sh -a "http://PRTGSERVER:5050" -t "xxx" > /dev/null 2>&1

Screenshots

docker-example systemd-example

Special thanks

S
Description
Monitor systemd units and Docker containers with PRTG via HTTP Push Data Advanced sensor
Readme MIT 258 KiB
Languages
Shell 100%