Skip to content

Instantly share code, notes, and snippets.

@marqu3z
Last active December 18, 2015 10:51
Show Gist options
  • Select an option

  • Save marqu3z/bcf98ac62fd002ee613e to your computer and use it in GitHub Desktop.

Select an option

Save marqu3z/bcf98ac62fd002ee613e to your computer and use it in GitHub Desktop.
#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