Created
December 26, 2019 13:25
-
-
Save somoza/62bb8ef9a7033d5e2466f8310979adfb to your computer and use it in GitHub Desktop.
Bash to check apache status, restart it and send telegram bot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
telegram=(xxxxx, yyyyyy) | |
if ! pidof apache2 > /dev/null | |
then | |
# web server down, restart the server | |
echo "Server down" | |
/etc/init.d/apache2 restart > /dev/null | |
sleep 10 | |
#checking if apache restarted or not | |
if pidof apache2 > /dev/null | |
then | |
for i in "${telegram[@]}" | |
do | |
curl -s -X POST https://api.telegram.org/botxxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyy/sendMessage -d chat_id="$i" -d text="`echo -e '\U0001F525'` Apache stoped on Molib Stage. Automatically restarted succesfully." | |
done | |
else | |
for i in "${telegram[@]}" | |
do | |
curl -s -X POST https://api.telegram.org/botxxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyy/sendMessage -d chat_id="$i" -d text="`echo -e '\U0001F525'` Apache stoped on Molib Stage. Automatically restart failed. Please check manually." | |
done | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment