- Updates to fan, power supply, and serial number methods (Jeroen van Ingen)

This commit is contained in:
Eric Miller
2007-12-02 03:02:01 +00:00
parent 8c421d333a
commit dedefde79f

View File

@@ -57,6 +57,8 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $I
'STATISTICS-MIB' => 'hpSwitchCpuStat', 'STATISTICS-MIB' => 'hpSwitchCpuStat',
'NETSWITCH-MIB' => 'hpMsgBufFree', 'NETSWITCH-MIB' => 'hpMsgBufFree',
'CONFIG-MIB' => 'hpSwitchConfig', 'CONFIG-MIB' => 'hpSwitchConfig',
'SEMI-MIB' => 'hpHttpMgSerialNumber',
'HP-ICF-CHASSIS' => 'hpicfSensorObjectId',
); );
%GLOBALS = ( %GLOBALS = (
@@ -65,6 +67,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $I
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
'serial1' => 'entPhysicalSerialNum.1', 'serial1' => 'entPhysicalSerialNum.1',
'serial2' => 'hpHttpMgSerialNumber.0',
'hp_cpu' => 'hpSwitchCpuStat.0', 'hp_cpu' => 'hpSwitchCpuStat.0',
'hp_mem_total' => 'hpGlobalMemTotalBytes.1', 'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
'mem_free' => 'hpGlobalMemFreeBytes.1', 'mem_free' => 'hpGlobalMemFreeBytes.1',
@@ -96,6 +99,10 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $I
# CONFIG-MIB::hpSwitchPortTable # CONFIG-MIB::hpSwitchPortTable
'hp_duplex' => 'hpSwitchPortEtherMode', 'hp_duplex' => 'hpSwitchPortEtherMode',
'hp_duplex_admin' => 'hpSwitchPortFastEtherMode', 'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
# HP-ICF-CHASSIS
'hp_s_oid' => 'hpicfSensorObjectId',
'hp_s_name' => 'hpicfSensorDescr',
'hp_s_status' => 'hpicfSensorStatus',
); );
%MUNGE = ( %MUNGE = (
@@ -207,16 +214,11 @@ sub model {
return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model; return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model;
} }
# Some have the serial num in entity mib, some dont. # Some have the serial in entity mib, some have it in SEMI-MIB::hphttpmanageable
sub serial { sub serial {
my $hp = shift; my $hp = shift;
# procurve 2xxx have this
my $serial = $hp->serial1();
return undef unless defined $serial; my $serial = $hp->serial1() || $hp->serial2() || undef;
# 4xxx dont
return undef if $serial =~ /nosuchobject/i;
return $serial; return $serial;
} }
@@ -324,14 +326,39 @@ sub slots {
return $slots; return $slots;
} }
#sub fan { sub fan {
# my $hp = shift; my $hp = shift;
# return &sensor($hp, 'fan');
# my %ents = reverse %{$hp->e_name()}; }
#
# my $fan = $ents{'Fan'}; sub ps1_status {
# my $hp = shift;
#} return &sensor($hp, 'power', '^power supply 1') || &sensor($hp, 'power', '^power supply sensor');
}
sub ps2_status {
my $hp = shift;
return &sensor($hp, 'power', '^power supply 2') || &sensor($hp, 'power', '^redundant');
}
sub sensor {
my $hp = shift;
my $search_type = shift || 'fan';
my $search_name = shift || '';
my $hp_s_oid = $hp->hp_s_oid();
my $result;
foreach my $sensor (keys %$hp_s_oid) {
my $sensortype = &SNMP::translateObj($hp_s_oid->{$sensor});
if ($sensortype =~ /$search_type/i) {
my $sensorname = $hp->hp_s_name()->{$sensor};
my $sensorstatus = $hp->hp_s_status()->{$sensor};
if ($sensorname =~ /$search_name/i) {
$result = $sensorstatus;
}
}
}
return $result;
}
# Bridge MIB does not map Bridge Port to ifIndex correctly on all models # Bridge MIB does not map Bridge Port to ifIndex correctly on all models
sub bp_index { sub bp_index {