IsraelTorres

loghost.sh

Oct 25th, 2012
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # ./loghost.sh
  3. # Israel Torres 20121025 host site logger - pings host and logs when it came back up
  4. ltimestamp=$(date +%s)
  5. ltsreadable=$(date -r $ltimestamp)
  6. HOST=$1
  7. echo "Scanning:: $HOST as of [$ltimestamp] $ltsreadable ..."
  8. ping -o $HOST > /dev/null
  9. if [ "$?" = 0 ]; then
  10.     timestamp=$(date +%s)
  11.     tsreadable=$(date -r $timestamp)
  12.     echo "$HOST appears UP as of [$timestamp] $tsreadable ***" | tee "log-$timestamp-$HOST.txt"
  13. else
  14.     echo "weird error"
  15. fi
  16. #eof
RAW Paste Data