Advertisement
sourc7

Track a Devices Uptime -OpenWRT [msmtp]

May 24th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1. #!/bin/bash
  2. HOSTS=”192.168.1.1 192.168.1.251 google.com 192.168.1.7“
  3. COUNT=4
  4. for myHost in $HOSTS
  5. do
  6.     count=$(ping -c $COUNT $myHost | grep ‘received‘ | awk -F’,’ ‘{ print $2 }| awk{ print $1 })
  7.     if [ $count -eq 0 ] ; then
  8.        # 100% failed
  9.        echo -e “Subject: $myHost is down\r\n\n Aww , Snap.. $myHost is down” |msmtp –from=default -t dest.addr@gmail.com
  10.  
  11.      fi
  12.    done
  13.  
  14. #-EOF
  15.  
  16. Visit : www.techrapid.co.uk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement