Linux script for pinging hosts /w reply value

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
rasc
Posts: 95
Joined: Sun Oct 11, 2009 8:25 am

Linux script for pinging hosts /w reply value

Post by rasc »

Hi,

what a pity you do not have 'ping' implemented in Linux rma :(
We enhanced your ping script a bit to get reply values.
It might help someone...

Regards

Ping host (advanced)

Code: Select all

#!/bin/sh

# ping -c $2 -w 4 $1 1> /dev/null 2> /dev/null
PingResult=`ping -c $2 -w 4 $1 | grep icmp_seq | awk -F= '{ print $4 }'`
if [ -z "$PingResult" ]
then
  echo "ScriptRes:No answer:dead"
else
  echo "ScriptRes:Host is alive:"$PingResult
fi 
Post Reply