Implement peth_port_neg_power, reporting the actual negotiated value

in CiscoPower and the max for the class in the generic PowerEthernet.
This commit is contained in:
Bill Fenner
2010-11-08 07:49:40 +00:00
parent 77982188bd
commit 4fb63d8a7b
2 changed files with 68 additions and 1 deletions

View File

@@ -41,7 +41,8 @@ use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.01';
%MIBS = ( 'CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex' );
%MIBS = ( 'CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex',
'CISCO-CDP-MIB' => 'cdpCachePowerConsumption' );
%GLOBALS = ();
@@ -72,6 +73,31 @@ sub peth_port_ifindex {
return $peth_port_ifindex;
}
# peth_port_neg_power uses the same index as the other peth_port_* tables.
# However, cdpCachePowerConsumption uses <ifIndex>.<neighbor>.
# Therefore, we have to invert peth_port_ifindex, to get to
# the index that is expected and the rest of the code can re-invert it.
sub peth_port_neg_power {
my $cpeth = shift;
my $partial = shift;
# Ignoring partial, since it's not easy to implement properly.
my $index = $cpeth->peth_port_ifindex();
my %inverse_index;
foreach my $i ( keys %$index ) {
$inverse_index{ $index->{$i} } = $i;
}
my $neg_power = $cpeth->cdpCachePowerConsumption();
my $peth_port_neg_power = {};
foreach my $i ( keys %$neg_power ) {
my( $ifIndex, $nbrIndex ) = split( /\./, $i );
if ( defined( $inverse_index{ $ifIndex } ) ) {
$peth_port_neg_power->{ $inverse_index{ $ifIndex } } = $neg_power->{ $i };
}
}
return $peth_port_neg_power;
}
1;
__END__
@@ -153,4 +179,15 @@ Power supplied by PoE ports, in milliwatts
=back
=head2 CDP Port table
=over
=item $poe->peth_port_neg_power()
Power negotiated using CDP, in milliwats
("cdpCachePowerConsumption")
=back
=cut