Last active
May 31, 2017 07:50
-
-
Save gsemet/a170111772e262522e5515439faf5581 to your computer and use it in GitHub Desktop.
NUT notification to PushOver
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import os | |
import sys | |
from pushover import init | |
from pushover import Client | |
USER_KEY = "xxxxxxxxxxxxxxxx" | |
APP_TOKEN = "xxxxxxxxxxxxxxxx" | |
message = '' | |
if len(sys.argv) > 1: | |
message = sys.argv[1].strip() | |
notify_type = os.environ.get('NOTIFYTYPE', "") | |
if notify_type == "ONBATT": | |
message = "Connected UPS has entered battery mode" | |
elif notify_type == "ONLINE": | |
message = "Connected UPS has returned to AC mode" | |
elif not message: | |
message = "(no message)" | |
init(APP_TOKEN) | |
print("Sending message: " + message) | |
Client(USER_KEY).send_message(message, title="Server Name") | |
# Test with upsdrvctl -t shutdown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment