image
image

Go Back   macosx.com > Scripts > Shell/Terminal Scripts

Reply
 
LinkBack Thread Tools
  #1  
Old February 6th, 2009, 12:55 PM
Registered User
 
Join Date: Mar 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
cticompserv is on a distinguished road
Script to notify if a computer shuts down

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
Reply With Quote
  #2  
Old February 8th, 2009, 10:15 PM
Just Some Guy
 
Join Date: Feb 2009
Location: LA
Posts: 21
Thanks: 0
Thanked 3 Times in 3 Posts
xserve@home is on a distinguished road
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
Reply With Quote
  #3  
Old February 9th, 2009, 12:39 AM
Just Some Guy
 
Join Date: Feb 2009
Location: LA
Posts: 21
Thanks: 0
Thanked 3 Times in 3 Posts
xserve@home is on a distinguished road
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.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 08:49 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.