Script to notify if a computer shuts down

cticompserv

Registered
I am in need of a method to contact a specific Mac, either by ping or an ssh session or some other means, and notify me if the computer is offline. I know I can simply ping it forever but that seem messy and doesn't give a decent notification. I would like either email or a pop-up with the information.

Thanks,
Kent
 
Here is a script I use. I run it from cron every 10 minutes. This script pings all the domains/computers list in a text file called 'domain_list.txt' and if it fails sends a message to any email, or cell phone in the variable 'contact_list'.

Good Luck.

#!/usr/local/bin/bash
contact_list="xxx@xxx.com,phone#@vtext.com,phone#@tmomail.net"

for file in `cat /usr/home/xxx/bin/domain_list.txt`
do
PING_TEST=""
PING_TEST=`telnet $file 80 < /usr/home/tom/bin/ping.txt 2>&1 | grep 'Unable to connect' | wc -l `

#echo PING_TEST $PING_TEST

if [ $PING_TEST -ne 0 ]
then
date | mail -s "$file OFFLINE" $contact_list
fi
done
 
BTW: I should not that the above script does a 'telnet xxx 80' instead of 'ping' because the server that runs the script has had the 'ping' command removed for 'security' reasons.
 
Back
Top