Changeset 896

Show
Ignore:
Timestamp:
04/04/05 04:45:41 (7 years ago)
Author:
ilmari
Message:

Add -rows option to Munin::Plugin::SNMP get_hash()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/ilmari/modularisation-branch/node/SNMP.pm.in

    r866 r896  
    117117                         [-contextengineid => $engine_id,] # v3  
    118118                         [-contextname     => $name,]      # v3 
     119                         [-rows            => \@rows,] 
    119120                         -baseoid          => $oid, 
    120121                         -cols             => \%columns 
     
    122123 
    123124This method calls C<get_table()> with all the given arguments except 
    124 C<-cols>, and then transforms the data into a hash of hashes in the 
    125 following manner: 
     125C<-cols> and C<-rows>, and then transforms the data into a hash of 
     126hashes in the following manner: 
    126127 
    127128The keys of the main hash are the last element(s) of the OIDs, after 
     
    129130are hashes with keys corresponding to the values of C<%columns> hash and 
    130131values from the subtables corresonding to the keys of C<%columns>. 
     132 
     133If C<@rows> is specified, only returns those rows. 
    131134 
    132135For this to work, all the keys of C<-cols> must have the same number of 
     
    141144                            2 => 'descr', 
    142145                            4 => 'mtu', 
    143                            } 
     146                           }, 
    144147            ); 
    145148 
     
    178181    my $base = $args{'-baseoid'}; 
    179182    my $cols = delete $args{'-cols'} or return; 
     183    my $rows = delete $args{'-rows'}; 
    180184 
    181185    my $table = $self->get_table(%args) 
    182186      or return; 
    183187 
     188    my $rowre; 
     189    if (defined $rows) { 
     190        $rowre = join '|', @$rows; 
     191    } else { 
     192        $rowre = '.*'; 
     193    } 
     194 
    184195    my $subtabs = join '|', keys %$cols; 
    185     my $re = qr/^\Q$base.\E($subtabs)\.(.*)/; 
     196    my $re = qr/^\Q$base.\E($subtabs)\.($rowre)/; 
    186197    for my $key (keys %$table) { 
    187198        $key =~ $re;