merlyn@iwarp.intel.com (Randal Schwartz) (02/07/90)
Here's a Perl program to generate your very own graph of the delay between posting and receiving, just like the folks at decwrl and uunet generate on a regular basis. Usage: no args gives you the entire spool; any arguments restrict it to the listed subdirectories. No claims for speed, although I can scan my entire spool in about 15 minutes. Requires Perl 3.0. Enjoy. %_=split(/(\D+)/,"2another4hacker,1Just3Perl");print"@_{1..4}"; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cut here (.sig below) #!/local/merlyn/bin/perl (($spool) = grep(-d, "/usr/spool/news", "/r2/usr.spool.news")) || die "Cannot find spool directory"; %offset = ( 'Jan89', 0, 'Feb89', 31, 'Mar89', 59, 'Apr89', 90, 'May89', 120, 'Jun89', 151, 'Jul89', 181, 'Aug89', 212, 'Sep89', 243, 'Oct89', 273, 'Nov89', 304, 'Dec89', 334, 'Jan90', 365, 'Feb90', 396, 'Mar90', 425, 'Apr90', 456, 'May90', 486, 'Jun90', 516 ); # that'll do for a while $| = 1; chdir $spool || die "Cannot chdir $spool ($!)"; @ARGV = ('.') unless $#ARGV > -1; open(FIND, "find @ARGV -type f -print|") || die "Cannot open FIND ($!)"; ARTICLE: while (<FIND>) { next ARTICLE unless m#^((.*/)?\d+)$#; $article = $1; unless (open(ARTICLE, $article)) { warn "Cannot open $article ($!)"; next ARTICLE; } while (<ARTICLE>) { if (/^$/) { warn "$article: What? No date?"; next ARTICLE; } last if /^Date:/; } unless (/\s(\d\d?)\s+(\w\w\w)\w*\s+(\d\d)\s+(\d\d?):(\d\d):(\d\d)\s+GMT/) { /(.*)/; warn "$article: unknown date format: $1"; next ARTICLE; } ($day,$monthname,$year,$hour,$minute,$second) = ($1,$2,$3,$4,$5,$6); unless (defined($offset{$monthname . $year})) { warn "$article: unknown month/year: $monthname/$year"; next ARTICLE; } $when = ($offset{$monthname . $year}+$day-1)*86400 + $hour*3600 + $minute * 60 + $second + 599616000; @x = stat(ARTICLE); $latency = $x[9]-$when; $daysold = int($latency/86400+2)-2; $daysold = 29 if $daysold > 28; $daysold = -1 if $daysold < 0; # time warp $daysold{$daysold}++; $daysoldn++; next ARTICLE unless $daysold < 1; $hoursold = int($latency/3600+2)-2; $hoursold = 25 if $hoursold > 24; $hoursold = -1 if $hoursold < 0; # time warp $hoursold{$hoursold}++; $hoursoldn++; } exit if $daysoldn < 1; print "$daysoldn articles total\n"; print "Days Count %---10---20---30---40---50---60---70---80---90--100\n"; for ((-1..29)) { printf "%4d %5d %s\n", $_, $daysold{$_}, '*' x (50*$daysold{$_}/$daysoldn); } exit if $hoursoldn < 1; print "\n$hoursoldn articles in first day\n"; print "Hour Count %---10---20---30---40---50---60---70---80---90--100\n"; for ((-1..25)) { printf "%4d %5d %s\n", $_, $hoursold{$_}, '*' x (50*$hoursold{$_}/$hoursoldn); } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cut here -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/