Skip to content

Commit

Permalink
Add support for pushover notification
Browse files Browse the repository at this point in the history
  • Loading branch information
diogopms committed Feb 5, 2020
1 parent 3c07937 commit b7b60f6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ docker run -it \
-p 2812:2812 \
-v $(pwd)/monitrc:/etc/monitrc \
-e "SLACK_URL=<SLACK_URL>" \
-e "PUSH_OVER_TOKEN=<PUSH_OVER_TOKEN>" \
-e "PUSH_OVER_USER=<PUSH_OVER_USER>" \
diogopms/monit-docker-kubernetes
```

### Example monitrc
### Example monitrc (Slack)

```
set daemon 20
set log syslog
# Web interface
# set httpd port 2812 and allow admin:monit
check host <Monitor name> with address <URL>
if failed
Expand All @@ -49,6 +53,31 @@ check host <Monitor name> with address <URL>
EOF
```

### Example monitrc (Pushover)

```
set daemon 20
set log syslog
# Web interface
# set httpd port 2812 and allow admin:monit
check host <Monitor name> with address <URL>
if failed
port 443 protocol https
request /route
status = 400
content = "XPTO"
for 2 cycles
then exec "/bin/pushover"
else if succeeded then exec "/bin/pushover"
EOF
```

### Supported notifications

- [Slack](https://www.slack.com)
- [Pushover](https://pushover.net)

### Troubleshooting

If when starting Monit returns the following message: `The control file '/etc/monitrc' permission 0755 is wrong, maximum 0700 allowed`, simply give the appropriate permissions to _monitrc_: `chmod 700 monitrc`.
12 changes: 12 additions & 0 deletions pushover
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [[ -z "${PUSH_OVER_TOKEN}" || -z "${PUSH_OVER_USER}" ]]; then
echo "Required credentials <PUSH_OVER_TOKEN|PUSH_OVER_USER"
exit 1
fi

curl -s \
-F "token=$PUSH_OVER_TOKEN" \
-F "user=$PUSH_OVER_USER" \
--form-string "message=[Monit] $MONIT_SERVICE - \
$MONIT_DESCRIPTION" https://api.pushover.net/1/messages.json

0 comments on commit b7b60f6

Please sign in to comment.