Re: Program to monitor line quality?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 28, 2000 at 06:28:28PM +0100, Ralf G. R. Bergs wrote:
> Hi there,
> 
> is there a program/package to monitor the "line quality" (read "availability" 
> with respect to packet roundtrip times to a Point-to-Point peer or some other 
> topologically short-ranged host)?
> 

You can use fping for that. 2 perl scripts for testing are
included in mon 
http://www.kernel.org/pub/software/admin/mon/html/

I have a script, for use with cricket that measures 
min, max, avg round trip time and packet loss. I append it here.
Should be easy to add some alarm when some parameter is out of an
acceptable range. 

  Ciao
    Dietmar

-- 
 Alles Gute / best wishes  
     Dietmar Goldbeck                E-Mail: dietmar.goldbeck@acm.org
Reporter (to Mahatma Gandhi): Mr Gandhi, what do you think of Western
Civilization?  Gandhi: I think it would be a good idea.
#!/usr/bin/perl -w
#
# icmp statistic
# For use with "mon".
#
# Arguments are "host [host...]"
#
use Getopt::Std;

#make perl -w happy:
$opt_t=0; $opt_p=0; $opt_n=0; $opt_i=0; $opt_l=0;

getopts ("t:p:n:i:l:");
$TIMEOUT   = $opt_t || 2000;
$MAXLOSS   = $opt_p || 10;
$PACKETS   = $opt_n || 10;
$INTERVAL  = $opt_i || 1000;
$LossmSecs = $opt_l || 500;

$ENV{'PATH'}="/usr/bin:/usr/sbin:" . $ENV{'PATH'};

foreach $host (@ARGV) {
  #
  ($min, $max, $avg, $lossN) = &fping($host, $TIMEOUT, $MAXLOSS, $PACKETS);
  $avg = $avg || 0;
  $min = $min || 0;
  $max = $max || 0;
  printf "%f\n%f\n%f\n%f\n", 
  	$min/1000.0, $max/1000.0, $avg/1000.0, $lossN * $LossmSecs/1000.0;
}
exit 0;

sub fping {
  my($host, $timeout, $maxloss, $packets) = @_;
  my($rtts);
  my($h);
  my(@rttList, $rtt);
  my($maxrtt);
  my($minrtt);
  my($MaxMinInitFlag) = 0;
  my($sumrtt) = 0;
  my($losscount) = 0;
  my($lossP);
  my($avg);
  #
  ($h, $rtts) = split(/:/, `fping -p $INTERVAL -C $packets -q $host 2>&1`);
  chop($rtts);
  $rtts =~ s/^\s+//;
  @rttList = split(/\s/, $rtts);
  foreach $rtt (@rttList) {
    #print "DEBUG \$rtt=$rtt\n";
    if($rtt =~ /\-/) {
      $losscount++;
    } else {
      $rtt = int($rtt);
      $sumrtt += $rtt;
      if($MaxMinInitFlag == 0) {
	$maxrtt = $rtt;
	$minrtt = $rtt;
	$MaxMinInitFlag = 1;
      } else {
	if($maxrtt < $rtt) {
	  $maxrtt = $rtt;
	}
	if($minrtt > $rtt) {
	  $minrtt = $rtt;
	}
      }
    }
  }
  if($losscount < $packets) {
    $avg = $sumrtt / ($packets - $losscount);
  }
  #print "DEBUG: losscount=$losscount maxrtt=$maxrtt\n";
  return ($minrtt, $maxrtt, $avg, $losscount);
}


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux