Changeset 1486

Show
Ignore:
Timestamp:
02/20/08 15:38:35 (4 years ago)
Author:
ssm
Message:

A working graph, just not necessarily generating anything remotely useful since we lack state

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/ssm/plugins/iostat/iostat_latency

    r1484 r1486  
    55# work on operations since last invocation of the plugin. 
    66 
     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 
    714use strict; 
    8 use Data::Dumper; # for debugging only 
     15 
     16use lib $ENV{'MUNIN_LIBDIR'}; 
    917use Munin::Plugin; 
    1018 
    1119## TODO: Make %stats a global variable? 
    1220## 
    13  
    14 ## Add a .info for each point with the underlying disks for lvm, for 
    15 ## instance 
    1621 
    1722## Add state to show averages over 5 minutes, even on multi-master. 
     
    2328my %graphconfig = ('grph_title' => 'Disk stats',  
    2429                   'graph_args' => '--base 1000 -l 0', 
    25                    'graph_vlabel' => 'Miliseconds', 
     30                   'graph_vlabel' => 'Seconds', 
    2631                   'graph_category' => 'system', 
    2732                   'graph_info' => 'Average IO latency in seconds per IO operation' 
     
    4449    if ($_ > 1) { 
    4550        die "Too many arguments"; 
    46     } elsif ($_ == 1) { 
     51    } elsif ($_ == 1 && $ARGV[0] ne '') { 
    4752        for ($ARGV[0]) { 
    4853            if ($_ eq "config") { 
    4954                my %stats=&diskstats; 
    5055                printconf(\%stats, \%graphconfig); 
    51             } elsif ($_ eq "debug") { 
    52                 my %stats=&diskstats; 
    53                 print Dumper(\%stats, \%graphconfig); 
    5456            } else { 
    55                 die "Unknown argument"; 
    56             } 
     57                die 'Usage: ' 
     58           } 
    5759        } 
    5860    } else { 
     
    8587                if($stats{$device}{'active'}) { 
    8688                    # 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)); 
    8891                    # Info 
    8992                    if ($stats{$device}{'info'}) { 
    90                         printf("%s_%s.info %s\n", $device, $operation, 
     93                        printf("%s_%s_time.info %s\n", $device, $operation, 
    9194                               $stats{$device}{'info'}); 
    9295                    } 
     
    107110            foreach my $operation ("read", "write") {  
    108111                if($stats{$device}{'active'}) { 
    109                     printf("%s_%s.value %f\n", $device, $operation, 
     112                    printf("%s_%s_time.value %f\n", $device, $operation, 
    110113                           &iotime(\%stats, $device, $operation)); 
    111114                    } 
     
    152155        my $major  = shift(@line); 
    153156        my $minor  = shift(@line); 
    154         my $device = shift(@line); 
     157        my $device = shift(@line); 
     158 
     159        $device =~ s,[^\w],_,g; 
    155160 
    156161        if(scalar(@line) == $DISK) { 
     
    214219} 
    215220 
    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 
    217225sub dm_major { 
    218226    my $major; 
     
    227235} 
    228236 
     237# The dm_name subroutine takes two integer arguments.  The first is 
     238# the major device number, the second is the minor. 
    229239sub dm_name { 
    230240    my $major = shift; 
     
    234244    die unless ($major =~ /^\d+$/ && $minor =~ /^\d+$/); 
    235245 
    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 |"); 
    237247    while (<DMSETUP>) { 
    238248        if (/^Name:\s+(\S+)/) { 
     
    240250        } 
    241251    } 
    242  
    243 
     252