Last active
December 18, 2015 10:51
-
-
Save marqu3z/bcf98ac62fd002ee613e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Author: Marco Andreotti | |
| # Email: marco.andreotti@tanaza.com | |
| # License: MIT | |
| # Nagios Usage: check_nrpe!check_docker_container!_container_id_ | |
| # Usage: ./check_docker_container.sh _container_id_ | |
| # | |
| # The script checks if a container is running. | |
| # OK - running | |
| # UNKNOWN - does not exist | |
| CONTAINER=$1 | |
| TASK=$2 | |
| RUNNING=$(docker ps | grep -w "$CONTAINER" | awk '{print $4" "$8" "$9" "$10}' | grep "$TASK") | |
| [ -z "$RUNNING" ] && { | |
| echo "UNKNOWN - $CONTAINER - $TASK does not exist." | |
| exit 3 | |
| } || { | |
| echo "OK - $CONTAINER - $TASK is up! ---> \n$RUNNING" | |
| exit 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment