Changeset 8236 for lang/perl/App-MadEye
- Timestamp:
- 03/21/08 11:40:09 (9 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Agent/SNMP/Disk.pm
r8142 r8236 3 3 use warnings; 4 4 use App::MadEye::Plugin::Agent::Base; 5 use Net::SNMP;5 use App::MadEye::Util; 6 6 7 7 my $oid_map = { … … 17 17 18 18 my $threshold = $self->config->{config}->{threshold} or die "missing threshold"; 19 my $community = $self->config->{config}->{community} or die "missing community";20 my $port = $self->config->{config}->{port} || 161;21 my $timeout = $self->config->{config}->{timeout} || 10;22 19 23 my $session = open_session($host, $community, $port, $timeout); 24 my $response = fetch_data($session); 25 $session->close(); 20 my $response = snmp_session( 21 $self, 22 $host => sub { 23 my $session = shift; 24 25 return +{ 26 map { 27 $_ => ( 28 $session->get_table( 29 -baseoid => $oid_map->{$_}, 30 ) or die "cannot get a $_ : " . $session->error 31 ) 32 } 33 qw/hrStorageDescr hrStorageUsed hrStorageType hrStorageSize/ 34 }; 35 }, 36 ); 26 37 27 38 my $result = ''; … … 37 48 }); 38 49 return $result; 39 }40 41 sub open_session {42 my ($host, $community, $port, $timeout) = @_;43 my ($session, $error) = Net::SNMP->session(44 -hostname => $host,45 -community => $community,46 -port => $port,47 -timeout => $timeout,48 );49 if (!defined($session)) {50 warn "ERROR: $error.\n";51 }52 $session;53 }54 55 sub fetch_data {56 my $session = shift;57 58 return +{59 map {60 $_ => (61 $session->get_table(62 -baseoid => $oid_map->{$_},63 ) or die "cannot get a $_ : " . $session->error64 )65 }66 qw/hrStorageDescr hrStorageUsed hrStorageType hrStorageSize/67 };68 50 } 69 51
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)