Last active
November 18, 2024 07:57
-
-
Save rokiden/2de353dc5b5886c418f47fa17c2d18d5 to your computer and use it in GitHub Desktop.
Uptime Kuma desktop notification daemon using notify-send
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Uptime Kuma Notifications | |
[Service] | |
ExecStart=python3 /opt/uptime_notif/uptime_notif.py | |
[Install] | |
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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