Skip to content

Commit 2886efc

Browse files
committed
added Gotify integration
1 parent 81cceac commit 2886efc

File tree

6 files changed

+591
-23
lines changed

6 files changed

+591
-23
lines changed

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Monitors Docker (MONitors dOCKER) containers and alerts on 'state' change.
1212
- Telegram
1313
- Pushbullet
1414
- Pushover
15-
- Discord (via webhooks)
15+
- Discord
1616
- Ntfy
1717
- Slack
18-
18+
- Gotify
1919

2020
## Future Considerations
2121
- Additional messaging platform support
@@ -33,11 +33,11 @@ services:
3333
# DOCKER_HOST: tcp://docker-socket-proxy:2375
3434
# Optional label to preface messages. Handy if you are running multiple versions of Monocker
3535
SERVER_LABEL: 'Your server name'
36-
# Optional avatar image URL to add to messages. Handy if you are running Monocker on different machines
37-
# - supported by discord & ntfy (mobile app) & slack
38-
SERVER_AVATAR: ''
36+
# Optional avatar image URL to add to messages. Handy if you are running Monocker on different machines (discord, ntfy, and slack)
37+
SERVER_AVATAR: 'https://content.invisioncic.com/u329766/monthly_2024_05/monocker.png.ba5ffdb390b627097d2a53645cf87350.png'
3938
# Specify the messaging platform and details, or leave blank if only wanting container logs (pick one only)
4039
MESSAGE_PLATFORM: 'telegram@your_bot_id@your_chat_id'
40+
# MESSAGE_PLATFORM: 'gotify@app_token'
4141
# MESSAGE_PLATFORM: 'pushbullet@your_api_key@your_device_id'
4242
# MESSAGE_PLATFORM: 'pushover@your_user_key@your_app_api_token'
4343
# MESSAGE_PLATFORM: 'discord@webhook_url'
@@ -54,12 +54,10 @@ services:
5454
PERIOD: 30
5555
# [Optional] - Supress startup messages from being sent. Default is false
5656
DISABLE_STARTUP_MSG: 'false'
57-
5857
## ADVANCED NTFY SETTINGS
5958
#CUSTOM_NTFY_SERVER: 'https://custom.ntfy.com' # use your own NTFY server
6059
#NTFY_USER: 'user' # use a username and password to login (on ntfy.sh or your own server. Option if you have your own server open)
6160
#NTFY_PASS: 'password'
62-
6361
# [optional] - adds SHA ID for all container references. 'true' or 'false' (default)
6462
SHA: 'false'
6563
volumes:

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
# MESSAGE_PLATFORM: 'pushbullet@your_api_key@your_device_id'
2020
# MESSAGE_PLATFORM: 'pushover@your_user_key@your_app_api_token'
2121
MESSAGE_PLATFORM: 'discord@webhook_url'
22+
# MESSAGE_PLATFORM: 'gotify@app_token'
2223
# MESSAGE_PLATFORM: 'ntfy@topic_title'
2324
# MESSAGE_PLATFORM: 'slack@bot_user_oauth_token@your_chat_id'
2425
# MESSAGE_PLATFORM: ''

index.js

+27-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Pushover from 'node-pushover';
77
import { Webhook } from 'discord-webhook-node';
88
import { NtfyClient } from 'ntfy';
99
import { WebClient } from '@slack/web-api';
10+
import { gotify } from 'gotify';
11+
1012
process.on('warning', (warning) => {
1113
console.log(warning.stack);
1214
});
@@ -50,6 +52,7 @@ let runClock;
5052
console.log("-------------------------------------------------------");
5153
console.log(" Monocker - MONitor dOCKER container states");
5254
console.log(" Developed by Matt Petersen - Brisbane Australia");
55+
console.log(" Donate: https://www.paypal.com/paypalme/thanksmp")
5356
console.log(" ");
5457
console.log(" Version: " + pjson.version);
5558
console.log("-------------------------------------------------------");
@@ -80,6 +83,16 @@ async function sendPushbullet(title, message) {
8083
});
8184
}
8285

86+
async function sendGotify(title, message) {
87+
await gotify({
88+
server: msgDetails[1],
89+
app: msgDetails[2],
90+
title: title,
91+
message: message,
92+
priority: 5
93+
});
94+
}
95+
8396
async function sendPushover(title, message) {
8497
var push = new Pushover({
8598
token: msgDetails[2],
@@ -174,6 +187,9 @@ async function send(message) {
174187
case "slack":
175188
sendSlack(title, message);
176189
break;
190+
case "gotify":
191+
sendGotify(title, message);
192+
break;
177193
case "default":
178194
// do nothing
179195
break;
@@ -234,15 +250,14 @@ async function list() {
234250
}
235251
if (ONLY_OFFLINE_STATES == 'true') {
236252
if (offlineStates.includes(c.State) || offlineStates.includes(c.State + " " + hcStatus)) {
237-
console.log(" - " + output);
253+
console.log(" - " + output);
238254
//send(output);
239255
messages += output + "\r\n";
240256
}
241257
}
242258
else {
243259
console.log(" - " + output);
244260
//send(output);
245-
console.log('*****' + output);
246261
messages += output + "\r\n";
247262
}
248263
}
@@ -257,16 +272,16 @@ async function list() {
257272
console.log(" - Currently monitoring " + newConArray.length + " (running) containers");
258273
if(DISABLE_STARTUP_MSG.toLowerCase()!='true'){
259274
//send("Currently monitoring " + newConArray.length + " (running) containers");
260-
messages =`Monitoring started
261-
-- Version: ` + pjson.version + `
262-
-- Messaging platform: ` + MESSAGE_PLATFORM.split("@")[0] +`
263-
-- Polling period: ` + PERIOD + ` seconds` +`
264-
-- Only offline state monitoring: ` + ONLY_OFFLINE_STATES +`
265-
-- Only include labelled containers: ` + LABEL_ENABLE +`
266-
-- Do not monitor 'Exited': ` + EXCLUDE_EXITED +`
267-
-- Disable Startup Messages: ` + DISABLE_STARTUP_MSG +`
268-
-- Display SHA ID: ` + SHA +`
269-
`;
275+
messages ="Monitoring started" + `
276+
- Version: ` + pjson.version + `
277+
- Messaging platform: ` + MESSAGE_PLATFORM.split("@")[0] +`
278+
- Polling period: ` + PERIOD + ` seconds` +`
279+
- Only offline state monitoring: ` + ONLY_OFFLINE_STATES +`
280+
- Only include labelled containers: ` + LABEL_ENABLE +`
281+
- Do not monitor 'Exited': ` + EXCLUDE_EXITED +`
282+
- Disable Startup Messages: ` + DISABLE_STARTUP_MSG +`
283+
- Display SHA ID: ` + SHA +`
284+
`;
270285
messages += "Currently monitoring " + newConArray.length + " (running) containers" + "\r\n";
271286
}
272287
isFirstRun=false;

0 commit comments

Comments
 (0)