diff options
author | H. P. <coding _æ_ lirion.de> | 2019-04-17 19:07:19 +0200 |
---|---|---|
committer | H. P. <coding _æ_ lirion.de> | 2019-04-17 19:07:19 +0200 |
commit | 1e2387474a449452b78520b9ad96a8b4b5e99722 (patch) | |
tree | 836889471eec7d2aac177405068e2a8f1e2b1978 /nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm | |
download | nagios-plugins-contrib-1e2387474a449452b78520b9ad96a8b4b5e99722.tar.bz2 |
initial commit of source fetch
Diffstat (limited to 'nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm')
-rwxr-xr-x | nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm b/nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm new file mode 100755 index 0000000..c218975 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm @@ -0,0 +1,81 @@ +package HP::Proliant::Component::PowersupplySubsystem::CLI; +our @ISA = qw(HP::Proliant::Component::PowersupplySubsystem); + +use strict; +use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; + +sub new { + my $class = shift; + my %params = @_; + my $self = { + runtime => $params{runtime}, + rawdata => $params{rawdata}, + powersupplies => [], + powerconverters => [], + blacklisted => 0, + info => undef, + extendedinfo => undef, + }; + bless $self, $class; + $self->init(%params); + return $self; +} + +sub init { + my $self = shift; + my %params = @_; + my %tmpps = ( + runtime => $self->{runtime}, + cpqHeFltTolPowerSupplyChassis => 1, + ); + my $inblock = 0; + foreach (grep(/^powersupply/, split(/\n/, $self->{rawdata}))) { + s/^powersupply\s*//g; + if (/^Power supply #(\d+)/) { + if ($inblock) { + $inblock = 0; + push(@{$self->{powersupplies}}, + HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); + %tmpps = ( + runtime => $self->{runtime}, + cpqHeFltTolPowerSupplyChassis => 1, + ); + } + $tmpps{cpqHeFltTolPowerSupplyBay} = $1; + $inblock = 1; + } elsif (/\s*Present\s+:\s+(\w+)/) { + $tmpps{cpqHeFltTolPowerSupplyPresent} = lc $1 eq 'yes' ? 'present' : + lc $1 eq 'no' ? 'absent': 'other'; + } elsif (/\s*Redundant\s*:\s+(\w+)/) { + $tmpps{cpqHeFltTolPowerSupplyRedundant} = lc $1 eq 'yes' ? 'redundant' : + lc $1 eq 'no' ? 'notRedundant' : 'other'; + } elsif (/\s*Condition\s*:\s+(\w+)/) { + $tmpps{cpqHeFltTolPowerSupplyCondition} = lc $1; + } elsif (/\s*Power\s*:\s+(\d+)/) { + $tmpps{cpqHeFltTolPowerSupplyCapacityUsed} = $1; + } elsif (/\s*Power Supply not present/) { + $tmpps{cpqHeFltTolPowerSupplyPresent} = "absent"; + $tmpps{cpqHeFltTolPowerSupplyCondition} = "other"; + $tmpps{cpqHeFltTolPowerSupplyRedundant} = "notRedundant"; + } elsif (/^\s*$/) { + if ($inblock) { + $inblock = 0; + push(@{$self->{powersupplies}}, + HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); + %tmpps = ( + runtime => $self->{runtime}, + cpqHeFltTolPowerSupplyChassis => 1, + ); + } + } + } + if ($inblock) { + push(@{$self->{powersupplies}}, + HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); + %tmpps = ( + runtime => $params{runtime}, + ); + } +} + +1; |