Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Plugin or Script that can function as a Docker watchdog?

Featured Replies

I have several Docker containers running now. When performing system maintenance, I have to stop them. Sometimes I forget to re-start them.

Is there any app or script that could periodically monitor that my Docker containers are running? I already have a monitoring script from another host periodically polling Unraid itself and my VMs by testing with nc to see if port 22 is available. Unfortunately, some of my docker containers are UDP only, and I don't know of a way to detect if the container is running over the network when only UDP is offered.

Maybe there is a plugin or way to monitor within the Unraid environment? I checked for "Docker Watchdog" in the app store, but didn't find anything. I looked at all the apps starting with "docker" and didn't see anything that looked appropriate.

Does anyone have ideas on how to do this?

  • Community Expert

uptime kuma.. a docker that can be ran else where like a pi on teh network that set to notify use when something is down or off...

?why not set the docker to auto start?

  • Author
On 10/30/2025 at 5:29 PM, bmartino1 said:

?why not set the docker to auto start?

When I was having trouble with my VMs bring down Unraid, I got in the habit of turning off all the auto-starts whenever I restarted Unraid so I wouldn't get into a boot loop. I'd start Unraid, and then start the Dockers and VMs, verify they started OK, and then turn auto-start back on.

As I think about it I've never had a Docker container bring Unraid down, so maybe it is safe to leave auto-start enabled for Docker. That will help if I'm forgetful, but not in the case of a container stopping due to a fault.

w.r.t uptime kuma, that looks nice, and I might try it at some point. It says it can monitor "...uptime for HTTP(s) / TCP / HTTP(s) Keyword / HTTP(s) Json Query / Ping / DNS Record / Push / Steam Game Server / Docker Containers" .

UDP notably missing. I'm curious how it can detect a running docker container over the network if the container offers ports only on UDP (it is unifi-controller-reborn). Is there some other "generic Docker API" that is available on all Docker instances, above and beyond what is shown on Unraid's Container Port?

I already have a bash script running as a cron job on a Pi to monitor my Unraid server, its VMs and other devices using ping and nc. nc only supports verifying a port is open for TCP. I have been unable to find a simple way to determine the availability of a port with UDP. The complex way is to use tcpdump to monitor for UDP on the specific port and IP, identify an example of a real-world Unifi UDP packet exchange, and then duplicate that in a test application.

  • Community Expert

udp requires broadcast and the use of ipvlan/macvlan... uptime kuma is built on node.js... its not common to need a udp check, or a check on the broadcast...
https://github.com/louislam/uptime-kuma/issues/9
no udp as there is no need to check udp with node.js...

what your describing more is something like portainer and setting up health checks, but portainer has to be running and you have to make the health checks to mark the containers as healthy...
there are also a way to start dockers with docker exec... docker start <name of Docker> etc etc...

And a FYI, watch dog docker does exist...
Docker watchdog: https://github.com/buanet/docker.watchdog
(*Similar to running watch tower for docker updates you run watch dog the docker and add -l a label in the dockers your watching... )
-But this needs to run/be running....

But I find uptime kuma quicker and easier to setup then watchdog direct...
Similar to running portainer, this would run on top of the unraid docker socket system...

if you looking for tcp, udp , and dns for checking there are other nice if up stem checks... not all are free.... like commercial enterprise grade software (Something we use at work)
https://www.whatsupgold.com/network-mapping

or a separate VM that runs something like netbox or foreman:
https://theforeman.org/introduction.html

https://netboxlabs.com/
*but this is more documentation not live checks... something could be leveraged and scripted...
https://forums.unraid.net/topic/97228-support-linuxserverio-netbox/

*As you would want something with tcp dump and netcast... So Since your scripting, I would build my own script to run...
https://www.digitalocean.com/community/tutorials/how-to-use-netcat-to-establish-and-test-tcp-and-udp-connections
3rd party unraid install... /boot/extra to have and write your own user script check...
https://slackware.pkgs.org/15.0/slackdce-x86_64/netcat-0.7.1-x86_64-1_slackdce.txz.html


So, this really Depends on what your wanting it to do and how you want to interact with it.

Edited by bmartino1
spelling - weird issues with forum links.

  • Author

@bmartino1 thanks for all the suggestions. The digitalocean.com article is helpful in highlighting the challenges with monitoring UDP, especially non-standard services.

I'm hoping to figure out a way to just add the monitoring for the unifi Docker container to my script that is already monitoring all the services on Unraid running on a Pi.

I thought maybe there is a way to determine if the container running from within Unraid. From the Unraid shell, I see this:

root@T440:/mnt/user/appdata/unifi-controller-reborn/db# ls -ltr

----snip -----

-rw------- 1 nobody 104 1105 Nov 2 15:46 WiredTiger.turtle

root@T440:/mnt/user/appdata/unifi-controller-reborn/db#


The file WiredTiger.turtle is apparently updated every few seconds when unifi-controller-reborn is running.

I'm not sure of the best way to determine that file's "freshness" from the Pi over the network. I suppose a user script on Unraid could check it, and then send something to the Pi. I like the Pi's script because it sends a single email when one or more services are not responding (listing them), and then an "all clear" email when all are restored.

  • Community Expert

on unraid docker ps would show runnign dockers..

root@omv:~# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

f039d932a21b containrrr/watchtower "/watchtower --sched…" 5 weeks ago Up 14 minutes (healthy) watchtower

root@omv:~#

docker inspect is your friend here...

we could make a watch do like automation check file if exist on a smb share for the pie to look and notify.

we can have unraid user script plugin run docker ps and grep unifi to see fi its running...
and leverage docker based commands...

so you see in my docker ps under status I have them reporting healthy.

we would have to add additional data to the docker template to write and make a health check

example for immich valkey/redis:
healthcheck:

test: redis-cli ping || exit 1

example code later as i will test... for 11 notes unifi "pete asking" maintained unifi docker container:
https://hub.docker.com/r/11notes/unifi

https://github.com/11notes/docker-unifi

per there docker file as it has a health check!
# :: Monitor

HEALTHCHECK --interval=5s --timeout=2s CMD curl -kILs --fail https://localhost:8443

as this docker kinda has a health check built in but not one that reports to unraid docker system...


This can be added for additional leveraging and checks on unraid docker and use with other systems and scripting like watch dog above.

--health-interval=120s --health-timeout=10s --health-retries=2 --health-start-period=600s


image.png

so now when the docker starts is uses a reported docker health check.

root@The-Borg:~# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

6b7efb2476db 11notes/unifi:8.6.9-unraid "/usr/local/bin/entr…" 19 seconds ago Up 18 seconds (health: starting) 0.0.0.0:1900->1900/udp, :::1900->1900/udp, 0.0.0.0:3478->3478/udp, :::3478->3478/udp, 0.0.0.0:6789->6789/tcp, :::6789->6789/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp, 0.0.0.0:8843->8843/tcp, :::8843->8843/tcp, 0.0.0.0:5514->5514/udp, :::5514->5514/udp, 0.0.0.0:10001->10001/udp, :::10001->10001/udp, 0.0.0.0:8880->8880/tcp, :::8880->8880/tcp unifi-controller-reborn

example when it reports unhealth

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

25b09e1130ec 11notes/unifi:8.6.9-unraid "/usr/local/bin/entr…" 7 minutes ago Up 7 minutes (unhealthy) 0.0.0.0:1900->1900/udp, :::1900->1900/udp, 0.0.0.0:3478->3478/udp, :::3478->3478/udp, 0.0.0.0:6789->6789/tcp, :::6789->6789/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp, 0.0.0.0:8843->8843/tcp, :::8843->8843/tcp, 0.0.0.0:5514->5514/udp, :::5514->5514/udp, 0.0.0.0:10001->10001/udp, :::10001->10001/udp, 0.0.0.0:8880->8880/tcp, :::8880->8880/tcp unifi-controller-reborn

as example...
root@The-Borg:~# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

d68859a1c9be 11notes/unifi:8.6.9-unraid "/usr/local/bin/entr…" 40 seconds ago Up 39 seconds (healthy) 0.0.0.0:1900->1900/udp, :::1900->1900/udp, 0.0.0.0:3478->3478/udp, :::3478->3478/udp, 0.0.0.0:6789->6789/tcp, :::6789->6789/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp, 0.0.0.0:8843->8843/tcp, :::8843->8843/tcp, 0.0.0.0:5514->5514/udp, :::5514->5514/udp, 0.0.0.0:10001->10001/udp, :::10001->10001/udp, 0.0.0.0:8880->8880/tcp, :::8880->8880/tcp unifi-controller-reborn

then use a docker inspect command to the docker name:

docker inspect --format '{{.Config.Healthcheck}}' unifi-controller-reborn

# Expect something like:

# {[CMD-SHELL curl -kILs --fail https://localhost:8443] 2m0s 10s 10m0s 2}

image.png

that writes to the smb file... a user script cron every 5,10,15,30 min to check the health status...

  • Community Expert

you can then use unraids sysntofit or built in notfications ssytems... I personly like the pie device this was i tell uptime kuma onteh pie and other things that it cheks are unable to conect or down to notify me..

so witht eh health check added to your extra parm inteh docker...

we cna then have unraid user scrpt plugin custom check and cron a file created for the pie to see latter...

User Script (copy-paste)

In Unraid (Plugins → User Scripts → Add New Script), name it e.g. unifi-health-export.sh, and paste:

#!/bin/bash
# Unraid User Script: Export UniFi container health to an SMB-visible file
# - Preserves the image's built-in HEALTHCHECK (we don't run curl ourselves)
# - Writes a single small status file (KV pairs) + an append-only log
# - Safe for cron: idempotent, atomic writes

set -Eeuo pipefail

### ======== CONFIGURE ME ======== ###
CONTAINER_NAME="unifi-controller-reborn"        # container name (as shown by docker ps)
OUTPUT_DIR="/mnt/user/health/unifi"             # SMB-exposed folder (make/share this as needed)
STATUS_FILE_NAME="unifi.status"                 # simple KV file Pi will read
LOG_FILE_NAME="unifi_health.log"                # append-only log for historical checks
# If your SMB share is different, change OUTPUT_DIR accordingly, e.g.:
# OUTPUT_DIR="/mnt/user/YourShare/health/unifi"
### ======== /CONFIGURE ME ======== ###

STATUS_FILE="${OUTPUT_DIR}/${STATUS_FILE_NAME}"
LOG_FILE="${OUTPUT_DIR}/${LOG_FILE_NAME}"

mkdir -p "${OUTPUT_DIR}"

ts() { date -Iseconds; }  # ISO-8601 timestamp

# --- Detect Docker engine status early ---
if ! docker info >/dev/null 2>&1; then
  ENGINE_STATE="down"
  CONTAINER_STATE="unknown"
  HEALTH_STATE="unknown"
  OK=0
else
  ENGINE_STATE="up"
  # Resolve container id (exact name match)
  CID="$(docker ps -aqf "name=^${CONTAINER_NAME}$" || true)"
  if [[ -z "${CID}" ]]; then
    CONTAINER_STATE="notfound"
    HEALTH_STATE="none"
    OK=0
  else
    # Read container state and health (health may be absent)
    CONTAINER_STATE="$(docker inspect -f '{{.State.Status}}' "${CONTAINER_NAME}" 2>/dev/null || echo unknown)"
    HEALTH_STATE="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "${CONTAINER_NAME}" 2>/dev/null || echo none)"

    # Policy: OK=1 only when container is running AND (health is healthy OR health not defined)
    if [[ "${CONTAINER_STATE}" == "running" ]] && [[ "${HEALTH_STATE}" == "healthy" || "${HEALTH_STATE}" == "none" ]]; then
      OK=1
    else
      OK=0
    fi
  fi
fi

# --- Atomically write the status file (so the Pi never reads a partial write) ---
TMP="$(mktemp)"
{
  echo "WHEN=$(ts)"
  echo "ENGINE=${ENGINE_STATE}"
  echo "CONTAINER=${CONTAINER_NAME}"
  echo "STATE=${CONTAINER_STATE}"    # running|exited|paused|created|notfound|unknown
  echo "HEALTH=${HEALTH_STATE}"      # healthy|unhealthy|starting|none|unknown
  echo "OK=${OK}"                    # 1=good, 0=bad
} > "${TMP}"
mv -f "${TMP}" "${STATUS_FILE}"

# --- Append a one-line log entry (easy to tail on the Pi) ---
echo "$(ts) CONTAINER=${CONTAINER_NAME} STATE=${CONTAINER_STATE} HEALTH=${HEALTH_STATE} ENGINE=${ENGINE_STATE} OK=${OK}" >> "${LOG_FILE}"

What the Pi reads latter:

The status file (e.g., /mnt/user/health/unifi/unifi.status) contains simple key/value lines:

WHEN=2025-11-02T18:20:00-06:00

ENGINE=up

CONTAINER=unifi-controller-reborn

STATE=running

HEALTH=healthy

OK=1

  • a scrpt on teh pie conected to a smb share to read the file at example: /mnt/user/health/unifi/unifi.status
    Your Pi can just parse OK=1 to mean “online & healthy”.

Schedule it (cron examples)

In the User Scripts UI, set Schedule → Custom and use one of these:

  • Every 5 minutes: */5 * * * *

  • Every 10 minutes: */10 * * * *

  • Every 15 minutes: */15 * * * *

  • Every 30 minutes: */30 * * * *

We just read Docker’s view of State.Status and State.Health.Status

Again I don't see the need to do a tcp/udp check.

  • Community Expert

example unraid notfication (if you setup the agents for email, telgram/slac/discord to notfiy you of xyz...

et’s keep UniFi’s built-in HEALTHCHECK and add a User Scripts job that watches Docker’s view of the container and fires an Unraid notification only when something changes (down/unhealthy/recovered). No Pi file—just native notify. (all on unraid....)

Unraid User Script — unifi-health-notify.sh

Paste this into Plugins → User Scripts → Add New Script:

#!/bin/bash
# #####################################
# Name:        UniFi Docker notify v2.0
# Description: Unraid notifications for Docker/UniFi status
#              - Fires an ALERT/WARNING every run while in a bad state
#              - Sends one NORMAL notice on recovery to healthy
# #####################################

set -Eeuo pipefail
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# ---------- Settings ----------
CONTAINER_NAME="unifi-controller-reborn"          # exact name from `docker ps`
GRACE_SECONDS=600                                 # ignore 'starting' for this long after (re)start
STATE_FILE="/tmp/unifi-docker-notify.last"        # remembers the last state to detect recovery
NOTIFY="/usr/local/emhttp/webGui/scripts/notify"  # Unraid notifier path
# -----------------------------

# race-safe (like your syslog script)
if [[ -d "/tmp/${0//\//_}" ]] || ! mkdir "/tmp/${0//\//_}"; then
  echo "Script is already running!"; exit 1
fi
trap 'rmdir "/tmp/${0//\//_}"' EXIT

# helpers
ts()  { date -Iseconds; }
now() { date +%s; }
notify_alert()   { "$NOTIFY" -i "alert"   -s "$1" -d "$2"; }   # red
notify_warning() { "$NOTIFY" -i "warning" -s "$1" -d "$2"; }   # yellow
notify_normal()  { "$NOTIFY" -i "normal"  -s "$1" -d "$2"; }   # green/white

# previous state (for recovery notice only)
PREV=""; [[ -f "$STATE_FILE" ]] && PREV="$(cat "$STATE_FILE")"

# 0) docker CLI missing
if ! command -v docker >/dev/null 2>&1; then
  notify_alert "Docker CLI missing" "Cannot find 'docker' in PATH at $(ts)."
  echo "cli_missing" > "$STATE_FILE"
  exit 0
fi

# 1) engine up?
if ! docker info >/dev/null 2>&1; then
  notify_alert "Docker engine is DOWN" "UniFi check skipped at $(ts)."
  echo "engine_down" > "$STATE_FILE"
  exit 0
fi

# 2) container present?
CID="$(docker ps -aqf "name=^${CONTAINER_NAME}$" || true)"
if [[ -z "$CID" ]]; then
  notify_alert "UniFi container NOT FOUND" "Container '${CONTAINER_NAME}' missing at $(ts)."
  echo "not_found" > "$STATE_FILE"
  exit 0
fi

# 3) status/health/age
STATUS="$(docker inspect -f '{{.State.Status}}' "$CONTAINER_NAME" 2>/dev/null || echo unknown)"
HEALTH="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$CONTAINER_NAME" 2>/dev/null || echo none)"
STARTED_AT="$(docker inspect -f '{{.State.StartedAt}}' "$CONTAINER_NAME" 2>/dev/null || echo "")"
START_EPOCH="$(date -d "$STARTED_AT" +%s 2>/dev/null || echo 0)"
AGE="$(( $(now) - START_EPOCH ))"

# best-effort last health output line
LAST_OUT="$(docker inspect "$CONTAINER_NAME" 2>/dev/null | awk -F'"' '/"Output":/ {o=$4} END{print o}')"

# 4) decide state
# good only when running AND healthy (or none=ok for images w/o healthcheck)
CUR=""
if [[ "$STATUS" != "running" ]]; then
  CUR="status_${STATUS}"                  # e.g. status_exited/paused/restarting/created
elif [[ "$HEALTH" == "healthy" ]]; then
  CUR="healthy"
elif [[ "$HEALTH" == "starting" ]]; then
  CUR=$(( AGE < GRACE_SECONDS )) && CUR="starting_grace" || CUR="starting_stuck"
elif [[ "$HEALTH" == "unhealthy" ]]; then
  CUR="unhealthy"
else
  CUR="nohealth_running"
fi

# 5) notify policy
case "$CUR" in
  healthy)
    # Only tell us when we *recover* from a bad state
    if [[ -n "$PREV" && "$PREV" != "healthy" && "$PREV" != "starting_grace" && "$PREV" != "nohealth_running" ]]; then
      notify_normal "UniFi is HEALTHY" \
"Container: ${CONTAINER_NAME}
Status: ${STATUS}
Health: ${HEALTH}
Uptime: ${AGE}s since ${STARTED_AT}"
    fi
    ;;
  starting_grace)
    # quiet during warmup (change GRACE_SECONDS if you want alerts here)
    ;;
  starting_stuck)
    notify_warning "UniFi still STARTING" \
"Warmup exceeded ${GRACE_SECONDS}s.
Uptime: ${AGE}s
Last health output: ${LAST_OUT}"
    ;;
  unhealthy)
    notify_alert "UniFi UNHEALTHY" \
"health=unhealthy
Uptime: ${AGE}s
Last health output: ${LAST_OUT}"
    ;;
  status_*)
    notify_alert "UniFi not running (${STATUS})" \
"Container '${CONTAINER_NAME}' state=${STATUS}
Last health: ${HEALTH}
Uptime: ${AGE}s since ${STARTED_AT}"
    ;;
  nohealth_running)
    # This image normally *has* a healthcheck; if not, warn each run
    notify_warning "UniFi running (no healthcheck)" \
"Container is running but has no Health object.
State=${STATUS}"
    ;;
esac

# remember last state (for recovery message next run)
echo "$CUR" > "$STATE_FILE"
exit 0

*Fixed script example

image.png

image.png

Schedule it

In User Scripts, set Schedule → Custom and choose one:

  • every 5 minutes: */5 * * * *

  • every 10 minutes: */10 * * * *

  • every 15 minutes: */15 * * * *

  • every 30 minutes: */30 * * * *

(You can also add the script multiple times with different cadences if you like...)

then your setting>notfication can alert you... and you can see a history of its health over time in unraid...

Edited by bmartino1
update unraid sysnotfi script for future use....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.