Bug#412549: netmrg: Improve linux26diskaccess.pl to monitor disk traffic in bytes /sec
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 57000 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 adduser3.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.11Debian configuration management sy ii libc6 2.3.6.ds1-11 GNU C Library: Shared libraries ii libgcc11:4.1.1-21GCC support library ii libmysqlclient15off5.0.32-3 mysql database client library ii libsnmp9 5.2.3-7 NET SNMP (Simple Network Managemen ii libssl0.9.80.9.8c-4 SSL shared libraries ii libstdc++6 4.1.1-21 The GNU Standard C++ Library v3 ii libxml22.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 rrdtool1.2.15-0.3Time-series data storage and displ ii wwwconfig-common 0.0.48Debian web auto configuration ii zlib1g 1:1.2.3-13compression 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 840446Fax: 02331 843920 signature.asc Description: Digital signature
Bug#412549: netmrg: Improve linux26diskaccess.pl to monitor disk traffic in bytes /sec
On Tue, 6 Mar 2007, Uwe Steinmann wrote: 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 57000 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'? I see. It's because the partition data start with spaces and thus the results are shifted (I only check the disk-wide results here). So all we have to do is strip the leading spaces. I'm attaching the updated script. -- Francois Gouget [EMAIL PROTECTED] http://fgouget.free.fr/ We are Pentium of Borg. You will be approximated. Division is futile.#!/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 blocks\n; print -w Report the number of write operations\n; print -wb Report the number of written blocks\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) { print $readb\n; } elsif ($ARGV[0] eq -wb) { print $writeb\n; }
Bug#412549: netmrg: Improve linux26diskaccess.pl to monitor disk traffic in bytes / sec
The conversion from blocks to bytes in the linux26diskaccess.pl script I sent is wrong because Perl's integers are 32bits so it overflows. Avoiding this problem in Perl is a bit tricky: I don't feel like having the script depend on the BigInt module. So I simply modified it to return the number of blocks read and added a 512 modifier in the graph. What's strange is that I had to delete everything (graph, monitor, subdevice, script) and recreate it all from scratch otherwise NetMRG would display nothing. This is not the first time I have this type of unexplained problems, it looks like NetMRG is really finicky sometimes. But at least now it's all working. So here's the new version. -- Francois Gouget [EMAIL PROTECTED] http://fgouget.free.fr/ The software said it requires Win95 or better, so I installed Linux.#!/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 blocks\n; print -w Report the number of write operations\n; print -wb Report the number of written blocks\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) { print $readb\n; } elsif ($ARGV[0] eq -wb) { print $writeb\n; }
Bug#412549: netmrg: Improve linux26diskaccess.pl to monitor disk traffic in bytes /sec
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 adduser3.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.11Debian configuration management sy ii libc6 2.3.6.ds1-11 GNU C Library: Shared libraries ii libgcc11:4.1.1-21GCC support library ii libmysqlclient15off5.0.32-3 mysql database client library ii libsnmp9 5.2.3-7 NET SNMP (Simple Network Managemen ii libssl0.9.80.9.8c-4 SSL shared libraries ii libstdc++6 4.1.1-21 The GNU Standard C++ Library v3 ii libxml22.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 rrdtool1.2.15-0.3Time-series data storage and displ ii wwwconfig-common 0.0.48Debian web auto configuration ii zlib1g 1:1.2.3-13compression 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; } -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]