Debian Codegraph @

src/hardware/server/lenovo/xcc/snmp/mode/components/memory.pm

raw
1 package hardware::server::lenovo::xcc::snmp::mode::components::memory;
2 use strict;
3 use warnings;
4
5 use strict;
6 use warnings;
7 use centreon::plugins::misc;
8
9 my $mapping = {
10 memoryStatus => { oid => '.1.3.6.1.4.1.19046.11.1.1.5.21.1.8' },
11 memoryString => { oid => '.1.3.6.1.4.1.19046.11.1.1.5.21.1.2' },
12 };
13
14 my $oid_memoryEntry = '.1.3.6.1.4.1.19046.11.1.1.5.21.1';
15
16 sub load {
17 my ($self) = @_;
18
19 push @{$self->{request}}, { oid => $oid_memoryEntry };
20 }
21 sub check {
22 my ($self) = @_;
23
24 $self->{output}->output_add(long_msg => "Checking memory");
25 $self->{components}->{memory} = { name => 'memory', total => 0, skip => 0 };
26 return if ($self->check_filter(section => 'memory'));
27
28 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_memoryEntry}})) {
29
30 next if ($oid !~ /^$mapping->{memoryString}->{oid}\.(.*)$/);
31
32 my $instance = $1;
33 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryEntry}, instance => $instance);
34 next if ($self->check_filter(section => 'memory', instance => $instance));
35 $result->{memoryStatus} = centreon::plugins::misc::trim($result->{memoryStatus});
36 $self->{components}->{memory}->{total}++;
37
38 $self->{output}->output_add(long_msg => sprintf("'%s' status is %s [instance: %s].",
39 $result->{memoryString}, $result->{memoryStatus}, $instance));
40
41 my $exit = $self->get_severity(label => 'default', section => 'default', value => $result->{memoryStatus});
42 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
43 $self->{output}->output_add(severity => $exit,
44 short_msg => sprintf("'%s' memory status for '%s'", $result->{memoryStatus}, $result->{memoryString}));
45 }
46 }
47 }
48 1;