Changeset 859

Show
Ignore:
Timestamp:
03/29/05 19:45:08 (7 years ago)
Author:
ilmari
Message:

Reinstated Munin::Plugin::SNMP (reverted trunk change r499).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/ilmari/modularisation-branch/ChangeLog

    r854 r859  
    1111  * Node: munin-node didn't treat default_plugin_user properly (Deb#295366). 
    1212  * Node: munin-node-configure now properly respect user plugins. 
     13  * Plugins: Add module Munin::Plugin::SNMP for simplifing SNMP plugins. 
    1314  * Plugins: linux/if* now treats ra* interfaces as wireless. 
    1415  * Plugins: minor bugfix in generic/bind9. 
  • people/ilmari/modularisation-branch/Makefile

    r746 r859  
    6161        mkdir -p $(LIBDIR)/plugins 
    6262        mkdir -p $(SBINDIR) 
    63         mkdir -p $(PERLLIB)/Munin/Plugin 
    6463 
    6564        mkdir -p $(LOGDIR) 
     
    8887        done 
    8988        $(INSTALL) -m 0644 build/node/plugins.history $(LIBDIR)/plugins/ 
     89 
     90        mkdir -p $(PERLLIB)/Munin/Plugin 
     91        $(INSTALL) -m 0644 build/node/SNMP.pm $(PERLLIB)/Munin/Plugin/ 
    9092 
    9193        #TODO: 
  • people/ilmari/modularisation-branch/node/node.d/snmp__sensors_fsc_bx_fan.in

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.4
    r499 r859  
    2222# 
    2323# $Log$ 
    24 # Revision 1.5  2004/11/23 16:59:38  jimmyo 
    25 # Include SNMP.pm in the files. We don't want any perl modules in the node for the 1.2 series. 
    26 # 
    2724# Revision 1.4  2004/11/16 20:08:26  jimmyo 
    2825# License cleanups. 
     
    4138#%# capabilities=snmpconf 
    4239 
    43 package Munin::Plugin::SNMP; 
    44  
    45 use Net::SNMP; 
    46 @ISA = qw(Net::SNMP); 
    47  
    48 sub session { 
    49     my $class = shift; 
    50     my $host      = $ENV{host}      || undef; 
    51     my $port      = $ENV{port}      || 161; 
    52     my $community = $ENV{community} || 'public'; 
    53     my $version   = $ENV{version}   || undef; 
    54  
    55     if ($0 =~ /^(?:.*\/)?snmp_([^_]+)_/) { 
    56         $host = $1; 
    57         if ($host =~ /^([^:]+):(\d+)$/) { 
    58             $host = $1; 
    59             $port = $2; 
    60         } 
    61     } elsif (!defined($host)) { 
    62         return unless wantarray; # Scalar or void context 
    63         return (undef, 'Couldn not find monitoring target.'); # Array context 
    64     } 
    65  
    66     return $class->SUPER::session(-hostname  => $host, 
    67                                   -community => $community, 
    68                                   -port      => $port, 
    69                                   ($version ? (-version => $version) : ())); 
    70 } 
    71  
    72 sub get_hash { 
    73     my $self = shift; 
    74     my %args = @_; 
    75     my %ret; 
    76      
    77     my $base = $args{'-baseoid'}; 
    78     my $cols = delete $args{'-cols'} or return; 
    79  
    80     my $table = $self->get_table(%args) 
    81       or return; 
    82  
    83     my $subtabs = join '|', keys %$cols; 
    84     my $re = qr/^\Q$base.\E($subtabs)\.(.*)/; 
    85     for my $key (keys %$table) { 
    86         $key =~ $re; 
    87         next unless defined($1 && $2); 
    88         $ret{$2}{$cols->{$1}} = $table->{$key}; 
    89     } 
    90     return \%ret; 
    91 } 
    92  
    93 package main; 
    94  
    9540use strict; 
     41use Munin::Plugin::SNMP; 
    9642use Net::SNMP qw(oid_lex_sort); 
    9743 
  • people/ilmari/modularisation-branch/node/node.d/snmp__sensors_fsc_bx_temp.in

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.4
    r499 r859  
    2222# 
    2323# $Log$ 
    24 # Revision 1.5  2004/11/23 16:59:38  jimmyo 
    25 # Include SNMP.pm in the files. We don't want any perl modules in the node for the 1.2 series. 
    26 # 
    2724# Revision 1.4  2004/11/16 20:08:26  jimmyo 
    2825# License cleanups. 
     
    4138#%# capabilities=snmpconf 
    4239 
    43 package Munin::Plugin::SNMP; 
    44  
    45 use Net::SNMP; 
    46 @ISA = qw(Net::SNMP); 
    47  
    48 sub session { 
    49     my $class = shift; 
    50     my $host      = $ENV{host}      || undef; 
    51     my $port      = $ENV{port}      || 161; 
    52     my $community = $ENV{community} || 'public'; 
    53     my $version   = $ENV{version}   || undef; 
    54  
    55     if ($0 =~ /^(?:.*\/)?snmp_([^_]+)_/) { 
    56         $host = $1; 
    57         if ($host =~ /^([^:]+):(\d+)$/) { 
    58             $host = $1; 
    59             $port = $2; 
    60         } 
    61     } elsif (!defined($host)) { 
    62         return unless wantarray; # Scalar or void context 
    63         return (undef, 'Couldn not find monitoring target.'); # Array context 
    64     } 
    65  
    66     return $class->SUPER::session(-hostname  => $host, 
    67                                   -community => $community, 
    68                                   -port      => $port, 
    69                                   ($version ? (-version => $version) : ())); 
    70 } 
    71  
    72 sub get_hash { 
    73     my $self = shift; 
    74     my %args = @_; 
    75     my %ret; 
    76      
    77     my $base = $args{'-baseoid'}; 
    78     my $cols = delete $args{'-cols'} or return; 
    79  
    80     my $table = $self->get_table(%args) 
    81       or return; 
    82  
    83     my $subtabs = join '|', keys %$cols; 
    84     my $re = qr/^\Q$base.\E($subtabs)\.(.*)/; 
    85     for my $key (keys %$table) { 
    86         $key =~ $re; 
    87         next unless defined($1 && $2); 
    88         $ret{$2}{$cols->{$1}} = $table->{$key}; 
    89     } 
    90     return \%ret; 
    91 } 
    92  
    93 package main; 
    94  
    9540use strict; 
     41use Munin::Plugin::SNMP; 
    9642use Net::SNMP qw(oid_lex_sort); 
    9743 
  • people/ilmari/modularisation-branch/node/node.d/snmp__sensors_fsc_fan.in

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.4
    r499 r859  
    2222# 
    2323# $Log$ 
    24 # Revision 1.5  2004/11/23 16:59:38  jimmyo 
    25 # Include SNMP.pm in the files. We don't want any perl modules in the node for the 1.2 series. 
    26 # 
    2724# Revision 1.4  2004/11/16 20:08:26  jimmyo 
    2825# License cleanups. 
     
    4138#%# capabilities=snmpconf 
    4239 
    43 package Munin::Plugin::SNMP; 
    44  
    45 use Net::SNMP; 
    46 @ISA = qw(Net::SNMP); 
    47  
    48 sub session { 
    49     my $class = shift; 
    50     my $host      = $ENV{host}      || undef; 
    51     my $port      = $ENV{port}      || 161; 
    52     my $community = $ENV{community} || 'public'; 
    53     my $version   = $ENV{version}   || undef; 
    54  
    55     if ($0 =~ /^(?:.*\/)?snmp_([^_]+)_/) { 
    56         $host = $1; 
    57         if ($host =~ /^([^:]+):(\d+)$/) { 
    58             $host = $1; 
    59             $port = $2; 
    60         } 
    61     } elsif (!defined($host)) { 
    62         return unless wantarray; # Scalar or void context 
    63         return (undef, 'Couldn not find monitoring target.'); # Array context 
    64     } 
    65  
    66     return $class->SUPER::session(-hostname  => $host, 
    67                                   -community => $community, 
    68                                   -port      => $port, 
    69                                   ($version ? (-version => $version) : ())); 
    70 } 
    71  
    72 sub get_hash { 
    73     my $self = shift; 
    74     my %args = @_; 
    75     my %ret; 
    76      
    77     my $base = $args{'-baseoid'}; 
    78     my $cols = delete $args{'-cols'} or return; 
    79  
    80     my $table = $self->get_table(%args) 
    81       or return; 
    82  
    83     my $subtabs = join '|', keys %$cols; 
    84     my $re = qr/^\Q$base.\E($subtabs)\.(.*)/; 
    85     for my $key (keys %$table) { 
    86         $key =~ $re; 
    87         next unless defined($1 && $2); 
    88         $ret{$2}{$cols->{$1}} = $table->{$key}; 
    89     } 
    90     return \%ret; 
    91 } 
    92  
    93 package main; 
    94  
    9540use strict; 
     41use Munin::Plugin::SNMP; 
    9642use Net::SNMP qw(oid_lex_sort); 
    9743 
  • people/ilmari/modularisation-branch/node/node.d/snmp__sensors_fsc_temp.in

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.4
    r499 r859  
    2222# 
    2323# $Log$ 
    24 # Revision 1.5  2004/11/23 16:59:38  jimmyo 
    25 # Include SNMP.pm in the files. We don't want any perl modules in the node for the 1.2 series. 
    26 # 
    2724# Revision 1.4  2004/11/16 20:08:26  jimmyo 
    2825# License cleanups. 
     
    4138#%# capabilities=snmpconf 
    4239 
    43 package Munin::Plugin::SNMP; 
    44  
    45 use Net::SNMP; 
    46 @ISA = qw(Net::SNMP); 
    47  
    48 sub session { 
    49     my $class = shift; 
    50     my $host      = $ENV{host}      || undef; 
    51     my $port      = $ENV{port}      || 161; 
    52     my $community = $ENV{community} || 'public'; 
    53     my $version   = $ENV{version}   || undef; 
    54  
    55     if ($0 =~ /^(?:.*\/)?snmp_([^_]+)_/) { 
    56         $host = $1; 
    57         if ($host =~ /^([^:]+):(\d+)$/) { 
    58             $host = $1; 
    59             $port = $2; 
    60         } 
    61     } elsif (!defined($host)) { 
    62         return unless wantarray; # Scalar or void context 
    63         return (undef, 'Couldn not find monitoring target.'); # Array context 
    64     } 
    65  
    66     return $class->SUPER::session(-hostname  => $host, 
    67                                   -community => $community, 
    68                                   -port      => $port, 
    69                                   ($version ? (-version => $version) : ())); 
    70 } 
    71  
    72 sub get_hash { 
    73     my $self = shift; 
    74     my %args = @_; 
    75     my %ret; 
    76      
    77     my $base = $args{'-baseoid'}; 
    78     my $cols = delete $args{'-cols'} or return; 
    79  
    80     my $table = $self->get_table(%args) 
    81       or return; 
    82  
    83     my $subtabs = join '|', keys %$cols; 
    84     my $re = qr/^\Q$base.\E($subtabs)\.(.*)/; 
    85     for my $key (keys %$table) { 
    86         $key =~ $re; 
    87         next unless defined($1 && $2); 
    88         $ret{$2}{$cols->{$1}} = $table->{$key}; 
    89     } 
    90     return \%ret; 
    91 } 
    92  
    93 package main; 
    94  
    9540use strict; 
     41use Munin::Plugin::SNMP; 
    9642use Net::SNMP qw(oid_lex_sort); 
    9743