Skip to content

Instantly share code, notes, and snippets.

Last active May 31, 2017 07:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
NUT notification to PushOver
#!/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)"
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