removed jq depdency, added HTTP codes, removed unknown error
This commit is contained in:
parent
8e268b6480
commit
104a9f63b0
@ -4,7 +4,7 @@
|
||||
|
||||
## Getting started.
|
||||
### Requriements
|
||||
`curl` `jq` `screen`
|
||||
`curl` `screen`
|
||||
- Install with whatever package manager you use.
|
||||
- Make SURE they are installed before continuing!
|
||||
### Clone repo and Configure
|
||||
|
26
bml-status-tg-bot
Normal file → Executable file
26
bml-status-tg-bot
Normal file → Executable file
@ -1,27 +1,25 @@
|
||||
#!/bin/bash
|
||||
source .env
|
||||
|
||||
STATUS_OLD=$(curl -s $BML_URL/login | jq .code)
|
||||
COUNT=0
|
||||
while true;
|
||||
do
|
||||
|
||||
STATUS=$(curl -s $BML_URL/login | jq .code)
|
||||
if [ "$STATUS" = "0" ]
|
||||
COUNT=$(echo $[$COUNT+1])
|
||||
STATUS=$(curl -si $BML_URL/login | head -n1 | awk '{print $2}')
|
||||
if [ "$STATUS" = "200" ]
|
||||
then
|
||||
TGTEXT="🟢BML%20Online"
|
||||
elif [ "$STATUS" = "37" ]
|
||||
then
|
||||
TGTEXT="🔴BML%20Down"
|
||||
TEXT="🟢BML Online"
|
||||
else
|
||||
TGTEXT="Unknown%20Error"
|
||||
TEXT="🔴BML Down"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$STATUS" != "$STATUS_OLD" ]
|
||||
then
|
||||
STATUS_OLD=$STATUS
|
||||
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT
|
||||
if [ "$COUNT" != "1" ]
|
||||
then
|
||||
TGTEXT=$(echo Status: $TEXT%0ACode: HTTP $STATUS | sed "s/ /%20/g")
|
||||
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=${TGTEXT}
|
||||
fi
|
||||
|
||||
fi
|
||||
echo ""; echo "";echo Status: $TEXT;echo Code: $STATUS;echo Count: $COUNT; echo Telegram: $TGTEXT;echo ""
|
||||
sleep $DELAY
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user