#!/bin/sh set -eu [ -n "${DEBUG:-}" ] && set -x healthcheck() { local container=${1:?} podman healthcheck run "$container" >/dev/null 2>&1 || true podman inspect --format '{{if .State.Health}}{{.Name}} {{.State.Health.Status}}{{end}}' "$container" | ( read -r name status test -n "$name" || return printf '%s (%s) is %s\n' "$container" "$name" "$status" case "$status" in healthy) ;; *) # tgnotify "!!! service $container unhealthy" ;; esac ) } main() { case "${1:-}" in "") podman container ls --format '{{.ID}}' | xargs -n1 $0 ;; *) healthcheck "$1" ;; esac } main $@