Created
August 7, 2019 10:05
-
-
Save refraction-ray/4904205f157bd79cd23b4a11c5ac2428 to your computer and use it in GitHub Desktop.
A super light-weighted monitoring and alerting tool, if you don't want to configure any of there monitoring tools
This file contains 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 | |
ips=("8.8.8.8" | |
"baidu.com") | |
webs=("http://10.0.0.1:8080") | |
address="[email protected]" | |
for ip in "${ips[@]}"; do | |
r=$(/bin/ping -c3 -W1 "${ip}"|grep received|awk '{print $4}') | |
if [ $r -lt 3 ]; then | |
echo "send mail..." | |
echo "${ip} cannot reached"|/usr/bin/mail -s "alert by stb" $address | |
fi | |
done | |
for web in "${webs[@]}"; do | |
r=$(curl -s "${web}"|grep 401|wc -l) | |
if [ $r == 0 ]; then | |
echo "send mail..." | |
echo "${web} cannot reached"|/usr/bin/mail -s "alert by stb" $address | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment