Last active
June 21, 2023 17:42
-
-
Save HorlogeSkynet/24b8fac534f0f128a6f4fb7ab3fa8ad2 to your computer and use it in GitHub Desktop.
A simple script to notify an admin by SMS if its ping-answering server is down, using the FREE MOBILE SMS API
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
#!/usr/bin/env bash | |
# @Author: HorlogeSkynet | |
# @Created: 2017-08-21 | |
# @Updater: 2020-04-14 | |
# @Brief: A simple script to notify an admin by SMS if its ping-answering server is down, using the FREE MOBILE SMS API | |
# In order to use it, add to your Crontab : `0 */1 * * * /bin/bash /path/to/script/checkServer.sh [YOUR.SERVER.HOSTNAME]` | |
FREE_USR="YOUR_FREE_USER" | |
FREE_PWD="YOUR_FREE_PASSWORD" | |
SERVER=${1:-YOUR.SERVER.HOSTNAME} | |
datetime="$(date +'%d/%m/%Y %H:%M:%S')" | |
if ! ping -c 2 -i 5 "$SERVER" > /dev/null 2>&1; then | |
wget \ | |
-q \ | |
"https://smsapi.free-mobile.fr/sendmsg?user=${FREE_USR}&pass=${FREE_PWD}&msg=${datetime} -- ${SERVER} is down !" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment