Skip to content

Instantly share code, notes, and snippets.

@rokiden
Last active November 18, 2024 07:57
Show Gist options
  • Save rokiden/2de353dc5b5886c418f47fa17c2d18d5 to your computer and use it in GitHub Desktop.
Save rokiden/2de353dc5b5886c418f47fa17c2d18d5 to your computer and use it in GitHub Desktop.
Uptime Kuma desktop notification daemon using notify-send
Uptime Kuma running on the same machine in docker container.
Kuma Setup:
Settings - Setup Notification:
Notification Type: Webhook
Friendly Name: uptime_notif
Post URL: http://172.17.0.1:65000
Request Body: Preset - application/json
[Unit]
Description=Uptime Kuma Notifications
[Service]
ExecStart=python3 /opt/uptime_notif/uptime_notif.py
[Install]
WantedBy=default.target
import json
import subprocess
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
class Handler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
o = json.loads(self.rfile.read(content_length))
subprocess.call(['/usr/bin/notify-send', 'Uptime Kuma', o['msg']])
self.send_response(200)
self.end_headers()
if __name__ == "__main__":
server = HTTPServer(("0.0.0.0", 65000), Handler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment