Simple script to monitor that all docker container is running, and report the status back to PRTG
It return 1 if the docker is running, or else it will return 0.
#!/bin/bash
echo "<prtg>"
#dockerlist_arr=( $(docker ps -a) )
readarray -t dockerlist_arr < <( docker ps -a | awk '{print $NF}' | tail -n +2 )
for i in "${dockerlist_arr[@]}"
do
echo "<result>"
echo "<channel>$i</channel>"
if [ "$( docker container inspect -f '{{.State.Running}}' $i )" = "true" ]; then
echo "<value>1</value>"
else
echo "<value>0</value>"
fi
echo "<LimitMode>1</LimitMode>"
echo "<LimitMaxError>1</LimitMaxError>"
echo "<LimitMinError>1</LimitMinError>"
echo "</result>"
# or do whatever with individual element of the array
done
echo "</prtg>"