변군이글루

[스크립트] ping check 프로그램 본문

문___스크립트

[스크립트] ping check 프로그램

변군 변군이글루 2015.03.27 13:52

 

ping check 프로그램

 

# cat pingcheck.sh

#!/bin/sh

 

while true; do

 

sleep 1

 

PING_CHECK=`ping -c 1 192.168.2.1 | grep icmp_seq | awk {'print $4'}`

 

if [ "$PING_CHECK" == "192.168.2.1:" ]; then

#       echo "Success"

        echo "`date '+%Y-%m-%d %H:%M:%S'` : Success" >> tempfile

else

#       echo "Fail"

        echo "`date '+%Y-%m-%d %H:%M:%S'` : Fail" >> tempfile

fi

 

done

 

 

# sh pingcheck.sh &

 

# tail -f tempfile

2015-03-27 13:41:35 : Success

2015-03-27 13:41:36 : Success

2015-03-27 13:41:37 : Success

2015-03-27 13:41:38 : Success

2015-03-27 13:41:39 : Success

2015-03-27 13:41:50 : Fail

2015-03-27 13:42:01 : Fail

2015-03-27 13:42:12 : Fail

2015-03-27 13:42:23 : Fail

2015-03-27 13:42:34 : Fail

2015-03-27 13:42:45 : Fail

 

 

0 Comments
댓글쓰기 폼