Current Issue


Table of contents

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 12.0

Version 12.0 delivers every issue of Sys Admin from 1992 through 2006 and every
issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!

Sys Admin Magazine > Archives > 2001 > July 2001
Listing 1 | Listing 2 | Listing 3 | Listing 4 | Listing 5 | Listing 6 | Listing 7 | Listing 8 | Listing 9 | Listing 10 | Article
Listing 1 - feedwatch.pl 
#!/usr/bin/perl
   # feedwatch.pl,v 1.12 2000-09-26 09:35:38-04 news Exp
# feedwatch - running count of total incoming feed stats
# a few handy things
   $KB = 1024;
   $MB = 1024 * 1024;
require "getopts.pl";
   Getopts("HL:Pi:d") || &Usage;
$HdrDef = 10;
   $UseInterval = $opt_i;
   $WantHdr = ( $opt_H ? 1 : 0 );
   if ( $opt_P ) {
   $WantHdr = 1;
   $HdrDef = 50;
   }
   $HdrLines = ( $opt_L ? $opt_L : $HdrDef );
# main read loop
   while (<>) {
   ($mon, $day, $time, $act, $feed, $MID, $rest) = split(" ", $_, 7);
   next unless m/ \d\d:\d\d:\d\d\.\d\d\d .*\n/;
   ($hour, $min, $sec) = split(/:/, $time);
   $logtime = $hour + $min/60 + $sec/3600;
   $token = "$hour$min";
 if ($UseInterval
   ? $Target == 0 || $logtime > $Target
   : $token ne $token_old
   ) {
   # decide if output really wanted
   if (($UseInterval ? defined $Target : defined $token_old)) {
   &print_stats;
   }
   $token_old = $token;
   $logtime_old = $logtime;
   $ofr = $acc = $can = $junk = $rej = $ref = $off = $accsize = 0;
   $first_sec = $sec;
   $Target = ( $Target ? $Target : $logtime ) + $UseInterval/3600;
   }
   ++$ofr;
   if ($act eq '+') {
   # accepted
   ++$acc;
   ($artsize, @dest) = split(" ", $rest);
   $accsize += $artsize;
   } elsif ($act eq 'j') {
   ++$junk;
   # correct, this shows up twice
   --$ofr;
   ($artsize, @dest) = split(" ", $rest);
   $accsize += $artsize;
   } elsif ($act eq 'c') {
   # cancel
   ++$can;
   } elsif ($act eq '-') {
   if ($rest =~ m/unwanted newsgroup/i) {
   ++$unw;
   } else { ++$ref }
   }
   }
&print_stats;
   exit 0;
sub print_stats
   {
   $et = 3600 * ($logtime - $logtime_old);
 # output header?
   if ($WantHdr && $lines++%$HdrLines == 0) {
   print "\f" if $opt_P && $lines > 1;
   print " <---------- arts ----------> tot offer accpt artKB avg K\n";
   print " time offer accpt junk cancl refu MB /sec /sec /sec size\n";
   }
 # decide on the time format
   if ($UseInterval) {
   $TimeFmt = "%06.3

				  



MarketPlace

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.

Six Sigma Certification
100% Online-Six Sigma Certificate from Villanova - Find Out More Now.

Workflow Enabled Help Desk & IT Service Management
Automate service desk activities and integrate processes across IT. Learn more here.

WinDev 11 - Powerful IDE
Develop 10 times faster ! ALM, IDE, .Net, RAD, 5GL, Database, 5GL, 64-bit, etc. Free Express version

Wanna see your ad here?