home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 February
/
PCWorld_2000-02_cd.bin
/
live
/
usr
/
X11R6
/
bin
/
procmeter-xlog
< prev
next >
Wrap
Text File
|
1998-10-13
|
1KB
|
49 lines
#!/usr/bin/perl
#
# A perl script that analyses the log file to extract one statistic.
#
# Written by Andrew M. Bishop
#
# This file Copyright 1997 Andrew M. Bishop
# It may be distributed under the GNU Public License, version 2, or
# any higher version. See section COPYING of the GNU Public license
# for conditions under which this file may be redistributed.
#
die "Usage: procmeter-xlog statistic < logfile\n" if($#ARGV==-1);
$statistic=$ARGV[0];
$position=-1;
$_=<STDIN>;
print $_;
print "# Data for '$statistic'\n";
while(<STDIN>)
{
chop;
if(/^\#/)
{
($hash,$time,@stats)=split(/ +/);
$old_position=$position;
$position=-1;
foreach $n (0 .. $#stats)
{
if($stats[$n] eq $statistic)
{$position=$n;}
}
if($position!=-1 && $old_position==-1)
{print "\n";}
}
elsif($position!=-1)
{
($time,@stats)=split(/ +/);
print "$time $stats[$position]\n";
}
}