-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMuonBot.sh
37 lines (22 loc) · 1.06 KB
/
MuonBot.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
37
#!/bin/bash
status=$(curl -s http://localhost:8012/status | jq -r '.network.nodeInfo.active')
ip_address=$(hostname -I | awk '{print $1}')
if [ "$status" = "false" ]; then
message="IP Server: $ip_address, node status: false"
curl -s -X POST \
-H 'Content-Type: application/json' \
-d "{\"chat_id\": \"459515129\", \"text\": \"$message\"}" \
https://api.telegram.org/bot6570530801:AAFrdXFIOBIJmRTt54Sa5SbDtGAwTpBiuJ0/sendMessage
else
echo "Статус не активний"
detailed_status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8012/status)
if [ "$detailed_status" != "200" ]; then
message="IP Server: $ip_address, HTTP error code: $detailed_status"
curl -s -X POST \
-H 'Content-Type: application/json' \
-d "{\"chat_id\": \"459515129\", \"text\": \"$message\"}" \
https://api.telegram.org/bot6570530801:AAFrdXFIOBIJmRTt54Sa5SbDtGAwTpBiuJ0/sendMessage
else
echo "Статус: $status"
fi
fi