๐Ÿ”Œ Power Reset Monitoring with Uptime Kuma

Ronald BartelsRonald Bartels
3 min read

Power instability is a reality โ€” whether you're dealing with remote edge routers, Raspberry Pis, or industrial IoT sensors. Wouldn't it be great to know when a device has unexpectedly rebooted due to power loss? ๐Ÿ’ฅ๐Ÿ”‹

Using Uptime Kuma and a little scripting magic, you can turn your monitoring host into a central watchdog that knows when your devices go down โ€” and when they come back.

To monitor actual devices being down requires separate monitors. This just identifies outages due to power resets.


๐ŸŽฏ What Youโ€™ll Achieve

You'll implement:

  1. A device-side script (custom-reboot.sh) that notifies Kuma of a reboot.

  2. A monitoring-host script (custom10.sh) that clears the alert every 10 minutes else the monitor will always be red/down.

  3. A push-based Uptime Kuma monitor to receive and visualise these events.


๐Ÿงฉ How It Works

  • When a device reboots, it sends a DOWN status to Kuma using a unique push URL.

  • Every 10 minutes, the Kuma host pings back with a UP status, effectively clearing any stale reboot alerts.

  • The notification identifies power outages that have occurred for purposed of causation.


๐Ÿ“ Device-Side Setup: custom-reboot.sh

Install this script on each remote device (router, server, IoT box):

#!/bin/bash

# Get the device hostname
HOSTNAME=$(hostname)

# URL encode the hostname
ENCODED_HOSTNAME=$(printf '%s' "$HOSTNAME" | jq -s -R -r @uri)

# Notify Kuma of reboot
URL="https://claymore.amastelek.com/api/push/ktqNBtJK13?status=down&msg=${ENCODED_HOSTNAME}&ping=1"
curl -s "$URL"

๐Ÿ” Trigger on Boot

Add this to the deviceโ€™s crontab:

@reboot sleep 180 && /usr/local/sbin/custom-reboot.sh

โฑ๏ธ 3-minute delay ensures network is up before script runs.


๐Ÿ–ฅ๏ธ Kuma Host Setup: custom10.sh

This script is installed and scheduled only on the Uptime Kuma host. It acts as a clearing heartbeat by sending an UP status to the Kuma push monitor.

#!/bin/bash

# Get the Kuma host's hostname
HOSTNAME=$(hostname)

# URL encode the hostname
ENCODED_HOSTNAME=$(printf '%s' "$HOSTNAME" | jq -s -R -r @uri)

# Send heartbeat UP to clear any stale reboots
URL="https://claymore.amastelek.com/api/push/ktqNBtJK13?status=up&msg=${ENCODED_HOSTNAME}&ping=0"
curl -s "$URL"

โฒ๏ธ Schedule Every 10 Minutes

Add to crontab on the Uptime Kuma server:

*/10 * * * * /usr/local/sbin/custom10.sh

๐Ÿ“ก Creating Push Monitors in Uptime Kuma

For each device you want to monitor:

  1. Go to Uptime Kuma โ†’ Add New Monitor

  2. Select Push Monitor

  3. Copy the Push URL

  4. Insert that URL into both custom-reboot.sh (device) and custom10.sh (Uptime Kuma host)


๐Ÿ” What Youโ€™ll See in Uptime Kuma

  • A reboot = a DOWN spike, tagged with the hostname

  • A UP alert comes within 10 minutes, marking systems as up.

๐Ÿ“Š You get visual logs of reboot frequency.


โœ… Summary

You now have a lightweight, reliable mechanism to detect power-related reboots across devices using:

๐Ÿ”Œ Uptime Kuma's Push Monitor
๐Ÿ“Ÿ Device-side cron-based scripts
๐Ÿง  Centralised clearing via the Kuma host

No agents. No overhead. Just results. ๐ŸŽฏ

10
Subscribe to my newsletter

Read articles from Ronald Bartels directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ronald Bartels
Ronald Bartels

Driving SD-WAN Adoption in South Africa