Bachelor Tech
  • Home
  • Tutorials
  • Tips
  • Portfolio
  • About Jan
  • Contact Jan

5. Bonus: Add UPS monitoring to Uptime Kuma

by Jan Bachelor October 28, 2025

Would it not be nice to also get an alert via UptimeKuma if power has gone down? This is an ideal case for a passive (push) monitor that would go from your RPi to regularly report the state.

  • On your UptimeKuma instance:
  • Click the “Add New Monitor” button.
  • Fill out the form:
  • Monitor Type: Select “Push”.
  • Friendly Name: UPS Battery Status
  • Heartbeat Interval: 70 (This means if the Pi fails to check in for 70 seconds, the monitor will go “Down”).
  • After you select “Push,” Uptime Kuma will generate a Push URL. It will look something like this: http://A.B.C.D:3001/api/push/LzGjP4k9q
  • Copy this URL up to the code (not the part after ?).
  • Keep it open and save it once the crontab job (later on) is set up.
Create a new Uptime Kuma passive push monitor.
Create a push monitor in Uptime Kuma and save the code in the URL.
  • On your RPI:
sudo -i
nano /usr/local/sbin/push_ups_to_kuma.sh

#!/bin/bash

# --- CONFIGURATION ---
PUSH_URL="<http://A.B.C.D:3001/api/push/CODE>"
#PUSH_URL="<http://192.168.8.60:3001/api/push/nXndhcQRH7ohAw9Ip9nOP3BMk9kcf2zr>"

# Full paths for all commands (cron-safe)
APCACCESS_CMD="/usr/sbin/apcaccess"
GREP_CMD="/usr/bin/grep"
AWK_CMD="/usr/bin/awk"
CURL_CMD="/usr/bin/curl"

# Get the raw status text (e.g., "ONLINE" or "ONBATT")
STATUS_MSG=$($APCACCESS_CMD | $GREP_CMD "STATUS" | $AWK_CMD '{print $3}')

# Get the battery value (per your UPS model)
BATT_VAL=$($APCACCESS_CMD | $GREP_CMD "BCHARGE" | $AWK_CMD '{print $3}')

# Set as 'up' only if battery is 'ONLINE'
KUMA_STATUS="up"
if [ "$STATUS_MSG" != "ONLINE" ]; then
    KUMA_STATUS="down"
fi

echo "Sending to Kuma: Kuma Status=${KUMA_STATUS}, UPS Status=${STATUS_MSG}, Battery=${BATT_VAL}%"

# Send the data to Uptime Kuma
$CURL_CMD \\
    --get \\
    --data-urlencode "status=${KUMA_STATUS}" \\
    --data-urlencode "msg=${STATUS_MSG}, battery at ${BATT_VAL}%." \\
    "$PUSH_URL"
A screenshot from nano that showcases the push for UptimeKuma.
Our push script for UptimeKuma
  • Make the script executable:
chmod +x /usr/local/sbin/push_ups_to_kuma.sh
  • Add it to crontab to run every minute:
crontab -e

# Send UPS status to Uptime Kuma every minute
* * * * * /usr/local/sbin/push_ups_to_kuma.sh >/dev/null 2>&1
  • Ensure the UptimeKuma monitor is saved and watch the magic happen 😇
Uptime Kuma showing the battery percentage in its status update.
Demonstration of the push monitor running in Uptime Kuma

Ok, we are ready for a battery test at last – let’s see what happens when we unplug the power!

4. Prepare onbaterry and offbatery APC scripts
6. Run a UPS drain test!
Go back to course overview: Automate Graceful Shutdown & Wake on LAN for Proxmox with RPi (APC)

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 FacebookWhatsappEmail

Course Steps

  1. 1. Automated Proxmox UPS Shutdown Process - Goals & Installation
  2. 2. Configure apcupsd, SSH keys and SMTP
  3. 3. Prepare a Script of Scripts for automated shutdown of Proxmox hosts
  4. 4. Prepare onbaterry and offbatery APC scripts
  5. 5. Bonus: Add UPS monitoring to Uptime Kuma
  6. 6. Run a UPS drain test!
  7. 7. Add Wake-on-LAN to automatically wake up your hosts!
  8. 8. GitOps - manage your shutdown scripts with Gitea

Other courses

Create an automated Gravity workflow that will allow...

January 19, 2024

Dynamically Populate Gravity Forms from Google Sheets (GSheets...

March 16, 2021

Concur Alternative: Import Employees’ Credit Card Expenses to...

January 19, 2024

Turn your Raspberry Pi into a Proxmox Backup...

July 13, 2025

Install iRedMail Mail Server As Proxmox VM With...

October 31, 2024

Recent Posts

  • How to get LXC containers for Proxmox outside of ready-made templates

  • How to join two Proxmox nodes into a cluster (PVE 8.x)

  • How to Rename a Proxmox Node

Facebook Twitter Instagram Pinterest Linkedin Youtube

All Rights Reserved. The theme was customized from Soledad, see PenciDesign

Bachelor Tech
  • Home
  • Tutorials
  • Tips
  • Portfolio
  • About Jan
  • Contact Jan