-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatus_Check.sh
More file actions
62 lines (41 loc) · 1.46 KB
/
Status_Check.sh
File metadata and controls
62 lines (41 loc) · 1.46 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Location of Script: /etc/init.d/
# Add to Ubuntu startup : sudo crontab -e ---> @reboot /etc/init.d/Script_Name.sh
# Update BOT{ID}:{Token}.
# Update node_file NAME & fix the command line as needed(grep/cut/sed etc').
sleep 5m # wait for the process to start
counter=0
while true
do
node_stat=$(node_file status | grep NodeStartLine | cut -d " " -f 3 | sed 's/,//')
if [[ $node_stat != "active" ]]
then
if [ $counter -lt "3" ]
then
counter=$(( counter+1 ))
date=$(date)
uptime=$(uptime)
curl -s "https://api.telegram.org/BOT{ID}:{Token}/sendMessage?chat_id={}&text=$node_stat"
curl -s "https://api.telegram.org/BOT{ID}:{Token}/sendMessage?chat_id={}&text=$date"
curl -s "https://api.telegram.org/BOT{ID}:{Token}/sendMessage?chat_id={}&text=$uptime"
sleep 2m
else
counter=$(( counter+1 ))
sleep 3m
if [[ $counter -eq 57 ]]
then
counter=0
fi
fi
else
if [[ $counter != 0 ]]
then
curl -s "https://api.telegram.org/BOT{ID}:{Token}/sendMessage?chat_id={}&text=$node_stat"
curl -s "https://api.telegram.org/BOT{ID}:{Token}/sendMessage?chat_id={}&text=$date"
curl -s "https://api.telegram.org/BOT{ID}:{Token}/sendMessage?chat_id={}&text=$uptime"
counter=0
fi
counter=0
sleep 1m
fi
done