diff --git a/hardware/server/huawei/hmm/snmp/mode/components/blade.pm b/hardware/server/huawei/hmm/snmp/mode/components/blade.pm new file mode 100644 index 000000000..bc4e4470a --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/blade.pm @@ -0,0 +1,51 @@ +package hardware::server::huawei::hmm::snmp::mode::components::blade; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); + my %eachStatus = ("0"=>"ok","1"=>"minor","2"=>"major","3"=>"major","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); + + my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; + my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.8.0", $self->{option_results}->{bladeNum}; + my $componentTemperatureOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2012.1.2.1", $self->{option_results}->{bladeNum}; + my $tmpShortMessage = ""; + my $tmpSeverity = "unknown"; + + my $result= $self->{snmp}->get_leef(oids =>[$componentPresentOid]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get blade info error."; + }else + { + if ($result->{$componentPresentOid} eq "0") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$componentPresentOid} eq "2") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$componentPresentOid} eq "1") + { + $result= $self->{snmp}->get_leef(oids =>[$componentStatusOid]); + $tmpSeverity = $statusHash{$result->{$componentStatusOid}}; + $tmpShortMessage = $tmpShortMessage. "Blade".$self->{option_results}->{bladeNum}.":".$eachStatus{$result->{$componentStatusOid}}; + $result = $self->{snmp}->get_leef(oids =>[$componentTemperatureOid] ); + $tmpShortMessage = $tmpShortMessage." Temperature:".$result->{$componentTemperatureOid}."℃"; + }else + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + } + } + + $self->{output}->output_add(severity => $tmpSeverity, + short_msg => $tmpShortMessage); + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + + \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm b/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm new file mode 100644 index 000000000..07aa2acfa --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/cpu.pm @@ -0,0 +1,101 @@ +package hardware::server::huawei::hmm::snmp::mode::components::cpu; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); + + my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get blade info error."; + }else + { + if ($result->{$bladePresentOid} eq "0") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "2") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "1") + { + my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2006.1.4", $self->{option_results}->{bladeNum}; + my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2006.1.5", $self->{option_results}->{bladeNum}; + my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2006.1.2", $self->{option_results}->{bladeNum}; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $componentPresentOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No cpu presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $totalPresent = 0; + my $totalComponent = 0; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "1") # presence status: 0-not presence,1-presence + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $componentMarkOid.".".$endKey; + $statusOid = $componentStatusOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + if($statusHash{$tmpresult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + } + $tmpShortMessage = "cpuPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + } + }else + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + } + + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage ); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/disk.pm b/hardware/server/huawei/hmm/snmp/mode/components/disk.pm new file mode 100644 index 000000000..75744e5d6 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/disk.pm @@ -0,0 +1,100 @@ +package hardware::server::huawei::hmm::snmp::mode::components::disk; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); + + my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get blade info error."; + }else + { + if ($result->{$bladePresentOid} eq "0") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "2") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "1") + { + my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2009.1.4", $self->{option_results}->{bladeNum}; + my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2009.1.5", $self->{option_results}->{bladeNum}; + my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2009.1.2", $self->{option_results}->{bladeNum}; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $componentPresentOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No disk presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $totalPresent = 0; + my $totalComponent = 0; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "1") # presence status: 0-not presence,1-presence + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $componentMarkOid.".".$endKey; + $statusOid = $componentStatusOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + if($statusHash{$tmpresult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + } + $tmpShortMessage = "diskPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + } + }else + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + } + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/fan.pm b/hardware/server/huawei/hmm/snmp/mode/components/fan.pm new file mode 100644 index 000000000..490090389 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/fan.pm @@ -0,0 +1,70 @@ +package hardware::server::huawei::hmm::snmp::mode::components::fan; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical"); + + my $fanStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.3"; + my $fanPresenceOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.3.2001.1.1"; + + my $tmpShortMessage; + my $componentStatus ="unknown"; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $fanPresenceOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No fan presence."; + }else + { + my $endKey; + my $statusOid; + my $tmpMsg; + my $tmpResult; + my $totalPresence = 0; + my $totalComponent = 14; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $statusOid = ""; + $tmpMsg = ""; + $totalPresence++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $tmpMsg = "Fan".$endKey.":"; + $statusOid = $fanStatusOid.".".$endKey; + $tmpResult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpResult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + + if($statusHash{$tmpResult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + $tmpShortMessage = "fanPresence:".$totalPresence."\/".$totalComponent." ".$tmpShortMessage; + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/memory.pm b/hardware/server/huawei/hmm/snmp/mode/components/memory.pm new file mode 100644 index 000000000..1bbf87bdd --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/memory.pm @@ -0,0 +1,100 @@ +package hardware::server::huawei::hmm::snmp::mode::components::memory; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); + + my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get blade info error."; + }else + { + if ($result->{$bladePresentOid} eq "0") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "2") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "1") + { + my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2007.1.4", $self->{option_results}->{bladeNum}; + my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2007.1.5", $self->{option_results}->{bladeNum}; + my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2007.1.2", $self->{option_results}->{bladeNum}; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $componentPresentOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No memory presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $totalPresent = 0; + my $totalComponent = 0; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "1") # presence status: 0-not presence,1-presence + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $componentMarkOid.".".$endKey; + $statusOid = $componentStatusOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + if($statusHash{$tmpresult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + } + $tmpShortMessage = "memoryPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + } + }else + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + } + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm b/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm new file mode 100644 index 000000000..d1675ad15 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/mezz.pm @@ -0,0 +1,100 @@ +package hardware::server::huawei::hmm::snmp::mode::components::mezz; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"unknown"); + + my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get blade info error."; + }else + { + if ($result->{$bladePresentOid} eq "0") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "2") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "1") + { + my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2008.1.4", $self->{option_results}->{bladeNum}; + my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2008.1.5", $self->{option_results}->{bladeNum}; + my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2008.1.2", $self->{option_results}->{bladeNum}; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $componentPresentOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No mezz presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $totalPresent = 0; + my $totalComponent = 0; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "1") # presence status: 0-not presence,1-presence + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $componentMarkOid.".".$endKey; + $statusOid = $componentStatusOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg. $eachStatus{ $tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + if($statusHash{$tmpresult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + } + $tmpShortMessage = "mezzPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + } + }else + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + } + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/psu.pm b/hardware/server/huawei/hmm/snmp/mode/components/psu.pm new file mode 100644 index 000000000..7472dd036 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/psu.pm @@ -0,0 +1,70 @@ +package hardware::server::huawei::hmm::snmp::mode::components::psu; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical"); + + my $psuPresenceOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1.1"; + my $psuStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.4.2001.1.3"; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $psuPresenceOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No psu presence."; + }else + { + my $endKey; + my $statusOid; + my $tmpMsg; + my $tmpResult; + my $totalPresence = 0; + my $totalComponent = 6; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $statusOid = ""; + $tmpMsg = ""; + $totalPresence++; + $k =~ /\.([0-9]+)$/; + $endKey = $1 ; + $tmpMsg = "Psu".$endKey.":"; + $statusOid = $psuStatusOid.".".$endKey; + $tmpResult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpResult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + + if($statusHash{$tmpResult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpResult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + $tmpShortMessage = "psuPresence:".$totalPresence."\/".$totalComponent." ".$tmpShortMessage; + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/raid.pm b/hardware/server/huawei/hmm/snmp/mode/components/raid.pm new file mode 100644 index 000000000..234bf317d --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/raid.pm @@ -0,0 +1,105 @@ +package hardware::server::huawei::hmm::snmp::mode::components::raid; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my $bladePresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.6.0", $self->{option_results}->{bladeNum}; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + my $result= $self->{snmp}->get_leef(oids =>[$bladePresentOid]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get blade info error."; + }else + { + if ($result->{$bladePresentOid} eq "0") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s not presence.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "2") + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status indeterminate.", $self->{option_results}->{bladeNum}; + }elsif ($result->{$bladePresentOid} eq "1") + { + my $componentPresentOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2011.1.2", $self->{option_results}->{bladeNum}; + my $componentStatusOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2011.1.7", $self->{option_results}->{bladeNum}; + my $componentMarkOid = sprintf ".1.3.6.1.4.1.2011.2.82.1.82.4.%s.2011.1.3", $self->{option_results}->{bladeNum}; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $componentPresentOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No raid presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpResult; + my $totalPresent = 0; + my $totalComponent = 0; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "2") # presence status: 1-not presence,2-presence + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1 ; + $temnameOid = $componentMarkOid.".".$endKey; + $statusOid = $componentStatusOid.".".$endKey; + $tmpResult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + + $tmpMsg = $tmpResult->{$temnameOid}.":"; + $tmpResult = $self->{snmp}->get_leef(oids =>[$statusOid]); + my $tmpStatus; + if ($tmpResult->{$statusOid} eq "-1"){ + $tmpStatus = "unknown"; + }elsif($tmpResult->{$statusOid} eq "1") + { + $tmpStatus = "ok"; + }else + { + $tmpStatus = "warning"; + } + $tmpMsg = $tmpMsg.$tmpStatus." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + if($tmpStatus eq "warning") + { + $componentStatus = "warning"; + }elsif ($tmpStatus eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + } + $tmpShortMessage = "raidPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + } + }else + { + $tmpShortMessage = sprintf $tmpShortMessage."Blade%s status unknown.", $self->{option_results}->{bladeNum}; + } + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); + +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/shelf.pm b/hardware/server/huawei/hmm/snmp/mode/components/shelf.pm new file mode 100644 index 000000000..52f3a352f --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/shelf.pm @@ -0,0 +1,27 @@ +package hardware::server::huawei::hmm::snmp::mode::components::shelf; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); + + my $componentStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.2.5.0"; + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + my $tmpResult; + + $tmpResult = $self->{snmp}->get_leef(oids =>[$componentStatusOid]); + + $componentStatus = $statusHash{$tmpResult->{$componentStatusOid}}; + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); + } +1; + \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/smm.pm b/hardware/server/huawei/hmm/snmp/mode/components/smm.pm new file mode 100644 index 000000000..20d88b3d4 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/smm.pm @@ -0,0 +1,27 @@ +package hardware::server::huawei::hmm::snmp::mode::components::smm; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); + + my $componentStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.3.9.0"; + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + my $tmpResult; + + $tmpResult = $self->{snmp}->get_leef(oids =>[$componentStatusOid]); + + $componentStatus = $statusHash{$tmpResult->{$componentStatusOid}}; + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); + } +1; + \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/switch.pm b/hardware/server/huawei/hmm/snmp/mode/components/switch.pm new file mode 100644 index 000000000..391ad14c1 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/switch.pm @@ -0,0 +1,71 @@ +package hardware::server::huawei::hmm::snmp::mode::components::switch; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical"); + + my $switchPresenceOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1.1"; + my $switchStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.100.2.2001.1.3"; + + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + + $self->{snmp}->{snmp_force_getnext} = 1; + my $result = $self->{snmp}->get_table(oid => $switchPresenceOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No switch presence."; + }else + { + my $endKey; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $totalPresence = 0; + my $totalComponent = 4; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $statusOid = ""; + $tmpMsg = ""; + $totalPresence++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $tmpMsg = "Switch".$endKey.":"; + $statusOid = $switchStatusOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + + if($statusHash{$tmpresult->{$statusOid}} eq "critical") + { + $componentStatus = "critical"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "warning" && ($componentStatus ne "critical")) + { + $componentStatus = "warning"; + }elsif (($statusHash{$tmpresult->{$statusOid}}) eq "ok") + { + if ($componentStatus eq "unknown") + { + $componentStatus = "ok"; + } + } + } + $tmpShortMessage = "switchPresence:".$totalPresence."\/".$totalComponent." ".$tmpShortMessage; + } + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; + \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/components/system.pm b/hardware/server/huawei/hmm/snmp/mode/components/system.pm new file mode 100644 index 000000000..cb60fb712 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/components/system.pm @@ -0,0 +1,27 @@ +package hardware::server::huawei::hmm::snmp::mode::components::system; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("0"=>"ok","1"=>"warning","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"critical","6"=>"critical","7"=>"critical"); + + my $componentStatusOid = ".1.3.6.1.4.1.2011.2.82.1.82.1.1.0"; + my $tmpShortMessage = ""; + my $componentStatus = "unknown"; + my $tmpResult; + + $tmpResult = $self->{snmp}->get_leef(oids =>[$componentStatusOid]); + + $componentStatus = $statusHash{$tmpResult->{$componentStatusOid}}; + + $self->{output}->output_add(severity => $componentStatus, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); + } +1; + \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/mode/hardwares.pm b/hardware/server/huawei/hmm/snmp/mode/hardwares.pm new file mode 100644 index 000000000..80dae8254 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/mode/hardwares.pm @@ -0,0 +1,81 @@ +package hardware::server::huawei::hmm::snmp::mode::hardwares; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use hardware::server::huawei::hmm::snmp::mode::components::blade; +use hardware::server::huawei::hmm::snmp::mode::components::switch; +use hardware::server::huawei::hmm::snmp::mode::components::shelf; +use hardware::server::huawei::hmm::snmp::mode::components::smm; +use hardware::server::huawei::hmm::snmp::mode::components::system; +use hardware::server::huawei::hmm::snmp::mode::components::cpu; +use hardware::server::huawei::hmm::snmp::mode::components::fan; +use hardware::server::huawei::hmm::snmp::mode::components::raid; +use hardware::server::huawei::hmm::snmp::mode::components::memory; +use hardware::server::huawei::hmm::snmp::mode::components::psu; +use hardware::server::huawei::hmm::snmp::mode::components::disk; +use hardware::server::huawei::hmm::snmp::mode::components::mezz; + + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "component:s" => { name => 'component', default => 'system' }, + "bladeNum:s" => { name => 'bladeNum', default => '0' }, + }); + $self->{components} = {}; + $self->{no_components} = undef; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + if ($self->{option_results}->{component} eq 'system') { + hardware::server::huawei::hmm::snmp::mode::components::system::check($self); + } elsif ($self->{option_results}->{component} eq 'cpu') { + hardware::server::huawei::hmm::snmp::mode::components::cpu::check($self); + } elsif ($self->{option_results}->{component} eq 'fan') { + hardware::server::huawei::hmm::snmp::mode::components::fan::check($self); + } elsif ($self->{option_results}->{component} eq 'raid') { + hardware::server::huawei::hmm::snmp::mode::components::raid::check($self); + } elsif ($self->{option_results}->{component} eq 'memory') { + hardware::server::huawei::hmm::snmp::mode::components::memory::check($self); + } elsif ($self->{option_results}->{component} eq 'psu') { + hardware::server::huawei::hmm::snmp::mode::components::psu::check($self); + } elsif ($self->{option_results}->{component} eq 'disk') { + hardware::server::huawei::hmm::snmp::mode::components::disk::check($self); + } elsif ($self->{option_results}->{component} eq 'blade') { + hardware::server::huawei::hmm::snmp::mode::components::blade::check($self); + } elsif ($self->{option_results}->{component} eq 'shelf') { + hardware::server::huawei::hmm::snmp::mode::components::shelf::check($self); + } elsif ($self->{option_results}->{component} eq 'smm') { + hardware::server::huawei::hmm::snmp::mode::components::smm::check($self); + } elsif ($self->{option_results}->{component} eq 'switch') { + hardware::server::huawei::hmm::snmp::mode::components::switch::check($self); + } elsif ($self->{option_results}->{component} eq 'mezz') { + hardware::server::huawei::hmm::snmp::mode::components::mezz::check($self); + } else { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ \ No newline at end of file diff --git a/hardware/server/huawei/hmm/snmp/plugin.pm b/hardware/server/huawei/hmm/snmp/plugin.pm new file mode 100644 index 000000000..0b6b09ad8 --- /dev/null +++ b/hardware/server/huawei/hmm/snmp/plugin.pm @@ -0,0 +1,28 @@ + +package hardware::server::huawei::hmm::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'hardwares' => 'hardware::server::huawei::hmm::snmp::mode::hardwares', + ); + + return $self; +} +1; +__END__ + + +=head1 PLUGIN DESCRIPTION + +Check HUAWEI servers in SNMP. + +=cut diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/cpu.pm b/hardware/server/huawei/ibmc/snmp/mode/components/cpu.pm new file mode 100644 index 000000000..7a3c8c5a5 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/cpu.pm @@ -0,0 +1,63 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::cpu; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown"); + + my $cpuStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.15.1.0"; + my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.15.50.1.6"; + my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.15.50.1.10"; + + my $tmpShortMessage = ""; + my $totalPresent = 0; + my $totalComponent = 0; + my $result = $self->{snmp}->get_table(oid => $statusTableOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No cpu presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v ne "5") # cpu present + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $deviceTableOid.".".$endKey; + $statusOid = $statusTableOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + } + } + } + $result = $self->{snmp}->get_leef(oids =>[$cpuStatusOid]); + $tmpShortMessage = "cpuPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + + $self->{output}->output_add(severity => $statusHash{$result-> {$cpuStatusOid}}, + short_msg => $tmpShortMessage ); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/disk.pm b/hardware/server/huawei/ibmc/snmp/mode/components/disk.pm new file mode 100644 index 000000000..7b0cb6c37 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/disk.pm @@ -0,0 +1,64 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::disk; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown"); + + my $diskStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.18.1.0"; + my $presentTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.18.50.1.2"; + my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.18.50.1.3"; + my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.18.50.1.6"; + + my $tmpShortMessage = ""; + my $totalPresent = 0; + my $totalComponent = 0; + my $result = $self->{snmp}->get_table(oid => $presentTableOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No Disk presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "2") # disk present + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $deviceTableOid.".".$endKey; + $statusOid = $statusTableOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + } + } + } + $result = $self->{snmp}->get_leef(oids =>[$diskStatusOid]); + $tmpShortMessage = "diskPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + + $self->{output}->output_add(severity => $statusHash{$result-> {$diskStatusOid}}, + short_msg => $tmpShortMessage ); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/fan.pm b/hardware/server/huawei/ibmc/snmp/mode/components/fan.pm new file mode 100644 index 000000000..161a13b94 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/fan.pm @@ -0,0 +1,64 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::fan; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown"); + + my $fanStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.3.0"; + my $presentTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.50.1.3"; + my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.50.1.4"; + my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.50.1.7"; + + my $tmpShortMessage = ""; + my $totalPresent = 0; + my $totalComponent = 0; + my $result = $self->{snmp}->get_table(oid => $presentTableOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No fan presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "2") # fan present + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1 ; + $temnameOid = $deviceTableOid.".".$endKey; + $statusOid = $statusTableOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + } + } + } + $result = $self->{snmp}->get_leef(oids =>[$fanStatusOid]); + $tmpShortMessage = "fanPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + + $self->{output}->output_add(severity => $statusHash{$result-> {$fanStatusOid}}, + short_msg => $tmpShortMessage ); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/memory.pm b/hardware/server/huawei/ibmc/snmp/mode/components/memory.pm new file mode 100644 index 000000000..3aeece563 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/memory.pm @@ -0,0 +1,63 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::memory; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown"); + + my $memoryStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.16.1.0"; + my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.16.50.1.6"; + my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.16.50.1.10"; + + my $tmpShortMessage = ""; + my $totalPresent = 0; + my $totalComponent = 0; + my $result = $self->{snmp}->get_table(oid => $statusTableOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No memory presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v ne "5") # memory present + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1 ; + $temnameOid = $deviceTableOid.".".$endKey; + $statusOid = $statusTableOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage = $tmpShortMessage.$tmpMsg; + } + } + } + $result = $self->{snmp}->get_leef(oids =>[$memoryStatusOid]); + $tmpShortMessage = "memoryPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + + $self->{output}->output_add(severity => $statusHash{$result-> {$memoryStatusOid}}, + short_msg => $tmpShortMessage ); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/psu.pm b/hardware/server/huawei/ibmc/snmp/mode/components/psu.pm new file mode 100644 index 000000000..ffecd7b66 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/psu.pm @@ -0,0 +1,64 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::psu; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown"); + my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown"); + + my $psuStatueOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.1.0"; + my $presentTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.50.1.9"; + my $statueTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.50.1.7"; + my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.50.1.13"; + + my $tmpShortMessage = ""; + my $totalPresent = 0; + my $totalComponent = 0; + my $result = $self->{snmp}->get_table(oid => $presentTableOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."No psu presence."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $totalComponent++; + if ($v eq "2") # psu present + { + $totalPresent++; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + $temnameOid = $deviceTableOid.".".$endKey; + $statusOid = $statueTableOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]); + $tmpMsg = $tmpresult->{$temnameOid}.":"; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + $tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." "; + $tmpShortMessage=$tmpShortMessage.$tmpMsg; + } + } + } + $result = $self->{snmp}->get_leef(oids =>[$psuStatueOid]); + $tmpShortMessage = "psuPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage; + + $self->{output}->output_add(severity => $statusHash{$result-> {$psuStatueOid}}, + short_msg => $tmpShortMessage ); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/raid.pm b/hardware/server/huawei/ibmc/snmp/mode/components/raid.pm new file mode 100644 index 000000000..b29726938 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/raid.pm @@ -0,0 +1,102 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::raid; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my $raidStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.36.50.1.7"; + my $bbuPresentOid = ".1.3.6.1.4.1.2011.2.235.1.1.36.50.1.16"; + my $bbuStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.36.50.1.18"; + + my $tmpShortMessage = ""; + my $result = $self->{snmp}->get_table(oid => $bbuPresentOid); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get BBU info failed."; + }else + { + my $endKey; + my $temnameOid; + my $statusOid; + my $tmpMsg; + my $tmpresult; + my $v; + foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result)) + { + $v = $result->{$k}; + $endKey = "0"; + $temnameOid = ""; + $statusOid = ""; + $tmpMsg = ""; + $k =~ /\.([0-9]+)$/; + $endKey = $1; + if ($v eq "2") # BBU present + { + $statusOid = $bbuStatusOid.".".$endKey; + $tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]); + my $tmpEachstate; + if ($tmpresult->{$statusOid} eq "0") + { + $tmpEachstate="ok"; + } + else + { + $tmpEachstate="warning"; + } + $tmpMsg =$tmpMsg. "BBU ".$endKey.":".$tmpEachstate." "; + $tmpShortMessage=$tmpShortMessage.$tmpMsg; + }elsif ($v eq "1") + { + $tmpShortMessage= $tmpShortMessage."BBU".$1.":absent "; + }else + { + $tmpShortMessage= $tmpShortMessage."BBU".$1.":unknown "; + } + } + } + + $result = $self->{snmp}->get_table(oid =>$raidStatusOid); + my $raidseverity = "undefine"; + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get raid Status failed." + }else + { + while (my($k,$v)= each %$result){ + $k =~ /\.([0-9]+)$/; + + if ($v eq "65535") + { + if( $raidseverity ne "warning") + { + $raidseverity = "unknown"; + } + $tmpShortMessage = "RAID".$1.":unknown ".$tmpShortMessage; + }elsif ($v eq "0") + { + if (($raidseverity ne "warning")&&($raidseverity ne "unknown")) + { + $raidseverity = "ok"; + } + $tmpShortMessage = "RAID".$1.":ok ".$tmpShortMessage; + }else + { + $raidseverity = "warning"; + $tmpShortMessage = "RAID".$1.":warning ".$tmpShortMessage; + } + } + } + if ($raidseverity eq "undefine") + { + $raidseverity = "unknown"; + } + + $self->{output}->output_add(severity => $raidseverity , + short_msg => $tmpShortMessage ); + $self->{output}->display(); + $self->{output}->exit(); + +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/components/system.pm b/hardware/server/huawei/ibmc/snmp/mode/components/system.pm new file mode 100644 index 000000000..9ec58e0f5 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/components/system.pm @@ -0,0 +1,35 @@ +package hardware::server::huawei::ibmc::snmp::mode::components::system; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical"); + my %powerHash = ("1"=>"normalPowerOff","2"=>"powerOn","3"=>"forcedSystemReset","4"=>"forcedPowerCycle","5"=>"forcedPowerOff"); + + my $systemStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.1.1.0"; + my $deviceNameOid = ".1.3.6.1.4.1.2011.2.235.1.1.1.6.0"; + my $deviceSerialNo = ".1.3.6.1.4.1.2011.2.235.1.1.1.7.0"; + my $systemPowerState = ".1.3.6.1.4.1.2011.2.235.1.1.1.12.0"; + + my $tmpShortMessage = ""; + + my $result = $self->{snmp}->get_leef(oids =>[$systemStatusOid,$deviceNameOid,$deviceSerialNo,$systemPowerState]); + if (scalar(keys %$result) <= 0) + { + $tmpShortMessage = $tmpShortMessage."Get system info failed."; + }else + { + $tmpShortMessage = "deviceName:".$result->{$deviceNameOid}." deviceSerialNo:".$result->{$deviceSerialNo}." systemPowerStatus:".$powerHash{$result->{$systemPowerState}}; + } + + + $self->{output}->output_add(severity => $statusHash{$result->{$systemStatusOid}}, + short_msg => $tmpShortMessage); + + $self->{output}->display(); + $self->{output}->exit(); +} +1; \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/mode/hardwares.pm b/hardware/server/huawei/ibmc/snmp/mode/hardwares.pm new file mode 100644 index 000000000..3c20b7cfd --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/mode/hardwares.pm @@ -0,0 +1,65 @@ +package hardware::server::huawei::ibmc::snmp::mode::hardwares; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use hardware::server::huawei::ibmc::snmp::mode::components::system; +use hardware::server::huawei::ibmc::snmp::mode::components::cpu; +use hardware::server::huawei::ibmc::snmp::mode::components::fan; +use hardware::server::huawei::ibmc::snmp::mode::components::raid; +use hardware::server::huawei::ibmc::snmp::mode::components::memory; +use hardware::server::huawei::ibmc::snmp::mode::components::psu; +use hardware::server::huawei::ibmc::snmp::mode::components::disk; + + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "component:s" => { name => 'component', default => 'system' }, + }); + $self->{components} = {}; + $self->{no_components} = undef; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + + if ($self->{option_results}->{component} eq 'system') { + hardware::server::huawei::ibmc::snmp::mode::components::system::check($self); + } elsif ($self->{option_results}->{component} eq 'cpu') { + hardware::server::huawei::ibmc::snmp::mode::components::cpu::check($self); + } elsif ($self->{option_results}->{component} eq 'fan') { + hardware::server::huawei::ibmc::snmp::mode::components::fan::check($self); + } elsif ($self->{option_results}->{component} eq 'raid') { + hardware::server::huawei::ibmc::snmp::mode::components::raid::check($self); + } elsif ($self->{option_results}->{component} eq 'memory') { + hardware::server::huawei::ibmc::snmp::mode::components::memory::check($self); + } elsif ($self->{option_results}->{component} eq 'psu') { + hardware::server::huawei::ibmc::snmp::mode::components::psu::check($self); + } elsif ($self->{option_results}->{component} eq 'disk') { + hardware::server::huawei::ibmc::snmp::mode::components::disk::check($self); + } else { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ \ No newline at end of file diff --git a/hardware/server/huawei/ibmc/snmp/plugin.pm b/hardware/server/huawei/ibmc/snmp/plugin.pm new file mode 100644 index 000000000..59c9a9ba3 --- /dev/null +++ b/hardware/server/huawei/ibmc/snmp/plugin.pm @@ -0,0 +1,28 @@ + +package hardware::server::huawei::ibmc::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'hardwares' => 'hardware::server::huawei::ibmc::snmp::mode::hardwares', + ); + + return $self; +} +1; +__END__ + + +=head1 PLUGIN DESCRIPTION + +Check HUAWEI servers in SNMP. + +=cut