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