#! /local/bin/perl5.003 -w # 1997 Rahul Dhesi, All rights reserved. # Permission for copying and creation of derivative works is granted, # provided this copyright notice is preserved. use strict; # $Source: /local/undoc/RCS/innd.stats,v $ # $Id: innd.stats,v 1.18 1997/08/20 14:41:20 rdroot Exp $ # # Scan inn's news.notice output and look for innd timer entries. # Print each one in a human readable form. Also recognizes # history cache statistics, if found. # # sample output: # # Aug 20 07:31:47 time, ms percent # -------- ------- # Latency 44 ms / 300 s 0.01 % # Percent busy: 91.92 % # Time per article write: 57.90 ms 35.88 % # Time per crosslink: 0.10 ms 0.02 % # Time per history write: 20.46 ms 18.76 % # Time per history lookup: 9.05 ms 15.73 % # History cache: 755961 / 980283 77.12 % $::myname = "innd.stats"; $::RCSHEADER = '$Source: /local/undoc/RCS/innd.stats,v $' . "\n" . '$Id: innd.stats,v 1.18 1997/08/20 14:41:20 rdroot Exp $'; $::usage = "usage: $::myname [-vtxr] [-L] [-f logfilename] (or -h for help)"; if (@ARGV && $ARGV[0] =~ "^-.+" ) { require "getopts.pl"; &Getopts("vtxhrLf:"); } $::debug = $::opt_x; $::trace = $::opt_t; $::verbose = $::debug || $::trace || $::opt_v; # suppresss perl warnings my($junk) = ($::debug && $::trace && $::verbose && $::opt_r && $::opt_h && $::opt_v && $::opt_t && $::opt_x); if ($::opt_h) { &givehelp(); exit(0); } ## (@ARGV < 1) && &usage_error; if ($::opt_f && $::opt_f ne '-') { open(STDIN, $::opt_f) || die "$::myname: error: can't read from $::opt_f: $!\n"; } $::output = ''; my $last_hash_tot = 0; my $restarted = ''; my @data; rescan: while (<>) { if (@data = / (.{15})\s\S+\sinnd\:\s+ME\stime\s(\d+)\s+ idle\s+(\d+)\((\d+)\)\s+ artwrite\s+(\d+)\((\d+)\)\s+ artlink\s+(\d+)\((\d+)\)\s+ hiswrite\s+(\d+)\((\d+)\)\s+ hissync\s+(\d+)\((\d+)\)\s+ sitesend\s+(\d+)\((\d+)\)\s+ artctrl\s+(\d+)\((\d+)\)\s+ artcncl\s+(\d+)\((\d+)\)\s+ hishave\s+(\d+)\((\d+)\)\s+ hisgrep\s+(\d+)\((\d+)\) /x) { my($tstamp, $ttotal, $tidle, $jidle, $tartwrite, $jartwrite, $tartlink, $jartlink, $thiswrite, $jhiswrite, $thissync, $jhissync, $tsitesend, $jsitesend, $tartctrl, $jartctrl, $tartcncl, $jartcncl, $thishave, $jhishave, ) = @data; my($hash_tot, $hash_hits) = (0, 0); if (/\shashstats\s+(\d+)\((\d+)\)/) { $hash_tot = $1; $hash_hits = $2; } $::debug && print; # make sure all possible denominators are nonzero my $var; for $var ($ttotal, $jartwrite, $jartlink, $jhiswrite, $jhishave) { if ($var == 0) { $var = 0.001; } } ## print "@data\n"; my $Ppbusy = &dc(100 * ($ttotal - $tidle) / $ttotal); my $Ptartwrite = &dc($tartwrite / $jartwrite); my $Ppartwrite = &dc(100 * ($tartwrite / $ttotal)); my $Ptcrosslink = &dc($tartlink / $jartlink); my $Ppcrosslink = &dc(100 * ($tartlink / $ttotal)); my $Pthiswrite = &dc($thiswrite / $jhiswrite); my $Pphiswrite = &dc(100 * ($thiswrite / $ttotal)); my $Ptlookup = &dc($thishave / $jhishave); my $Pplookup = &dc(100 * ($thishave / $ttotal)); my $Platency = sprintf("%6u", $ttotal - 300000); my $Pplatency = &dc(100 * ($Platency / 300000)); my $Phash_hits = sprintf("%6u", $hash_hits); my $Phash_tot; my $Pphash; if ($hash_tot > 0) { $Phash_tot = sprintf("%- 6u", $hash_tot); $Pphash = &dc(100 * $hash_hits / $hash_tot); } else { $Phash_tot = sprintf("%- 6u", $hash_tot); $Pphash = &dc(0); } $::output = ''; $restarted = ''; if ($last_hash_tot > $hash_tot) { $restarted .= "*** cleared ***\n"; } $last_hash_tot = $hash_tot; $::output .= <