Created
April 27, 2018 20:47
-
-
Save icasimpan/81d350236a6637729be2a8f8a8a1d232 to your computer and use it in GitHub Desktop.
DIY simple uptime checker via shell
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
### Credentials file '/home/user/.credentials.txt for additional protection be chmod to 600. | |
### Sample creds content: | |
### --user youruser:password_here | |
### This could then be run from cron every 15mins: | |
### */15 * * * * /home/user/monitor.sh | |
### | |
#!/bin/bash | |
site_urls="https://www.google.com http://ismael.casimpan.com/" | |
for each_url in $site_urls; do | |
reply_code=$(curl --config /home/user/.credentials.txt -Is $each_url | grep HTTP | cut -d' ' -f2) | |
if [[ $reply_code != 200 ]]; then | |
$(echo "See user cron /home/user/monitor.sh (ticket XXXX)." | mail -s "$each_url DOWN!" [email protected]) | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'--config' would have this value: