-
Notifications
You must be signed in to change notification settings - Fork 3
/
notify.sh
36 lines (27 loc) · 909 Bytes
/
notify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
#My dummy script to check Humanode services
#Default message text
message="!!! ATTENTION !!! You must renew your authentification token in Humanode"
humanode=$(ps aux | grep humanode)
ngrok=$(ps aux | grep ngrok)
#Check if we missed a "consensus" word in log
alert=$(journalctl -u humanode -S "$(date -d "-10 minutes" +%Y"-"%m"-"%d" "%T)" | grep consensus)
if [ -z "$alert" ]
then
systemctl restart humanode && \
#Wait for humanode startup
sleep 10 && \
#Get auth url from log
link=$(journalctl -u humanode -S "$(date -d "-10 seconds" +%Y"-"%m"-"%d" "%T)" | grep -o 'https://[^"]*')
telegram-send "$message Please visit $link"
fi
#Check if humanode service is working
if [ -z "$humanode" ]
then
telegram-send "!!! Humanode daemon is not running !!!"
fi
#Check if ngrok service is working
if [ -z "$ngrok" ]
then
telegram-send "!!! Ngrok daemon is not running !!!"
fi