ygemici,
please also include this statement passed within your script provided whenever i get ping broken
i.e If ping response is not responding(i.e when hostname is not alive) then this cmd to be executed :
opcmsg object=PING a=PING msg_grp=win-ping severity=critical msg_text="PING BROKEN on $line"
ygemici,
please also include this statement passed within your script provided whenever i get ping broken
i.e If ping response is not responding(i.e when hostname is not alive) then this cmd to be executed :
opcmsg object=PING a=PING msg_grp=win-ping severity=critical msg_text="PING BROKEN on $line"
Code:
#!/usr/bin/bash
if [ $# != 2 ] ; then echo "usage $0 'packetcount' hostlistfile" ; exit 0 ; fi
sleep=2 ; c=$1 # count for packets
while read -r host ; do
(sleep $sleep;ping -s $host 56 $c >/dev/null) &
pid=$! ; wait $pid
if [ $? -eq 0 ] ; then
PL=$(i=1;while [ $i -le $c ] ; do sleep $sleep;ping -s $host 56 $c ;((i++));done)
echo "$PL"|nawk -F, -v c=$1 -v host=$host -v sleep=$sleep '/packets/{sub("% packet loss","",$3)}{t+=$3}
END{if(t>50*c) {system("opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text=\"PING BROKEN on "host"\"")
print "ping problem in \""host"\" !!\nping loss \"%"t" of %"100*c"\" for at "c" packet tries in "sleep" seconds intervals\n"}
else {print "\""host"\" is alive with \"%"t" of %"100*c" loss rate\" at "c" packet tries in "sleep" seconds intervals\n"}}'
else echo -e "ping failed while sending 'echo_request(s)' to \"$host\"\n\
check!! host access (/network or firewall or route(ing) settings/) or \ncheck!! resolution (/hosts/dns/nsswitch)!!\n\
or \ncheck!! be sure host is power up or \ncheck!! is ping enabled in o.s or switch(s) or router(s)\n"
fi;done<$2
you are right , ping test takes long time..i modified and defined some defaults(for exa ping test about send 4 echo packet check in script)..
now you can give a ping try count for first parameter and then see the results..(actually 50 try requires more times but if you want to test in long time period then maybe you must specify 50 100 or 200 or more than parameter..)
so in script , ping tries transmit packets to target with 2 seconds intervals and 4 packets
first(prestart control) ping test takes about four seconds(normally about 1 second per packet or under 1 second ,, of course it may vary depending on various factors however) if target is avaliable and must must not be resulotion problem [ default timeout is 20 second ].but we defined packet size then it takes about 10 seconds + 4*1 second (per packet) = about 14 seconds.
lets look belows.
# if you dont have access to host..(some waits target host is non-accessable)
Code:
# time ping -s 192.168.56.112 56 4
PING 192.168.56.112: 56 data bytes
----192.168.56.112 PING Statistics----
4 packets transmitted, 0 packets received, 100% packet loss
real 0m13.069s
user 0m0.020s
sys 0m0.043s
# if you have access to host..(no wait target host is accessable)
Code:
# time ping -s 192.168.56.111 56 10
PING 192.168.56.111: 56 data bytes
64 bytes from solaris (192.168.56.111): icmp_seq=0. time=1.42 ms
64 bytes from solaris (192.168.56.111): icmp_seq=1. time=0.704 ms
64 bytes from solaris (192.168.56.111): icmp_seq=2. time=0.722 ms
........................
64 bytes from solaris (192.168.56.111): icmp_seq=9. time=0.795 ms
----192.168.56.111 PING Statistics----
10 packets transmitted, 10 packets received, 0% packet loss
round-trip (ms) min/avg/max/stddev = 0.381/0.8182/1.42/0.260
real 0m9.092s
user 0m0.027s
sys 0m0.051s
at the now,you must you can try and use to a specifying parameter with new script..
for example
Code:
# ./testping.sh 2 hostlist
this means that you want to try for Number of 4-pack counts[this is defaul in script] * 2 count..
Code:
#!/usr/bin/bash
## justdoit ## ping test on SunOS ##
if [ $# != 2 ] ; then echo "usage $0 'packetcount' hostlistfile" ; exit 0 ; fi
if [[ $(echo $1|grep [^0-9]) ]] ; then echo "first parameter '$1' is not digit!!";exit 1;fi
sleep=2 ; c=$1 ; control=4 ; # count for packets
while read -r host ; do
printf "%s" "testing access to $host ...? "
(sleep $sleep;ping -s $host 56 $control > /dev/null 2>&1) &
pid=$! ; wait $pid
if [ $? -ne 0 ] ; then
printf "%s\n" "FAIL!! "
else
>tmppg
printf "%s\n" "SUCCESS "
## pinging try ##
printf "%s" "pinging try "
for((j=0;j<$c;j++)); do printf "%c" ".";sleep $sleep; ping -s $host 56 $control >>tmppg;done;
printf "%s\n" " OK"
nawk -F, -v c=$1 -v host=$host -v sleep=$sleep '/packets/{sub("% packet loss","",$3)}{t+=$3}
END{if(t>50*c) {system("opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text=\"PING BROKEN on "host"\"");
print "ping problem in \""host"\" !!\nping loss \"%"t" of %"100*c"\" for at "c" packet tries in "sleep" seconds intervals"}
else {print "\""host"\" is alive with \"%"t" of %"100*c" loss rate\" at "c" packet tries in "sleep" seconds intervals"}}' tmppg
fi;echo;done<"$2"
help with bash script!
im am working on this script to make sure my server will stay online, so i made this script..
HOSTS="192.168.138.155"
COUNT=4
pingtest(){
for myhost in "$@"
do
ping -c "$COUNT" "$myhost" &&return 1
done
return 0
}
if pingtest $HOSTS
#100% failed... (4 Replies)
Hi
I am using perl to ping a list of nodes - with script below :
$p = Net::Ping->new("icmp");
if ($p->ping($host,1)){
print "$host is alive.\n";
}
else {
print "$host is unreacheable.\n";
}
$p->close();... (4 Replies)
Hello All,
We have added a windows host and its config files to Nagios master server and wanted to do a ping check alone at the moment however, the nagios master server identifies the host in its GUI and immediately disappears can anyone let me know the right approach to this one, We want to... (2 Replies)
Hi,
I develop simple animation ping script on Solaris Platform. It is like Cisco ping.
Examples and source code are below.
bash-3.00$ gokcell 152.155.180.8 30
Sending 30 Ping Packets to 152.155.180.8
!!!!!!!!!!!!!.!!!!!!!!!!!!!!!.
% 93.33 success... % 6.66 packet loss...... (1 Reply)
I have perl script that I use to check and ping a list of ip,
The problem is, I didnt understand how to ping ipv6 on perl,
Could I use Ping::External??And how could I get the ping result (reply or not)?
This is my code
#!/usr/bin/perl --
use Net::Ping;
use Data::Validate::IP;
use... (3 Replies)
Dear all,
I have system that have 2 disk, and 1 off disk is broken, how can I check if the disk is broken or other problem.
I'm using Solaris 10 x86.
Thank you,
Best Regards,
Heru (4 Replies)
Hi,
I first wanted to install my NIC drivers but it said:
Makefile:62: *** Linux kernel source not found. Stop.
So I installed the kernel source: linux-source-2.6.18_2.6.18.dfsg.1-13etch5_all.deb
1) cd /usr/src
2) -xjvf linux-source.2.6.18.extension (forget what it was)
3) ln -s... (12 Replies)
Ok i am running Linux, or rather was. I can not longer do anything. This was a dns server amoungst other things.
It will no longer boot.
I have used a startup disk, but how can i recover the OS?
I need help and urgently.
Please someone
thanks (3 Replies)