git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm
diff options
context:
space:
mode:
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-xnagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm81
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;