What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Sensor for Docker Container monitoring

Votes:

1

Your Vote:

Up

Down

Good morning,

today I wrote a script to monitor the services on a docker host.

You'll get a warning if a container is dead which should be running.

Just move the script to /var/prtg/scripts and create a new sensor "SSH Scripts"

Dont forget to execute chmod +x !

#!/bin/sh

#Variables

hostname="`cat /etc/hostname`"

#MAIN
deadcontainer="`docker service ls --format {{.Name}}:{{.Replicas}} | grep '0/1' | cut -d':' -f1`"
if [ "$deadcontainer" == "" ]; then
    echo "0:1:All container are running"
    exit 0
else
    for i in $deadcontainer; do
        echo "1:0:$deadcontainer is not running"
        exit 1
    done
fi

Have fun!

docker prtg server service ssh

Created on Jul 12, 2019 7:59:12 AM by  Matthias Pröll (1) 1



2 Replies

Votes:

1

Your Vote:

Up

Down

Awesome, thanks for sharing! :)


PRTGapi | Feature Requests | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 12, 2019 8:32:48 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Youre welcome :)

Created on Jul 12, 2019 9:18:14 AM by  Matthias Pröll (1) 1




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.