Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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