[Mon-commit] mon/mon.d up_rtt.monitor,1.1.1.1,1.1.1.1.2.1
Brought to you by:
trockij
From: Jim T. <tr...@us...> - 2004-06-23 12:20:14
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17644 Modified Files: Tag: mon-1-0-0pre1 up_rtt.monitor Log Message: added -r to log individual rtts better error reporting for tcp and udp check Index: up_rtt.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/up_rtt.monitor,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** up_rtt.monitor 9 Jun 2004 05:18:04 -0000 1.1.1.1 --- up_rtt.monitor 23 Jun 2004 12:19:55 -0000 1.1.1.1.2.1 *************** *** 8,12 **** # Requires Perl Modules "Time::HiRes" and "Statistics::Descriptive" # ! # # # $Id$ --- 8,12 ---- # Requires Perl Modules "Time::HiRes" and "Statistics::Descriptive" # ! # # # $Id$ *************** *** 48,52 **** use Statistics::Descriptive; ! getopts ("dt:T:l:U:"); # -d Debug mode --- 48,52 ---- use Statistics::Descriptive; ! getopts ("drt:T:l:U:"); # -d Debug mode *************** *** 56,67 **** # -l file Log file name with optional YYYYMM part that will be transformed to current month # -U num Number of UDP packets to send $TimeOut = $opt_t || 10; # Timeout in seconds ! $NUM_UDP_TRYS = $opt_U || 5; # Number of UDP packet to send # Solaris MSG_WAITALL 0x40 /* Wait for complete recv or error */ #linux/socket.h:#define MSG_WAITALL 0x100 /* Wait for a full request */ ! # $RecvRet = recv($S, $Echo, $DataLength, 64); # Solaris & older versions of Linux #$RecvFlags = 0; # May work on all systems due to small packets used here --- 56,68 ---- # -l file Log file name with optional YYYYMM part that will be transformed to current month # -U num Number of UDP packets to send + # -r Log individual raw RTTs $TimeOut = $opt_t || 10; # Timeout in seconds ! $NUM_UDP_TRYS = $opt_U || 5; # Number of UDP packets to send # Solaris MSG_WAITALL 0x40 /* Wait for complete recv or error */ #linux/socket.h:#define MSG_WAITALL 0x100 /* Wait for a full request */ ! # $RecvRet = recv($S, $Echo, $DataLength, 64); # Solaris & older versions of Linux #$RecvFlags = 0; # May work on all systems due to small packets used here *************** *** 81,84 **** --- 82,87 ---- foreach $TargetHost (@Hosts) { + undef @RawRTT; + $stat = Statistics::Descriptive::Full->new(); *************** *** 104,113 **** $count = $stat->count(); ! $ResultString{$TargetHost} = sprintf "%d %s %0.4f %0.4f %0.4f %d", ! $TimeOfDay, $TargetHost, $min, $mean, $max, $count; if ($opt_T) { # Check minimum RTT for alarm limit if ($min > $opt_T) { ! push (@Failures, $TargetHost); } } --- 107,125 ---- $count = $stat->count(); ! if ($opt_r && (defined @RawRTT)) { ! $ResultString{$TargetHost} = sprintf "%d %s", ! $TimeOfDay, $TargetHost; ! foreach $rtt (@RawRTT) { ! $ResultString{$TargetHost} .= sprintf " %0.4f", $rtt; ! } ! } else { ! $ResultString{$TargetHost} = sprintf "%d %s %0.4f %0.4f %0.4f %d", ! $TimeOfDay, $TargetHost, $min, $mean, $max, $count; ! } if ($opt_T) { # Check minimum RTT for alarm limit if ($min > $opt_T) { ! print "Minimum RTT pushing $host\n" if $opt_d; ! push (@Failures, $TargetHost); } } *************** *** 139,149 **** if (@Failures == 0) { # Indicate "all OK" to mon ! exit 0; } ! print "@Failures\n"; ! foreach $host (sort @Failures) { ! print "$host: $ResultString{$host} "; } print "\n"; --- 151,165 ---- if (@Failures == 0) { # Indicate "all OK" to mon ! print "\n--------- No Failures ---------\n" if $opt_d; ! exit 0; } ! print "\n--------- Have Failures - mon Data Below ---------\n" if $opt_d; ! @SortedFailures = sort @Failures; ! print "@SortedFailures\n"; ! ! foreach $host (@SortedFailures) { ! print "$ResultString{$host}\n"; } print "\n"; *************** *** 155,159 **** # ! sub UDPcheck { my($TargetHost) = @_; my($DroppedPackets, $GoodPackets); --- 171,175 ---- # ! sub UDPcheck { # Send multiple UDP packets my($TargetHost) = @_; my($DroppedPackets, $GoodPackets); *************** *** 161,164 **** --- 177,181 ---- $DroppedPackets = 0; $GoodPackets = 0; + $dt = -1; # Will report -1 on failure $S = new IO::Socket::INET (PeerAddr => $TargetHost, *************** *** 167,171 **** ); do { ! &LeaveError($TargetHost, "Can't open UDP socket to $TargetHost\n"); return 0; } unless ($S); --- 184,188 ---- ); do { ! &udpLeaveError($TargetHost, "Can't open UDP socket to $TargetHost\n"); return 0; } unless ($S); *************** *** 177,180 **** --- 194,198 ---- # $Out .= ' 'x52; # Make a 56+ byte packet $DataLength = length($Out); + $Echo = ''; # Clear input buffer $t1 = [gettimeofday]; *************** *** 199,202 **** --- 217,221 ---- if ($Echo eq $Out) { $stat->add_data($dt); + push(@RawRTT, $dt); if ($opt_d) { print "$i - $DataLength - $dt -$Echo-\n"; *************** *** 208,212 **** } } - } } --- 227,230 ---- *************** *** 215,223 **** } ! sub TCPcheck { my($TargetHost) = @_; my($DroppedPackets, $GoodPackets, $dt); $S = new IO::Socket::INET (PeerAddr => $TargetHost, PeerPort => 7, --- 233,245 ---- } ! sub TCPcheck { # Send a single TCP packet my($TargetHost) = @_; my($DroppedPackets, $GoodPackets, $dt); + $GoodPackets = 0; + $i = 1; + $dt = -1; # Will report -1 on failure + $S = new IO::Socket::INET (PeerAddr => $TargetHost, PeerPort => 7, *************** *** 225,235 **** ); do { ! &LeaveError($TargetHost, "Can't open TCP socket to $TargetHost\n"); ! return 0; } unless ($S); - $GoodPackets = 0; - $i = 1; - $dt = -1; # Will report -1 on failure $Out = "TCP$i"; $DataLength = length($Out); --- 247,254 ---- ); do { ! &tcpLeaveError($TargetHost, "Can't open TCP socket to $TargetHost\n"); ! return $GoodPackets, $dt; } unless ($S); $Out = "TCP$i"; $DataLength = length($Out); *************** *** 270,279 **** } ! sub LeaveError { my ($host, $reason) = @_; push (@Failures, $host); - # $ResultString{$host} .= $reason; - # push (@FailReasons, $reason); - # print "$reason\n"; } --- 289,301 ---- } ! sub udpLeaveError { # Don't call this one a failure, TCP might work my ($host, $reason) = @_; + print "udpLeaveError $host\n" if $opt_d; + } + + sub tcpLeaveError { # If we get here, it was a failure + my ($host, $reason) = @_; + print "tcpLeaveError pushing $host\n" if $opt_d; push (@Failures, $host); } |