Thanks for the improved script. I made a simple test, but didn't get the expected results.
ibook:/usr/share/doc/linux-wlan-ng# cat /sys/block/hda/hda2/stat 285 570 0 0 ibook:/usr/share/doc/linux-wlan-ng# /tmp/linux26diskaccess.pl -r hda2 ibook:/usr/share/doc/linux-wlan-ng# /tmp/linux26diskaccess.pl -rb hda2 285 ibook:/usr/share/doc/linux-wlan-ng# /tmp/linux26diskaccess.pl -w hda2 570 ibook:/usr/share/doc/linux-wlan-ng# /tmp/linux26diskaccess.pl -wb hda2 0 Why doesn't '/tmp/linux26diskaccess.pl -r hda2' return '0'? Uwe On Mon, Feb 26, 2007 at 07:38:41PM +0100, Francois Gouget wrote: > Package: netmrg > Version: 0.18.2-14 > Severity: normal > Tags: patch > > > When I looked at linux26diskaccess.pl I was surprised by the results. > I would like to monitor my disk traffic in bytes per second rather than > requests per second (the two are not correlated because of request > merging). > > So I modified linux26diskaccess.pl so it supports the -rb and -wb > options which report these statistics. > > At the same time I made some other changes: > * It can now monitor any disk device, not just IDE disks > * I tried to improve the usage message a bit > * I factorized the partition / raw device handling > > -- System Information: > Debian Release: 4.0 > APT prefers testing > APT policy: (500, 'testing'), (500, 'stable') > Architecture: i386 (i686) > Shell: /bin/sh linked to /bin/bash > Kernel: Linux 2.6.17.8fg1 > Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) > > Versions of packages netmrg depends on: > ii adduser 3.102 Add and remove users and groups > ii apache2-mpm-prefork [httpd 2.2.3-3.2 Traditional model for Apache > HTTPD > ii debconf [debconf-2.0] 1.5.11 Debian configuration management > sy > ii libc6 2.3.6.ds1-11 GNU C Library: Shared libraries > ii libgcc1 1:4.1.1-21 GCC support library > ii libmysqlclient15off 5.0.32-3 mysql database client library > ii libsnmp9 5.2.3-7 NET SNMP (Simple Network > Managemen > ii libssl0.9.8 0.9.8c-4 SSL shared libraries > ii libstdc++6 4.1.1-21 The GNU Standard C++ Library v3 > ii libxml2 2.6.27.dfsg-1 GNOME XML library > ii mysql-client-5.0 [mysql-cl 5.0.32-3 mysql database client binaries > ii php4 6:4.4.4-8 server-side, HTML-embedded > scripti > ii php4-cli 6:4.4.4-8 command-line interpreter for the > p > ii php4-mysql 6:4.4.4-8 MySQL module for php4 > ii rrdtool 1.2.15-0.3 Time-series data storage and > displ > ii wwwconfig-common 0.0.48 Debian web auto configuration > ii zlib1g 1:1.2.3-13 compression library - runtime > > netmrg recommends no packages. > > -- debconf information excluded > > *** /usr/lib/netmrg/linux26diskaccess.pl > #!/usr/bin/perl > use strict; > > ### config variables > my $blockdev = "/sys/block"; > > > ### argument processing > if (@ARGV != 2 or > $ARGV[0] !~ /^-[rw]b?$/ or > $ARGV[1] !~ /^\w+(?:\d+)?$/) > { > print "U\n"; > print "\n"; > print "$0 [-r|-rb|-w|-wb] <dev(N)>\n"; > print "\n"; > print "Reports disk I/O statistics counters for use as a NetMRG test > script.\n"; > print "\n"; > print "Options:\n"; > print " -r Report the number of read operations\n"; > print " -rb Report the number of read bytes\n"; > print " -w Report the number of write operations\n"; > print " -wb Report the number of written bytes\n"; > print " dev(n) Is a relative block device or partition name.\n"; > print " For instance hda, hda1 or md0\n"; > print "\n"; > exit 1; > } > > > ### figure out device/partitions > my ($hd, $partition); > if ($ARGV[1] =~ /^(hd\w)\d+$/) > { > $partition = $ARGV[1]; > $hd = $1; > } # end if hd has a partition > else > { > $hd = $ARGV[1]; > } # end else hd is just the drive > > > ### read info from system block > > # read the data from the correct path > my $path = "$blockdev/$hd"; > $path .= "/$partition" if ($partition ne ""); > $path .= "/stat"; > open(STAT, $path) || die ("U\nERROR: couldn't open $path\n\n"); > my $line = <STAT>; > close(STAT); > chomp($line); > my ($read, $readb, $write, $writeb); > if ($partition eq "") > { > ($read, $readb, $write, $writeb)=(split /\s+/, $line)[0, 2, 4, 6]; > } > else > { > ($read, $readb, $write, $writeb)=split /\s+/, $line; > } > > ### output the data > if ($ARGV[0] eq "-r") > { > print "$read\n"; > } > elsif ($ARGV[0] eq "-w") > { > print "$write\n"; > } > elsif ($ARGV[0] eq "-rb") > { > $readb*=512; > print "$readb\n"; > } > elsif ($ARGV[0] eq "-wb") > { > $writeb*=512; > print "$writeb\n"; > } -- MMK GmbH, Fleyer Str. 196, 58097 Hagen [EMAIL PROTECTED] Tel: 02331 840446 Fax: 02331 843920
signature.asc
Description: Digital signature