I have extended the well-known Nagios Docker check script by Erik Kristensen and added comprehensive **substate monitoring**. The new version allows for much more accurate container health checks – perfect for production environments where “running / not running” is simply not enough.
### **What’s New?**
Compared to the original script, which only differentiated between *running*, *restarting*, *stopped*, and *unknown*, the updated version now supports several additional Docker substates:
๐น **WARNING states**
* Paused
* Restarting
* Removing
* Created (but not started)
๐น **CRITICAL states**
* Exited
* Dead
* OOMKilled (Out of Memory)
* Stopped (not running)
๐น **Improved Robustness**
* No more template errors thanks to dynamic state parsing
* Additional evaluation of the `.State.Status` field
* Fallback handling for missing fields
* Improved container existence checks
* Fully compatible with NRPE, NCPA, and local host checks
๐น **Additional Enhancements**
* Outputs container start time and IP address
* Licensed under **GPLv3**
* General code hardening (better error handling, safer Docker calls)
This makes the script an excellent choice for environments that require detailed container monitoring – such as debugging setups, monitoring pipelines, and sensitive production workloads.
๐ **View / Download the script:**
https://gitba.se/tpries/check_docker_container/src/branch/main/check_docker_container.sh#
Hi, Iโm a trained IT specialist in system integration and have been working as a Linux system administrator for several years. At home, I feel most comfortable with Proxmox, Ubuntu, and Debian โ these three accompany me both at work and on my personal servers. When Iโm not busy at the shell, I enjoy tinkering with new projects, testing exciting open-source tools, or optimizing existing setups. On linuxbase.io, I want to share my experiences so others donโt have to stumble over the same pitfalls.
