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:
@@ -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
|
||||
|
||||
@@ -89,6 +89,28 @@ sub peth_port_ifindex {
|
||||
return $peth_port_ifindex;
|
||||
}
|
||||
|
||||
# Subclasses are encouraged to override this method to report
|
||||
# what has actually been negotiated with the device, if a
|
||||
# protocol with more values (e.g., CDP) has been used.
|
||||
sub peth_port_neg_power {
|
||||
my $peth = shift;
|
||||
my $partial = shift;
|
||||
|
||||
my $peth_port_status = $peth->peth_port_status($partial);
|
||||
my $peth_port_class = $peth->peth_port_class($partial);
|
||||
|
||||
my $poemax = { 'class0' => 12950, 'class1' => 3840, 'class2' => 6490, 'class3' => 12950,
|
||||
'class4' => 25500 };
|
||||
|
||||
my $peth_port_neg_power = {};
|
||||
foreach my $i ( keys %$peth_port_status ) {
|
||||
if ($peth_port_status->{$i} eq 'deliveringPower') {
|
||||
$peth_port_neg_power->{$i} = $poemax->{ $peth_port_class->{$i} };
|
||||
}
|
||||
}
|
||||
return $peth_port_neg_power;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
@@ -187,6 +209,14 @@ implement; the MIB gives only very weak guidance.
|
||||
A given device class may implement its own version
|
||||
of this function (e.g., see Info::CiscoPower).
|
||||
|
||||
=item $poe->peth_port_neg_power()
|
||||
|
||||
The power, in milliwatts, that has been committed to this port.
|
||||
This value is derived from the 802.3af class of the device being
|
||||
powered, but may be overridden by a subclass that has information
|
||||
from another source (e.g., if a different protocol, such as CDP,
|
||||
was used to negotiate the power level.)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Power Supply Table
|
||||
|
||||
Reference in New Issue
Block a user