Mombu the GNU Linux Forum sponsored links

Go Back   Mombu the GNU Linux Forum > GNU_Linux > ping script
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 30th July 03:17
curtis vaughan
External User
 
Posts: 1
Default ping script



Could you share it with me?

Curtis Vaughan


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Reply With Quote


  sponsored links


2 30th July 03:17
bijan soleymani
External User
 
Posts: 1
Default ping script



Curtis Vaughan said:

Here's a quick one:
#!/bin/bash
if ping -c 1 $1;
then echo "success";
else echo "ping failed for $1" | mail -s "ping failure for $1" bijan@psq.com;
fi

Simply replace "bijan@psq.com" with your email address. Bijan --
Bijan Soleymani <bijan@psq.com>
http://www.crasseux.com


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Reply With Quote
3 30th July 12:01
jan minar
External User
 
Posts: 1
Default ping script


#!/bin/sh
while :; do
# Allow for intermittent network failures
ping -c 120 "$1" && LAST="`date -R`" || \
mail -s "Can't ping $1 since $LAST" < /dev/null
done

--
Jan Minar "Please don't CC me, I'm subscribed." x 9

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFACNo5+uczK20Fa5cRAqlWAKCcaOAE7EfL4EnXdWM5Yx 3XIcyiKQCglRWC
sCYQ/lQNp/ySy/hOVO/aEQw=
=n9T1
-----END PGP SIGNATURE-----
  Reply With Quote
4 30th July 12:01
curtis vaughan
External User
 
Posts: 1
Default ping script


Well, I've been able to edit Bijan's script to do exactly what I want
except. It just runs once. Without putting it in a cron job that
would run every 10 secs, how do I get it to just keep repeating itself,
preferably with a 10 sec delay?

Curtis Vaughan

--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Reply With Quote
5 30th July 12:01
curtis vaughan
External User
 
Posts: 1
Default ping script


Actually this is the way I tried to get it to continually loop.
Apparently it does, but it only send out messages as to failures after
I have killed the process.

#!/bin/bash
while :; do
ping='10.0.0.3'
if ping -c 1 $ping;
then echo "success";
else echo "ping failed for $ping" | mail -s "ping failure for $ping"
curtis;
fi
done

Curtis Vaughan

--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Reply With Quote
6 30th July 20:58
bijan soleymani
External User
 
Posts: 1
Default ping script


I think that it might be succeeding, and therefore not sending any mails,
but when you kill it you don't kill the script but just the ping command
causing it to "fail". That's why you get the emails when you kill it.

Here's a perl script that repeats the ping every ten seconds until it fails
then it stops running:
#!/usr/bin/perl
$ping='10.0.0.3';
while(!$fail) #check if last ping failed
{
`ping -c 1 $ping`; #execute the ping
if($?==0) #check the status of last command
{
print "success\n";
}
else
{
`echo "ping failed for $ping" | mail -s "ping failure for $ping" curtis`;
$fail=true;
}
sleep(10);
}

If you want it to go on forever (even after the ping starts to fail) simply
change the loop from while(!$fail) to while(1). Bijan --
Bijan Soleymani <bijan@psq.com>
http://www.crasseux.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFACWX3Uof+95vTyAwRAgH7AJkBvo47ca+GA+cg/hxqjVka3u0oEwCePbSN
lsLEZmHqvayc7FcHZRjn148=
=H+Nm
-----END PGP SIGNATURE-----
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666