Add UptimeKuma Notifcations
This commit is contained in:
parent
fdbb478c19
commit
ac8fb45637
20
README.md
20
README.md
@ -10,6 +10,7 @@ services:
|
||||
- '4545:4545'
|
||||
environment:
|
||||
- TZ=America/Chicago # OPTIONAL: Default is UTC
|
||||
- ENABLE_KUMA_NOTIFICATIONS=false # Whether or not to setup UptimeKuma SMS notifications
|
||||
- RADARR_HOST_URL=http://127.0.0.1:7878 # Change to your radarr host
|
||||
- RADARR_API_KEY=apikeyhere # Found by navigating to Settings > General
|
||||
- SMS_SERVICE=servicename # Currently only supporting Telnyx
|
||||
@ -21,16 +22,20 @@ services:
|
||||
#### Run the container in non-daemon mode, you will get an error stating that there are variables that need to be set within the `config.yaml` file, this file is in the internal path of `/data/config.yaml`. Go into that file and being setting the variables that appear for you within that file. Note that every single entry must have a value, the only optional value is `home_domain` but requires `null` at the very least (this is also the default).
|
||||
|
||||
### 3. What Does Every Value in config.yaml Mean?
|
||||
- #### `IMPORTANT NOTE` ALL values that contain phone numbers should be placed within single quotation marks (e.g. '+18005269856, +18005247852, +18002365874').
|
||||
|
||||
- #### `quality_profile_id` There is a commented list of profiles that exist within your Radarr server. The list contains the profile id followed by the profile name. This value should be the single integer id of the quality profile that you would like movies to be added under.
|
||||
|
||||
- #### `home_domain` Defaults to null meaning 404/405 errors will just return the error to the browser. Replace this will a full URL if you would like those errors to be redirected to your website (e.g. https://pkrm.dev)
|
||||
|
||||
- #### `api_number` The number given to you by your SMS service, in international format, and in ' ' (e.g. '+18005282589')
|
||||
- #### `api_number` The number given to you by your SMS service, in international format, and in (e.g. '+18005282589')
|
||||
|
||||
- #### `valid_senders` Comma-space separated list of numbers that are allowed to send commands, this stops random numbers from being allowed to add movies to Radarr. This also must be in international format (e.g. +18005269856, +18005247852, +18002365874). If you have only 1 sender here, that must be put within ' '.
|
||||
- #### `valid_senders` Comma-space separated list of numbers that are allowed to send commands, this stops random numbers from being allowed to add movies to Radarr. This also must be in international format (e.g. '+18005269856, +18005247852, +18002365874').
|
||||
|
||||
- #### `root_folder_path` The folder path defined in your Radarr server. Find this value by logging into your Radarr server and navigate to Settings > Media Management, at the bottom of this page will be your root folder path (copy the full path!)
|
||||
|
||||
- #### `notif_receivers` and `authorization_header_token` Only appear if you have `ENABLE_KUMA_NOTIFICATIONS` set to true. `notif_receivers` is a list of phone numbers (e.g. '+18005269856, +18005247852, +18002365874') that will receive the notifications on service statuses. `authorization_header_token` other things that find the /kuma route cant send POST requests there - the value can be anything you choose, the default is `uptimekumaauthtoken`. For help on setting up UptimeKuma, see `step 6`.
|
||||
|
||||
- #### The last values will vary dependant on your SMS service, but they are just the authentication values for your service.
|
||||
|
||||
### 4. Setup your Domain
|
||||
@ -41,7 +46,16 @@ services:
|
||||
### 5. Add the Domain
|
||||
#### Once you have configured your domain or router go to your sms services console and buy a number for SMS messaging. Once you buy the number you need to configure how it handles incoming messages, there you should be able to have the service send a POST request to a webhook for incoming message. You should overwrite or set this value to `http(s)://yourdomain.com/incoming` or `http://yourip:port/incoming`
|
||||
|
||||
### 6. Further Help
|
||||
### 6. UptimeKuma Setup
|
||||
#### If you chose to enable UptimeKuma notifications and have already setup the container, please continue - otherwise, set the values in the config first and make the container is working. First go to your UptimeKuma dashboard, go to Settings > Notifications, then click `Setup Notification`. For notification type, choose `Webhook`, give it whatever name, `Post URL` should be set to `http(s)://ip:port/kuma` or `http(s)yourdomain.com/kuma`. Finally check the `Additional Headers` switch and paste in this -
|
||||
```
|
||||
{
|
||||
"Authorization": "YOURAUTHTOKENVALUEHERE"
|
||||
}
|
||||
```
|
||||
#### Finally, choose whether or not to have the notification be enabled by default or whether to apply this notification to all current monitors.
|
||||
|
||||
### 7. Further Help
|
||||
#### Please open an issue if you need help with any part of setting this up (I know the docs/instructions aren't great). You can also email me at [contact@pkrm.dev](mailto:contact@pkrm.dev)
|
||||
|
||||
|
||||
|
@ -4,9 +4,10 @@ import requests
|
||||
|
||||
supported_sms_services = ['telnyx', 'twilio']
|
||||
|
||||
sms_service = str(os.environ['SMS_SERVICE']).lower()
|
||||
radarr_host_url = str(os.environ['RADARR_HOST_URL'])
|
||||
radarr_api_key = str(os.environ['RADARR_API_KEY'])
|
||||
enable_kuma_notifications = str(os.environ['ENABLE_KUMA_NOTIFICATIONS']).lower()
|
||||
sms_service = str(os.environ['SMS_SERVICE']).lower()
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
@ -26,6 +27,11 @@ try:
|
||||
api_number = str(file['api_number'])
|
||||
val_nums = str(file['valid_senders'])
|
||||
root_folder_path = str(file['root_folder_path'])
|
||||
|
||||
if enable_kuma_notifications == 'true':
|
||||
notif_receivers_nums = str(file['notif_receivers'])
|
||||
authorization_header_token = str(file['authorization_header_token'])
|
||||
|
||||
if sms_service not in supported_sms_services:
|
||||
print(f'{sms_service} is not a supported SMS service. Please choose from the supported list: {supported_sms_services}')
|
||||
exit()
|
||||
@ -58,9 +64,14 @@ if value_not_set:
|
||||
|
||||
f.write("quality_profile_id:\n")
|
||||
f.write("home_domain: null\n")
|
||||
f.write("api_number:\n")
|
||||
f.write("valid_senders:\n")
|
||||
f.write("api_number: ''\n")
|
||||
f.write("valid_senders: ''\n")
|
||||
f.write("root_folder_path:\n")
|
||||
|
||||
if enable_kuma_notifications == 'true':
|
||||
f.write("notif_receivers: ''\n")
|
||||
f.write("authorization_header_token: uptimekumaauthtoken\n")
|
||||
|
||||
if sms_service not in supported_sms_services:
|
||||
print(f'{sms_service} is not a supported SMS service. Please choose from the supported list: {supported_sms_services}')
|
||||
exit()
|
||||
|
@ -39,6 +39,39 @@ valid_senders = []
|
||||
for number in val_nums.split(', '):
|
||||
valid_senders.append(number)
|
||||
|
||||
if notif_receivers_nums:
|
||||
notif_receivers = []
|
||||
|
||||
for number in notif_receivers_nums.split(', '):
|
||||
notif_receivers.append(number)
|
||||
|
||||
|
||||
"""
|
||||
POST request route to accept incoming notifications from UptimeKuma
|
||||
regarding the status of certain services. Messages are sent to the
|
||||
'notif_receivers' list whenever a service goes down or comes back up.
|
||||
"""
|
||||
@app.route('/kuma', methods=['POST'])
|
||||
def api():
|
||||
# Make sure the request is coming from UptimeKuma (Configured to use this authorization token)
|
||||
if flask.request.headers.get('Authorization') == authorization_header_token:
|
||||
data = flask.request.get_json()
|
||||
|
||||
if data['heartbeat']['status'] == 0:
|
||||
message = f"❌ {data['monitor']['name']} is down!"
|
||||
|
||||
elif data['heartbeat']['status'] == 1:
|
||||
message = f"✅ {data['monitor']['name']} is up!"
|
||||
|
||||
for number in notif_receivers:
|
||||
create_message(number, message)
|
||||
|
||||
return 'OK'
|
||||
# If the request does not contain the correct authorization token, return 401
|
||||
else:
|
||||
return 'Unauthorized', 401
|
||||
|
||||
|
||||
"""
|
||||
POST request route to accept incoming message from the SMS API,
|
||||
then process the incoming message in order to see if it is a valid command
|
||||
|
@ -5,9 +5,10 @@ services:
|
||||
- '4545:4545'
|
||||
environment:
|
||||
- TZ=America/Chicago # OPTIONAL: Default is UTC
|
||||
- ENABLE_KUMA_NOTIFICATIONS=false # Whether or not to setup UptimeKuma SMS notifications
|
||||
- RADARR_HOST_URL=http://127.0.0.1:7878 # Change to your radarr host
|
||||
- RADARR_API_KEY=apikeyhere # Found by navigating to Settings > General
|
||||
- SMS_SERVICE= # Currently only supporting Telnyx and Twilio
|
||||
volumes:
|
||||
- /local/file/path:/data
|
||||
- /loca/file/path:/data
|
||||
image: packetparker/messagearr:latest
|
Reference in New Issue
Block a user