Changeset 1486
- Timestamp:
- 02/20/08 15:38:35 (4 years ago)
- Files:
-
- people/ssm/plugins/iostat/iostat_latency (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
people/ssm/plugins/iostat/iostat_latency
r1484 r1486 5 5 # work on operations since last invocation of the plugin. 6 6 7 # If you run this as "root", you'll get device mapper names added to 8 # the info field in the generated HTML. 9 # 10 # XXX: This is readable by any user within the file system, but the 11 # "dmsetup info" command is just usable by root. Any decent fix? I'd 12 # hate parsing "ls" output. 13 7 14 use strict; 8 use Data::Dumper; # for debugging only 15 16 use lib $ENV{'MUNIN_LIBDIR'}; 9 17 use Munin::Plugin; 10 18 11 19 ## TODO: Make %stats a global variable? 12 20 ## 13 14 ## Add a .info for each point with the underlying disks for lvm, for15 ## instance16 21 17 22 ## Add state to show averages over 5 minutes, even on multi-master. … … 23 28 my %graphconfig = ('grph_title' => 'Disk stats', 24 29 'graph_args' => '--base 1000 -l 0', 25 'graph_vlabel' => ' Miliseconds',30 'graph_vlabel' => 'Seconds', 26 31 'graph_category' => 'system', 27 32 'graph_info' => 'Average IO latency in seconds per IO operation' … … 44 49 if ($_ > 1) { 45 50 die "Too many arguments"; 46 } elsif ($_ == 1 ) {51 } elsif ($_ == 1 && $ARGV[0] ne '') { 47 52 for ($ARGV[0]) { 48 53 if ($_ eq "config") { 49 54 my %stats=&diskstats; 50 55 printconf(\%stats, \%graphconfig); 51 } elsif ($_ eq "debug") {52 my %stats=&diskstats;53 print Dumper(\%stats, \%graphconfig);54 56 } else { 55 die "Unknown argument"; 56 }57 die 'Usage: ' 58 } 57 59 } 58 60 } else { … … 85 87 if($stats{$device}{'active'}) { 86 88 # Label 87 printf("%s_%s.label %s\n", $device, $operation, $device); 89 printf("%s_%s_time.label %s\n", 90 $device, $operation, join("_", $device, $operation)); 88 91 # Info 89 92 if ($stats{$device}{'info'}) { 90 printf("%s_%s .info %s\n", $device, $operation,93 printf("%s_%s_time.info %s\n", $device, $operation, 91 94 $stats{$device}{'info'}); 92 95 } … … 107 110 foreach my $operation ("read", "write") { 108 111 if($stats{$device}{'active'}) { 109 printf("%s_%s .value %f\n", $device, $operation,112 printf("%s_%s_time.value %f\n", $device, $operation, 110 113 &iotime(\%stats, $device, $operation)); 111 114 } … … 152 155 my $major = shift(@line); 153 156 my $minor = shift(@line); 154 my $device = shift(@line); 157 my $device = shift(@line); 158 159 $device =~ s,[^\w],_,g; 155 160 156 161 if(scalar(@line) == $DISK) { … … 214 219 } 215 220 216 # Return major number for device-mapper 221 222 223 # The dm_major subroutine takes no arguments. It return an integer 224 # use as major number for device-mapper 217 225 sub dm_major { 218 226 my $major; … … 227 235 } 228 236 237 # The dm_name subroutine takes two integer arguments. The first is 238 # the major device number, the second is the minor. 229 239 sub dm_name { 230 240 my $major = shift; … … 234 244 die unless ($major =~ /^\d+$/ && $minor =~ /^\d+$/); 235 245 236 my $foo = open(DMSETUP, "/sbin/dmsetup info --major $major --minor $minor|");246 open(DMSETUP, "/sbin/dmsetup info --major $major --minor $minor 2>/dev/null |"); 237 247 while (<DMSETUP>) { 238 248 if (/^Name:\s+(\S+)/) { … … 240 250 } 241 251 } 242 243 } 252 }
