Debian Codegraph @

check_hpasm/src/plugins-scripts/HP/Proliant/Component/FanSubsystem/CLI.pm

raw
1 package HP::Proliant::Component::FanSubsystem::CLI;
2 our @ISA = qw(HP::Proliant::Component::FanSubsystem);
3
4 use strict;
5 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
6
7 sub new {
8 my $class = shift;
9 my %params = @_;
10 my $self = {
11 runtime => $params{runtime},
12 rawdata => $params{rawdata},
13 fans => [],
14 blacklisted => 0,
15 info => undef,
16 extendedinfo => undef,
17 };
18 bless $self, $class;
19 $self->init(%params);
20 return $self;
21 }
22
23 # partner not available = cpqHeFltTolFanRedundantPartner=0
24 # cpqHeFltTolFanTypeValue = other
25 sub init {
26 my $self = shift;
27 my %params = @_;
28 my %tmpfan = ();
29 foreach (grep(/^fans/, split(/\n/, $self->{rawdata}))) {
30 s/^fans //g;
31 if (/^#(\d+)\s+([\w#_\/\-]+)\s+(\w+)\s+(\w+)\s+(FAILED|[N\/A\d]+)%*\s+([\w\/]+)\s+(FAILED|[N\/A\d]+)\s+(\w+)/) {
32 %tmpfan = (
33 cpqHeFltTolFanIndex => $1,
34 cpqHeFltTolFanLocale => lc $2,
35 cpqHeFltTolFanPresent => lc $3,
36 cpqHeFltTolFanSpeed => lc $4,
37 cpqHeFltTolFanPctMax => lc $5, # (FAILED|[N\/A\d]+)
38 cpqHeFltTolFanRedundant => lc $6,
39 cpqHeFltTolFanRedundantPartner => lc $7, # (FAILED|[N\/A\d]+)
40 cpqHeFltTolFanHotPlug => lc $8,
41 );
42 } elsif (/^#(\d+)\s+([\w#_\/\-]+?)(Yes|No|N\/A)\s+(\w+)\s+(FAILED|[N\/A\d]+)%*\s+([\w\/]+)\s+(FAILED|[N\/A\d]+)\s+(\w+)/) {
43 # #5 SCSI_BACKPLANE_ZONEYes NORMAL N/A ....
44 %tmpfan = (
45 cpqHeFltTolFanIndex => $1,
46 cpqHeFltTolFanLocale => lc $2,
47 cpqHeFltTolFanPresent => lc $3,
48 cpqHeFltTolFanSpeed => lc $4,
49 cpqHeFltTolFanPctMax => lc $5,
50 cpqHeFltTolFanRedundant => lc $6,
51 cpqHeFltTolFanRedundantPartner => lc $7,
52 cpqHeFltTolFanHotPlug => lc $8,
53 );
54 } elsif (/^#(\d+)\s+([\w#_\/\-]+)\s+[NOno]+\s/) {
55 # Fan is not installed. #2 CPU#2 No - - No N/A -
56 } elsif (/^#(\d+)/) {
57 main::contact_author("FAN", $_);
58 }
59 if (%tmpfan) {
60 $tmpfan{runtime} = $params{runtime};
61 $tmpfan{cpqHeFltTolFanChassis} = 1; # geht aus hpasmcli nicht hervor
62 $tmpfan{cpqHeFltTolFanType} = 'other';
63 if ($tmpfan{cpqHeFltTolFanPctMax} !~ /^\d+$/) {
64 if ($tmpfan{cpqHeFltTolFanSpeed} eq 'normal') {
65 $tmpfan{cpqHeFltTolFanPctMax} = 50;
66 } elsif ($tmpfan{cpqHeFltTolFanSpeed} eq 'high') {
67 $tmpfan{cpqHeFltTolFanPctMax} = 100;
68 } else {
69 $tmpfan{cpqHeFltTolFanPctMax} = 0;
70 }
71 }
72 if($tmpfan{cpqHeFltTolFanSpeed} eq 'failed') {
73 $tmpfan{cpqHeFltTolFanCondition} = 'failed';
74 } elsif($tmpfan{cpqHeFltTolFanSpeed} eq 'n/a') {
75 $tmpfan{cpqHeFltTolFanCondition} = 'other';
76 } else {
77 $tmpfan{cpqHeFltTolFanCondition} = 'ok';
78 }
79 $tmpfan{cpqHeFltTolFanRedundant} =
80 $tmpfan{cpqHeFltTolFanRedundant} eq 'yes' ? 'redundant' :
81 $tmpfan{cpqHeFltTolFanRedundant} eq 'no' ? 'notRedundant' : 'other';
82 $tmpfan{cpqHeFltTolFanPresent} =
83 $tmpfan{cpqHeFltTolFanPresent} eq 'yes' ? 'present' :
84 $tmpfan{cpqHeFltTolFanPresent} eq 'failed' ? 'present' :
85 $tmpfan{cpqHeFltTolFanPresent} eq 'no' ? 'absent' : 'other';
86 $tmpfan{cpqHeFltTolFanHotPlug} =
87 $tmpfan{cpqHeFltTolFanHotPlug} eq 'yes' ? 'hotPluggable' :
88 $tmpfan{cpqHeFltTolFanHotPlug} eq 'no' ? 'nonHotPluggable' : 'other';
89 push(@{$self->{fans}},
90 HP::Proliant::Component::FanSubsystem::Fan->new(%tmpfan));
91 %tmpfan = ();
92 }
93 }
94 }
95
96 sub overall_check {
97 my $self = shift;
98 # nix. nur wegen der gleichheit mit snmp
99 return 0;
100 }
101 1;