Write a bash or python nagios plugin that checks inode usage of multiple docker containers, and displays the name of the container, or containers that exceed warning or critical thresholds
Budget: £20 – £250 GBP
We make use of 2 commands, redirecting output to temp files I imagine. The commands are:
1 - df -i | grep devicemapper
and
2 - docker ps --format "{{.ID}}" | xargs docker inspect -f "{{.GraphDriver.Data.DeviceName}} {{.Name}}"
The output of each of these commands overlaps with the other, and so I want 3 possible outcomes typical for nagios:
if [[ "$warning_alert" -eq 1 ]]; then
echo "WARNING: Container $alerting_container on host `hostname` exceeds the warning level of inode usage percentage, which is $warn%"
exit $WARNING
elif [[ "$critical_alert" -eq 1 ]]; then
echo "CRITICAL: Container $alerting_container on host `hostname` exceeds the critical level of inode usage percentage, which is $crit%"
exit $CRITICAL
else
echo "OK: All docker container devicemapper filesystems on host `hostname` are within acceptable limits of inode usage percentage, which is under $warn%"
exit $OK
fi
I've made a start on this [uploaded here] but cannot get it to work exactly - if you can debug that might make the job shorter, but if not write a new script why not.
1 - df -i | grep devicemapper
and
2 - docker ps --format "{{.ID}}" | xargs docker inspect -f "{{.GraphDriver.Data.DeviceName}} {{.Name}}"
The output of each of these commands overlaps with the other, and so I want 3 possible outcomes typical for nagios:
if [[ "$warning_alert" -eq 1 ]]; then
echo "WARNING: Container $alerting_container on host `hostname` exceeds the warning level of inode usage percentage, which is $warn%"
exit $WARNING
elif [[ "$critical_alert" -eq 1 ]]; then
echo "CRITICAL: Container $alerting_container on host `hostname` exceeds the critical level of inode usage percentage, which is $crit%"
exit $CRITICAL
else
echo "OK: All docker container devicemapper filesystems on host `hostname` are within acceptable limits of inode usage percentage, which is under $warn%"
exit $OK
fi
I've made a start on this [uploaded here] but cannot get it to work exactly - if you can debug that might make the job shorter, but if not write a new script why not.