Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joet3ch/1332526 to your computer and use it in GitHub Desktop.
Save joet3ch/1332526 to your computer and use it in GitHub Desktop.
#!/bin/bash
SOURCE="monitor01.t3ch.com"
SUBJECT="Network Alert: Node unreachable"
TO="youremail@t3ch.com"
MESSAGE="/tmp/network_monitor-message.txt"
for ipaddr in `cat nodes.list`;
do
if ! ping -c 1 $ipaddr
then
echo "Node: $ipaddr" > $MESSAGE
echo "When: `date`" >> $MESSAGE
echo "Source: $SOURCE" >> $MESSAGE
/usr/bin/mail -s "$SUBJECT" "$TO" < $MESSAGE
rm $MESSAGE
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment