mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-26 23:24:27 +02:00
parent
4fb907b3e3
commit
d968bc235c
@ -23,20 +23,100 @@ package network::hirschmann::standard::snmp::mode::components::fan;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my %map_fan_status = (
|
my $map_classic_fan_state = {
|
||||||
1 => 'ok',
|
1 => 'ok',
|
||||||
2 => 'failed',
|
2 => 'failed'
|
||||||
);
|
};
|
||||||
|
my $map_hios_fan_state = {
|
||||||
|
1 => 'not-available',
|
||||||
|
2 => 'available-and-ok',
|
||||||
|
3 => 'available-but-failure'
|
||||||
|
};
|
||||||
|
|
||||||
# In MIB 'hmpriv.mib'
|
my $mapping_classic_fan = {
|
||||||
my $mapping = {
|
fan_state => { oid => '.1.3.6.1.4.1.248.14.1.3.1.3', map => $map_classic_fan_state } # hmFanState
|
||||||
hmFanState => { oid => '.1.3.6.1.4.1.248.14.1.3.1.3', map => \%map_fan_status },
|
};
|
||||||
|
my $mapping_hios_fan = {
|
||||||
|
fan_state => { oid => '.1.3.6.1.4.1.248.11.13.1.1.2.1.2', map => $map_hios_fan_state } # hm2FanModuleMgmtStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $mapping->{hmFanState}->{oid} };
|
push @{$self->{myrequest}->{hios}},
|
||||||
|
{ oid => $mapping_hios_fan->{fan_state}->{oid} };
|
||||||
|
push @{$self->{myrequest}->{classic}},
|
||||||
|
{ oid => $mapping_classic_fan->{fan_state}->{oid} };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_fan_classic {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_classic_fan->{fan_state}->{oid} }})) {
|
||||||
|
next if ($oid !~ /^$mapping_classic_fan->{fan_state}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
my $result = $self->{snmp}->map_instance(
|
||||||
|
mapping => $mapping_classic_fan,
|
||||||
|
results => $self->{results}->{ $mapping_classic_fan->{fan_state}->{oid} },
|
||||||
|
instance => $instance
|
||||||
|
);
|
||||||
|
|
||||||
|
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||||
|
$self->{components}->{fan}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"fan '%s' status is %s [instance: %s].",
|
||||||
|
$instance, $result->{fan_state},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'fan', value => $result->{fan_state});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"fan '%s' status is %s",
|
||||||
|
$instance, $result->{fan_state}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_fan_hios {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_hios_fan->{fan_state}->{oid} }})) {
|
||||||
|
next if ($oid !~ /^$mapping_hios_fan->{fan_state}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
my $result = $self->{snmp}->map_instance(
|
||||||
|
mapping => $mapping_hios_fan,
|
||||||
|
results => $self->{results}->{ $mapping_hios_fan->{fan_state}->{oid} },
|
||||||
|
instance => $instance
|
||||||
|
);
|
||||||
|
|
||||||
|
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||||
|
$self->{components}->{fan}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"fan '%s' status is %s [instance: %s].",
|
||||||
|
$instance, $result->{fan_state},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'fan', value => $result->{fan_state});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"fan '%s' status is %s",
|
||||||
|
$instance, $result->{fan_state}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
@ -46,25 +126,8 @@ sub check {
|
|||||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||||
return if ($self->check_filter(section => 'fan'));
|
return if ($self->check_filter(section => 'fan'));
|
||||||
|
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{hmFanState}->{oid}}})) {
|
check_fan_classic($self) if ($self->{os_type} eq 'classic');
|
||||||
next if ($oid !~ /^$mapping->{hmFanState}->{oid}\.(.*)$/);
|
check_fan_hios($self) if ($self->{os_type} eq 'hios');
|
||||||
my $instance = $1;
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{hmFanState}->{oid}}, instance => $instance);
|
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
|
||||||
$self->{components}->{fan}->{total}++;
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [instance: %s].",
|
|
||||||
$instance, $result->{hmFanState},
|
|
||||||
$instance
|
|
||||||
));
|
|
||||||
my $exit = $self->get_severity(section => 'fan', value => $result->{hmFanState});
|
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("fan '%s' status is %s",
|
|
||||||
$instance, $result->{hmFanState}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
@ -23,26 +23,77 @@ package network::hirschmann::standard::snmp::mode::components::led;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my %map_led_status = (
|
my $map_hios_led_type = {
|
||||||
|
1 => 'power', 2 => 'status', 3 => 'rm',
|
||||||
|
4 => 'envm', 5 => 'i1', 6 => 'i2'
|
||||||
|
};
|
||||||
|
my $map_hios_led_status = {
|
||||||
|
1 => 'off', 2 => 'greenSolid', 3 => 'greenBlink1', 4 => 'greenBlink3',
|
||||||
|
5 => 'greenBlink4', 6 => 'greenBlink5', 7 => 'greenBlink5i', 8 => 'yellowSolid',
|
||||||
|
9 => 'yellowBlink1',10 => 'yellowBlink3', 11 => 'yellowBlink4', 12 => 'yellowBlink5',
|
||||||
|
13 => 'redSolid', 14 => 'redBlink1', 15 => 'redBlink3', 16 => 'redBlink4', 17 => 'redBlink5'
|
||||||
|
};
|
||||||
|
my $map_classic_led_status = {
|
||||||
1 => 'off',
|
1 => 'off',
|
||||||
2 => 'green',
|
2 => 'green',
|
||||||
3 => 'yellow',
|
3 => 'yellow',
|
||||||
4 => 'red',
|
4 => 'red'
|
||||||
);
|
};
|
||||||
|
my $mapping_hios_led = {
|
||||||
# In MIB 'hmpriv.mib'
|
led_status => { oid => '.1.3.6.1.4.1.248.11.22.1.4.1.1.2', map => $map_hios_led_status } # hm2LedGlobalStatus
|
||||||
my $oid_hmLEDGroup = '.1.3.6.1.4.1.248.14.1.1.35';
|
};
|
||||||
|
my $oid_classic_led_group = '.1.3.6.1.4.1.248.14.1.1.35'; # hmLEDGroup
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $oid_hmLEDGroup };
|
push @{$self->{myrequest}->{classic}},
|
||||||
|
{ oid => $oid_classic_led_group };
|
||||||
|
push @{$self->{myrequest}->{hios}},
|
||||||
|
{ oid => $mapping_hios_led->{led_status}->{oid} };
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_led {
|
sub check_hios_led {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_hios_led->{led_status}->{oid} }})) {
|
||||||
|
next if ($oid !~ /^$mapping_hios_led->{led_status}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
|
||||||
|
my $result = $self->{snmp}->map_instance(
|
||||||
|
mapping => $mapping_hios_led,
|
||||||
|
results => $self->{results}->{ $mapping_hios_led->{led_status}->{oid} },
|
||||||
|
instance => $instance
|
||||||
|
);
|
||||||
|
|
||||||
|
next if ($self->check_filter(section => 'led', instance => $instance));
|
||||||
|
$self->{components}->{led}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"led '%s' status is %s [instance: %s].",
|
||||||
|
$map_hios_led_type->{$instance},
|
||||||
|
$result->{led_status},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'led', value => $result->{led_status});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"Led '%s' status is %s",
|
||||||
|
$map_hios_led_type->{$instance}, $result->{led_status}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_classic_led_group {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$oid_hmLEDGroup}, instance => '0');
|
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$oid_classic_led_group}, instance => 0);
|
||||||
foreach my $name (sort keys %{$options{mapping}}) {
|
foreach my $name (sort keys %{$options{mapping}}) {
|
||||||
next if (!defined($result->{$name}));
|
next if (!defined($result->{$name}));
|
||||||
|
|
||||||
@ -52,55 +103,69 @@ sub check_led {
|
|||||||
next if ($self->check_filter(section => 'led', instance => $instance));
|
next if ($self->check_filter(section => 'led', instance => $instance));
|
||||||
$self->{components}->{led}->{total}++;
|
$self->{components}->{led}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Led '%s' status is %s [instance: %s].",
|
$self->{output}->output_add(
|
||||||
$instance, $result->{$name},
|
long_msg => sprintf(
|
||||||
$instance
|
"led '%s' status is %s [instance: %s].",
|
||||||
));
|
$instance, $result->{$name},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => 'led', value => $result->{$name});
|
my $exit = $self->get_severity(section => 'led', value => $result->{$name});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Led '%s' status is %s",
|
severity => $exit,
|
||||||
$instance, $result->{$name}));
|
short_msg => sprintf(
|
||||||
|
"Led '%s' status is %s",
|
||||||
|
$instance, $result->{$name}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check_classic_led {
|
||||||
my ($self) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking leds");
|
|
||||||
$self->{components}->{led} = {name => 'leds', total => 0, skip => 0};
|
|
||||||
return if ($self->check_filter(section => 'led'));
|
|
||||||
|
|
||||||
my $mapping;
|
my $mapping;
|
||||||
if (defined($self->{results}->{$oid_hmLEDGroup}->{$oid_hmLEDGroup . '.1.1.0'})) {
|
if (defined($self->{results}->{$oid_classic_led_group}->{$oid_classic_led_group . '.1.1.0'})) {
|
||||||
$mapping = {
|
$mapping = {
|
||||||
hmLEDRSPowerSupply => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.1', map => \%map_led_status, desc => 'PowerSupply' },
|
hmLEDRSPowerSupply => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.1', map => $map_classic_led_status, desc => 'PowerSupply' },
|
||||||
hmLEDRStandby => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.2', map => \%map_led_status, desc => 'Standby' },
|
hmLEDRStandby => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.2', map => $map_classic_led_status, desc => 'Standby' },
|
||||||
hmLEDRSRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.3', map => \%map_led_status, desc => 'RedundancyManager' },
|
hmLEDRSRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.3', map => $map_classic_led_status, desc => 'RedundancyManager' },
|
||||||
hmLEDRSFault => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.4', map => \%map_led_status, desc => 'Fault' },
|
hmLEDRSFault => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.4', map => $map_classic_led_status, desc => 'Fault' }
|
||||||
};
|
};
|
||||||
} elsif (defined($self->{results}->{$oid_hmLEDGroup}->{$oid_hmLEDGroup . '.2.1.0'})) {
|
} elsif (defined($self->{results}->{$oid_classic_led_group}->{$oid_classic_led_group . '.2.1.0'})) {
|
||||||
$mapping = {
|
$mapping = {
|
||||||
hmLEDOctPowerSupply1 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.1', map => \%map_led_status, desc => 'PowerSupply1' },
|
hmLEDOctPowerSupply1 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.1', map => $map_classic_led_status, desc => 'PowerSupply1' },
|
||||||
hmLEDOctPowerSupply2 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.2', map => \%map_led_status, desc => 'PowerSupply2' },
|
hmLEDOctPowerSupply2 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.2', map => $map_classic_led_status, desc => 'PowerSupply2' },
|
||||||
hmLEDOctRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.3', map => \%map_led_status, desc => 'RedundancyManager' },
|
hmLEDOctRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.3', map => $map_classic_led_status, desc => 'RedundancyManager' },
|
||||||
hmLEDOctFault => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.4', map => \%map_led_status, desc => 'Fault' },
|
hmLEDOctFault => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.4', map => $map_classic_led_status, desc => 'Fault' }
|
||||||
};
|
};
|
||||||
} elsif (defined($self->{results}->{$oid_hmLEDGroup}->{$oid_hmLEDGroup . '.3.1.0'})) {
|
} elsif (defined($self->{results}->{$oid_classic_led_group}->{$oid_classic_led_group . '.3.1.0'})) {
|
||||||
$mapping = {
|
$mapping = {
|
||||||
hmLEDRSRPowerSupply => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.1', map => \%map_led_status, desc => 'PowerSupply' },
|
hmLEDRSRPowerSupply => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.1', map => $map_classic_led_status, desc => 'PowerSupply' },
|
||||||
hmLEDRSRStandby => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.2', map => \%map_led_status, desc => 'Standby' },
|
hmLEDRSRStandby => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.2', map => $map_classic_led_status, desc => 'Standby' },
|
||||||
hmLEDRSRRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.3', map => \%map_led_status, desc => 'RedundancyManager' },
|
hmLEDRSRRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.3', map => $map_classic_led_status, desc => 'RedundancyManager' },
|
||||||
hmLEDRSRFault => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.4', map => \%map_led_status, desc => 'Fault' },
|
hmLEDRSRFault => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.4', map => $map_classic_led_status, desc => 'Fault' },
|
||||||
hmLEDRSRRelay1 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.5', map => \%map_led_status, desc => 'Relay1' },
|
hmLEDRSRRelay1 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.5', map => $map_classic_led_status, desc => 'Relay1' },
|
||||||
hmLEDRSRRelay2 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.6', map => \%map_led_status, desc => 'Relay2' },
|
hmLEDRSRRelay2 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.6', map => $map_classic_led_status, desc => 'Relay2' }
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_led($self, mapping => $mapping);
|
check_classic_led_group($self, mapping => $mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => 'Checking leds');
|
||||||
|
$self->{components}->{led} = { name => 'leds', total => 0, skip => 0 };
|
||||||
|
return if ($self->check_filter(section => 'led'));
|
||||||
|
|
||||||
|
check_classic_led($self) if ($self->{os_type} eq 'classic');
|
||||||
|
check_hios_led($self) if ($self->{os_type} eq 'hios');
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -23,73 +23,148 @@ package network::hirschmann::standard::snmp::mode::components::psu;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my %map_psu_status = (
|
my $map_hios_psu_state = {
|
||||||
|
1 => 'present',
|
||||||
|
2 => 'defective',
|
||||||
|
3 => 'notInstalled',
|
||||||
|
4 => 'unknown'
|
||||||
|
};
|
||||||
|
my $map_classic_psu_state = {
|
||||||
1 => 'ok',
|
1 => 'ok',
|
||||||
2 => 'failed',
|
2 => 'failed',
|
||||||
3 => 'notInstalled',
|
3 => 'notInstalled',
|
||||||
4 => 'unknown',
|
4 => 'unknown'
|
||||||
);
|
};
|
||||||
my %map_psu_state = (
|
my $map_classic_psu_mon = {
|
||||||
1 => 'error', 2 => 'ignore',
|
1 => 'error', 2 => 'ignore'
|
||||||
);
|
};
|
||||||
my %map_psid = (
|
my $mapping_classic_devmon = {
|
||||||
1 => 9, # hmDevMonSensePS1State
|
ps1_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.9', map => $map_classic_psu_mon }, # hmDevMonSensePS1State
|
||||||
2 => 10, # hmDevMonSensePS2State
|
ps2_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.10', map => $map_classic_psu_mon }, # hmDevMonSensePS2State
|
||||||
3 => 14, # hmDevMonSensePS3State
|
ps3_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.14', map => $map_classic_psu_mon }, # hmDevMonSensePS3State
|
||||||
4 => 15, # hmDevMonSensePS4State
|
ps4_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.15', map => $map_classic_psu_mon }, # hmDevMonSensePS4State
|
||||||
5 => 17, # hmDevMonSensePS5State
|
ps5_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.17', map => $map_classic_psu_mon }, # hmDevMonSensePS5State
|
||||||
6 => 18, # hmDevMonSensePS6State
|
ps6_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.18', map => $map_classic_psu_mon }, # hmDevMonSensePS6State
|
||||||
7 => 19, # hmDevMonSensePS7State
|
ps7_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.19', map => $map_classic_psu_mon }, # hmDevMonSensePS7State
|
||||||
8 => 20, # hmDevMonSensePS8State
|
ps8_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.20', map => $map_classic_psu_mon } # hmDevMonSensePS8State
|
||||||
);
|
};
|
||||||
|
my $mapping_classic_psu = {
|
||||||
# In MIB 'hmpriv.mib'
|
psu_state => { oid => '.1.3.6.1.4.1.248.14.1.2.1.3', map => $map_classic_psu_state } # hmPSState
|
||||||
my $mapping = {
|
};
|
||||||
hmPSState => { oid => '.1.3.6.1.4.1.248.14.1.2.1.3', map => \%map_psu_status },
|
my $oid_classic_devmon_entry = '.1.3.6.1.4.1.248.14.2.12.3.1'; # hmDevMonConfigEntry
|
||||||
|
|
||||||
|
my $mapping_hios_psu = {
|
||||||
|
psu_state => { oid => '.1.3.6.1.4.1.248.11.11.1.1.1.1.2', map => $map_hios_psu_state } # hm2PSState
|
||||||
};
|
};
|
||||||
my $oid_hmDevMonConfigEntry = '.1.3.6.1.4.1.248.14.2.12.3.1';
|
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $mapping->{hmPSState}->{oid} }, { oid => $oid_hmDevMonConfigEntry };
|
push @{$self->{myrequest}->{classic}},
|
||||||
|
{ oid => $oid_classic_devmon_entry, start => $mapping_classic_devmon->{ps1_mon}->{oid} },
|
||||||
|
{ oid => $mapping_classic_psu->{psu_state}->{oid} };
|
||||||
|
push @{$self->{myrequest}->{hios}},
|
||||||
|
{ oid => $mapping_hios_psu->{psu_state}->{oid} };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_psu_classic {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
my $devmons = {};
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_classic_psu->{psu_state}->{oid} }})) {
|
||||||
|
next if ($oid !~ /^$mapping_classic_psu->{psu_state}->{oid}\.(\d+)\.(\d+)$/);
|
||||||
|
my $instance = $1 . '.' . $2;
|
||||||
|
my ($sysid, $psid) = ($1, $2);
|
||||||
|
my $result = $self->{snmp}->map_instance(
|
||||||
|
mapping => $mapping_classic_psu,
|
||||||
|
results => $self->{results}->{ $mapping_classic_psu->{psu_state}->{oid} },
|
||||||
|
instance => $instance
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!defined($devmons->{$sysid})) {
|
||||||
|
$devmons->{$sysid} = $self->{snmp}->map_instance(
|
||||||
|
mapping => $mapping_classic_devmon,
|
||||||
|
results => $self->{results}->{$oid_classic_devmon_entry},
|
||||||
|
instance => $sysid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($devmons->{$sysid}->{'ps' . $psid . '_mon'}) && $devmons->{$sysid}->{'ps' . $psid . '_mon'} eq 'ignore') {
|
||||||
|
$result->{psu_state} = 'ignore';
|
||||||
|
}
|
||||||
|
|
||||||
|
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||||
|
next if ($result->{psu_state} =~ /notInstalled/i &&
|
||||||
|
$self->absent_problem(section => 'psu', instance => $instance));
|
||||||
|
$self->{components}->{psu}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"power supply '%s' status is %s [instance: %s].",
|
||||||
|
$instance, $result->{psu_state},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'psu', value => $result->{psu_state});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"Power supply '%s' status is %s",
|
||||||
|
$instance, $result->{psu_state}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_psu_hios {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_hios_psu->{psu_state}->{oid} }})) {
|
||||||
|
next if ($oid !~ /^$mapping_hios_psu->{psu_state}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
|
||||||
|
my $result = $self->{snmp}->map_instance(
|
||||||
|
mapping => $mapping_hios_psu,
|
||||||
|
results => $self->{results}->{ $mapping_hios_psu->{psu_state}->{oid} },
|
||||||
|
instance => $instance
|
||||||
|
);
|
||||||
|
|
||||||
|
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||||
|
next if ($result->{psu_state} =~ /notInstalled/i &&
|
||||||
|
$self->absent_problem(section => 'psu', instance => $instance));
|
||||||
|
$self->{components}->{psu}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"power supply '%s' status is %s [instance: %s].",
|
||||||
|
$instance, $result->{psu_state},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'psu', value => $result->{psu_state});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"Power supply '%s' status is %s",
|
||||||
|
$instance, $result->{psu_state}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
$self->{output}->output_add(long_msg => 'Checking power supplies');
|
||||||
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
|
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
|
||||||
return if ($self->check_filter(section => 'psu'));
|
return if ($self->check_filter(section => 'psu'));
|
||||||
|
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{hmPSState}->{oid}}})) {
|
check_psu_classic($self) if ($self->{os_type} eq 'classic');
|
||||||
next if ($oid !~ /^$mapping->{hmPSState}->{oid}\.(\d+)\.(\d+)$/);
|
check_psu_hios($self) if ($self->{os_type} eq 'hios');
|
||||||
my $instance = $1 . '.' . $2;
|
|
||||||
my ($sysid, $psid) = ($1, $2);
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{hmPSState}->{oid}}, instance => $instance);
|
|
||||||
|
|
||||||
if (defined($map_psid{$psid}) &&
|
|
||||||
defined($self->{results}->{$oid_hmDevMonConfigEntry}->{$oid_hmDevMonConfigEntry . '.' . $map_psid{$psid} . '.' . $sysid})) {
|
|
||||||
my $state = $map_psu_state{$self->{results}->{$oid_hmDevMonConfigEntry}->{$oid_hmDevMonConfigEntry . '.' . $map_psid{$psid} . '.' . $sysid}};
|
|
||||||
$result->{hmPSState} = 'ignore' if ($state eq 'ignore');
|
|
||||||
}
|
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
|
||||||
next if ($result->{hmPSState} =~ /notInstalled/i &&
|
|
||||||
$self->absent_problem(section => 'psu', instance => $instance));
|
|
||||||
$self->{components}->{psu}->{total}++;
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s].",
|
|
||||||
$instance, $result->{hmPSState},
|
|
||||||
$instance
|
|
||||||
));
|
|
||||||
my $exit = $self->get_severity(section => 'psu', value => $result->{hmPSState});
|
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("Power supply '%s' status is %s",
|
|
||||||
$instance, $result->{hmPSState}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -23,57 +23,84 @@ package network::hirschmann::standard::snmp::mode::components::temperature;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
# In MIB 'hmpriv.mib'
|
my $mapping_classic_temp = {
|
||||||
my $mapping = {
|
temp_current => { oid => '.1.3.6.1.4.1.248.14.2.5.1' }, # hmTemperature
|
||||||
hmTemperature => { oid => '.1.3.6.1.4.1.248.14.2.5.1' },
|
temp_upper_limit => { oid => '.1.3.6.1.4.1.248.14.2.5.2' }, # hmTempUprLimit
|
||||||
hmTempUprLimit => { oid => '.1.3.6.1.4.1.248.14.2.5.2' },
|
temp_lower_limit => { oid => '.1.3.6.1.4.1.248.14.2.5.3' } # hmTempLwrLimit
|
||||||
hmTempLwrLimit => { oid => '.1.3.6.1.4.1.248.14.2.5.3' },
|
|
||||||
};
|
};
|
||||||
my $oid_hmTempTable = '.1.3.6.1.4.1.248.14.2.5';
|
my $mapping_hios_temp = {
|
||||||
|
temp_current => { oid => '.1.3.6.1.4.1.248.11.10.1.5.1' }, # hm2DevMgmtTemperature
|
||||||
|
temp_upper_limit => { oid => '.1.3.6.1.4.1.248.11.10.1.5.2' }, # hm2DevMgmtTemperatureUpperLimit
|
||||||
|
temp_lower_limit => { oid => '.1.3.6.1.4.1.248.11.10.1.5.3' } # hm2DevMgmtTemperatureLowerLimit
|
||||||
|
};
|
||||||
|
my $oid_classic_temp_table = '.1.3.6.1.4.1.248.14.2.5'; # hmTempTable
|
||||||
|
my $oid_hios_temp_table = '.1.3.6.1.4.1.248.11.10.1.5'; # hm2DeviceMgmtTemperatureGroup
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $oid_hmTempTable };
|
push @{$self->{myrequest}->{classic}},
|
||||||
|
{ oid => $oid_classic_temp_table };
|
||||||
|
push @{$self->{myrequest}->{hios}},
|
||||||
|
{ oid => $oid_hios_temp_table, end => $mapping_hios_temp->{temp_lower_limit}->{oid} };
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check_temp {
|
||||||
my ($self) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
|
||||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
|
||||||
return if ($self->check_filter(section => 'temperature'));
|
|
||||||
|
|
||||||
return if (!defined($self->{results}->{$oid_hmTempTable}->{$mapping->{hmTemperature}->{oid} . '.0'}));
|
|
||||||
my $instance = 0;
|
my $instance = 0;
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hmTempTable}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(
|
||||||
|
mapping => $options{mapping},
|
||||||
|
results => $options{results},
|
||||||
|
instance => $instance
|
||||||
|
);
|
||||||
|
return if (!defined($result->{temp_current}));
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||||
$self->{components}->{temperature}->{total}++;
|
$self->{components}->{temperature}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("temperature is %dC [instance: %s].",
|
$self->{output}->output_add(
|
||||||
$result->{hmTemperature},
|
long_msg => sprintf(
|
||||||
$instance));
|
"temperature is %dC [instance: %s].",
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{hmTemperature});
|
$result->{temp_current},
|
||||||
|
$instance
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temp_current});
|
||||||
if ($checked == 0) {
|
if ($checked == 0) {
|
||||||
my $warn_th = '';
|
my $warn_th = '';
|
||||||
my $crit_th = $result->{hmTempLwrLimit} . ':' . $result->{hmTempUprLimit};
|
my $crit_th = $result->{temp_lower_limit} . ':' . $result->{temp_upper_limit};
|
||||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||||
}
|
}
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Temperature is %s degree centigrade", $result->{hmTemperature}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Temperature is %s degree centigrade", $result->{hmTemperature})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => "temp", unit => 'C',
|
|
||||||
nlabel => 'hardware.temperature.celsius',
|
nlabel => 'hardware.temperature.celsius',
|
||||||
value => $result->{hmTemperature},
|
unit => 'C',
|
||||||
|
value => $result->{temp_current},
|
||||||
warning => $warn,
|
warning => $warn,
|
||||||
critical => $crit
|
critical => $crit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => 'Checking temperatures');
|
||||||
|
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||||
|
return if ($self->check_filter(section => 'temperature'));
|
||||||
|
|
||||||
|
check_temp($self, mapping => $mapping_classic_temp, results => $self->{results}->{$oid_classic_temp_table})
|
||||||
|
if ($self->{os_type} eq 'classic');
|
||||||
|
check_temp($self, mapping => $mapping_hios_temp, results => $self->{results}->{$oid_hios_temp_table})
|
||||||
|
if ($self->{os_type} eq 'hios');
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
126
network/hirschmann/standard/snmp/mode/configuration.pm
Normal file
126
network/hirschmann/standard/snmp/mode/configuration.pm
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2021 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package network::hirschmann::standard::snmp::mode::configuration;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"configuration status is '%s'",
|
||||||
|
$self->{result_values}->{config_status}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0 }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'status', type => 2, warning_default => '%{config_status} =~ /notInSync|outOfSync/', set => {
|
||||||
|
key_values => [ { name => 'config_status' } ],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $map_config_status = {
|
||||||
|
1 => 'ok', 2 => 'notInSync'
|
||||||
|
};
|
||||||
|
my $map_nvm_state = {
|
||||||
|
1 => 'ok', 2 => 'outOfSync', 3 => 'busy'
|
||||||
|
};
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
hios => {
|
||||||
|
config_status => { oid => '.1.3.6.1.4.1.248.11.21.1.3.1', map => $map_config_status } # hm2FMNvmState
|
||||||
|
},
|
||||||
|
classic => {
|
||||||
|
config_status => { oid => '.1.3.6.1.4.1.248.14.2.4.12', map => $map_config_status } # hmConfigurationStatus
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_config {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => 0);
|
||||||
|
return 0 if (!defined($result->{config_status}));
|
||||||
|
|
||||||
|
$self->{global} = $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
|
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})), ],
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
if ($self->check_config(snmp => $options{snmp}, type => 'hios', snmp_result => $snmp_result) == 0) {
|
||||||
|
$self->check_config(snmp => $options{snmp}, type => 'classic', snmp_result => $snmp_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check configuration status.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status (Default : '%{config_status} =~ /notInSync|outOfSync/').
|
||||||
|
Can used special variables like: %{config_status}
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status.
|
||||||
|
Can used special variables like: %{config_status}
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
@ -20,61 +20,98 @@
|
|||||||
|
|
||||||
package network::hirschmann::standard::snmp::mode::cpu;
|
package network::hirschmann::standard::snmp::mode::cpu;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
sub prefix_cpu_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Cpu utilization: ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_cpu_output', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'cpu-utilization-current', nlabel => 'cpu.utilization.current.percentage', set => {
|
||||||
|
key_values => [ { name => 'cpu_util' } ],
|
||||||
|
output_template => '%.2f%% (current)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'cpu-utilization-30m', nlabel => 'cpu.utilization.30m.percentage', set => {
|
||||||
|
key_values => [ { name => 'cpu_util_avg' } ],
|
||||||
|
output_template => '%.2f%% (30min)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"warning:s" => { name => 'warning' },
|
|
||||||
"critical:s" => { name => 'critical' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
my $map_enable = {
|
||||||
my ($self, %options) = @_;
|
1 => 'enable', 2 => 'disable'
|
||||||
$self->SUPER::init(%options);
|
};
|
||||||
|
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
my $mapping = {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
hios => {
|
||||||
$self->{output}->option_exit();
|
measure_enable => { oid => '.1.3.6.1.4.1.248.11.22.1.8.1', map => $map_enable }, # hm2DiagEnableMeasurement
|
||||||
}
|
cpu_util => { oid => '.1.3.6.1.4.1.248.11.22.1.8.10.1' }, # hm2DiagCpuUtilization
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
cpu_util_avg => { oid => '.1.3.6.1.4.1.248.11.22.1.8.10.2' } # hm2DiagCpuAverageUtilization
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
},
|
||||||
|
classic => {
|
||||||
|
measure_enable => { oid => '.1.3.6.1.4.1.248.14.2.15.1', map => $map_enable }, # hmEnableMeasurement
|
||||||
|
cpu_util => { oid => '.1.3.6.1.4.1.248.14.2.15.2.1' }, # hmCpuUtilization
|
||||||
|
cpu_util_avg => { oid => '.1.3.6.1.4.1.248.14.2.15.2.2' } # hmCpuAverageUtilization
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_cpu {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => 0);
|
||||||
|
return 0 if (!defined($result->{cpu_util}));
|
||||||
|
|
||||||
|
if ($result->{measure_enable} eq 'disable') {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'resource measurement is disabled');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
$self->{global} = {
|
||||||
|
cpu_util => $result->{cpu_util},
|
||||||
|
cpu_util_avg => $result->{cpu_util_avg}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
|
|
||||||
my $oid_hmCpuUtilization = '.1.3.6.1.4.1.248.14.2.15.2.1.0'; # in %
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
|
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})) ],
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmCpuUtilization],
|
nothing_quit => 1
|
||||||
nothing_quit => 1);
|
);
|
||||||
my $cpu = $result->{$oid_hmCpuUtilization};
|
if ($self->check_cpu(snmp => $options{snmp}, type => 'hios', snmp_result => $snmp_result) == 0) {
|
||||||
|
$self->check_cpu(snmp => $options{snmp}, type => 'classic', snmp_result => $snmp_result);
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $cpu, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("CPU Usage is %.2f%%", $cpu));
|
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => "cpu", unit => '%',
|
|
||||||
value => sprintf("%.2f", $cpu),
|
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
|
||||||
min => 0, max => 100);
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -83,18 +120,14 @@ __END__
|
|||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check CPU usage.
|
Check cpu.
|
||||||
hmEnableMeasurement must be activated (value = 1).
|
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Threshold warning in %.
|
Thresholds.
|
||||||
|
Can be: 'cpu-utilization-current' (%), 'cpu-utilization-30m' (%).
|
||||||
=item B<--critical>
|
|
||||||
|
|
||||||
Threshold critical in %.
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -28,44 +28,76 @@ use warnings;
|
|||||||
sub set_system {
|
sub set_system {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$';
|
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$';
|
||||||
|
|
||||||
$self->{cb_hook2} = 'snmp_execute';
|
$self->{cb_hook2} = 'snmp_execute';
|
||||||
|
|
||||||
$self->{thresholds} = {
|
$self->{thresholds} = {
|
||||||
fan => [
|
fan => [
|
||||||
|
#hios
|
||||||
|
['not-available', 'OK'],
|
||||||
|
['available-and-ok', 'OK'],
|
||||||
|
['available-but-failure', 'CRITICAL'],
|
||||||
|
|
||||||
|
# classic
|
||||||
['ok', 'OK'],
|
['ok', 'OK'],
|
||||||
['failed', 'CRITICAL'],
|
['failed', 'CRITICAL']
|
||||||
],
|
],
|
||||||
psu => [
|
psu => [
|
||||||
|
# classic
|
||||||
['ok', 'OK'],
|
['ok', 'OK'],
|
||||||
['failed', 'CRITICAL'],
|
['failed', 'CRITICAL'],
|
||||||
['notInstalled', 'OK'],
|
['notInstalled', 'OK'],
|
||||||
['unknown', 'UNKNOWN'],
|
['unknown', 'UNKNOWN'],
|
||||||
['ignore', 'OK'],
|
['ignore', 'OK'],
|
||||||
|
|
||||||
|
# hios
|
||||||
|
['present', 'OK'],
|
||||||
|
['defective', 'CRITICAL']
|
||||||
],
|
],
|
||||||
led => [
|
led => [
|
||||||
['off', 'OK'],
|
['off', 'OK'],
|
||||||
['green', 'OK'],
|
['green', 'OK'],
|
||||||
['yellow', 'WARNING'],
|
['yellow', 'WARNING'],
|
||||||
['red', 'CRITICAL'],
|
['red', 'CRITICAL']
|
||||||
],
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{myrequest} = {
|
||||||
|
classic => [],
|
||||||
|
hios => []
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->{components_path} = 'network::hirschmann::standard::snmp::mode::components';
|
$self->{components_path} = 'network::hirschmann::standard::snmp::mode::components';
|
||||||
$self->{components_module} = ['fan', 'psu', 'temperature', 'led'];
|
$self->{components_module} = ['fan', 'led', 'psu', 'temperature'];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub snmp_execute {
|
sub snmp_execute {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
|
||||||
|
my $hios_serial = '.1.3.6.1.4.1.248.11.10.1.1.3.0'; # hm2DevMgmtSerialNumber
|
||||||
|
my $classic_version = '.1.3.6.1.4.1.248.14.1.1.2.0'; # hmSysVersion
|
||||||
|
my $snmp_result = $self->{snmp}->get_leef(
|
||||||
|
oids => [ $hios_serial, $classic_version ],
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$self->{os_type} = 'unknown';
|
||||||
|
$self->{results} = {};
|
||||||
|
if (defined($snmp_result->{$classic_version})) {
|
||||||
|
$self->{os_type} = 'classic';
|
||||||
|
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{myrequest}->{classic});
|
||||||
|
} elsif ($snmp_result->{$hios_serial}) {
|
||||||
|
$self->{os_type} = 'hios';
|
||||||
|
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{myrequest}->{hios});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {});
|
$options{options}->add_options(arguments => {});
|
||||||
@ -79,7 +111,7 @@ __END__
|
|||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Hardware (Power Supplies, Fans, Temperatures, LEDs).
|
Check hardware.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
@ -20,71 +20,116 @@
|
|||||||
|
|
||||||
package network::hirschmann::standard::snmp::mode::memory;
|
package network::hirschmann::standard::snmp::mode::memory;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
sub custom_ram_usage_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'Memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)',
|
||||||
|
$self->{perfdata}->change_bytes(value => $self->{result_values}->{total}),
|
||||||
|
$self->{perfdata}->change_bytes(value => $self->{result_values}->{used}),
|
||||||
|
$self->{result_values}->{prct_used},
|
||||||
|
$self->{perfdata}->change_bytes(value => $self->{result_values}->{free}),
|
||||||
|
$self->{result_values}->{prct_free}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'ram', type => 0, skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{ram} = [
|
||||||
|
{ label => 'memory-usage', nlabel => 'memory.usage.bytes', set => {
|
||||||
|
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_ram_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'memory-usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => {
|
||||||
|
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_ram_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'memory-usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => {
|
||||||
|
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_ram_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
"warning:s" => { name => 'warning' },
|
|
||||||
"critical:s" => { name => 'critical' },
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
my $map_enable = {
|
||||||
my ($self, %options) = @_;
|
1 => 'enable', 2 => 'disable'
|
||||||
$self->SUPER::init(%options);
|
};
|
||||||
|
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
my $mapping = {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
hios => {
|
||||||
$self->{output}->option_exit();
|
measure_enable => { oid => '.1.3.6.1.4.1.248.11.22.1.8.1', map => $map_enable }, # hm2DiagEnableMeasurement
|
||||||
}
|
ram_total => { oid => '.1.3.6.1.4.1.248.11.22.1.8.11.1' }, # hm2DiagMemoryRamAllocated
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
ram_free => { oid => '.1.3.6.1.4.1.248.11.22.1.8.11.2' } # hm2DiagMemoryRamFree
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
},
|
||||||
|
classic => {
|
||||||
|
measure_enable => { oid => '.1.3.6.1.4.1.248.14.2.15.1', map => $map_enable }, # hmEnableMeasurement
|
||||||
|
ram_total => { oid => '.1.3.6.1.4.1.248.14.2.15.3.1' }, # hmMemoryAllocated
|
||||||
|
ram_free => { oid => '.1.3.6.1.4.1.248.14.2.15.3.2' } # hmMemoryFree
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_memory {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => 0);
|
||||||
|
return 0 if (!defined($result->{ram_free}));
|
||||||
|
|
||||||
|
if ($result->{measure_enable} eq 'disable') {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'resource measurement is disabled');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result->{ram_total} *= 1024;
|
||||||
|
$result->{ram_free} *= 1024;
|
||||||
|
$self->{ram} = {
|
||||||
|
total => $result->{ram_total},
|
||||||
|
used => $result->{ram_total} - $result->{ram_free},
|
||||||
|
free => $result->{ram_free},
|
||||||
|
prct_used => 100 - ($result->{ram_free} * 100 / $result->{ram_total}),
|
||||||
|
prct_free => $result->{ram_free} * 100 / $result->{ram_total}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
|
|
||||||
my $oid_hmMemoryFree = '.1.3.6.1.4.1.248.14.2.15.3.2.0'; # in KBytes
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
my $oid_hmMemoryAllocated = '.1.3.6.1.4.1.248.14.2.15.3.1.0'; # in KBytes
|
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})) ],
|
||||||
|
nothing_quit => 1
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmMemoryFree, $oid_hmMemoryAllocated],
|
);
|
||||||
nothing_quit => 1);
|
if ($self->check_memory(snmp => $options{snmp}, type => 'hios', snmp_result => $snmp_result) == 0) {
|
||||||
my $mem_free = $result->{$oid_hmMemoryFree} * 1024;
|
$self->check_memory(snmp => $options{snmp}, type => 'classic', snmp_result => $snmp_result);
|
||||||
my $mem_allocated = $result->{$oid_hmMemoryAllocated} * 1024;
|
}
|
||||||
|
|
||||||
my $mem_total = $mem_allocated + $mem_free;
|
|
||||||
|
|
||||||
my $mem_percent_used = ($mem_total != 0) ? $mem_allocated / $mem_total * 100 : '0';
|
|
||||||
|
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $mem_percent_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
|
||||||
|
|
||||||
my ($mem_allocated_value, $mem_allocated_unit) = $self->{perfdata}->change_bytes(value => $mem_allocated);
|
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("Memory used %s (%.2f%%)",
|
|
||||||
$mem_allocated_value . " " . $mem_allocated_unit, $mem_percent_used));
|
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => "used", unit => 'B',
|
|
||||||
value => $mem_allocated,
|
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $mem_total, cast_int => 1),
|
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $mem_total, cast_int => 1),
|
|
||||||
min => 0, max => $mem_total,
|
|
||||||
);
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -93,18 +138,14 @@ __END__
|
|||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Memory usage.
|
Check memory.
|
||||||
hmEnableMeasurement must be activated (value = 1).
|
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Threshold warning in %.
|
Thresholds.
|
||||||
|
Can be: 'memory-usage' (B), 'memory-usage-free' (B), 'memory-usage-prct' (%).
|
||||||
=item B<--critical>
|
|
||||||
|
|
||||||
Threshold critical in %.
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -20,61 +20,95 @@
|
|||||||
|
|
||||||
package network::hirschmann::standard::snmp::mode::processcount;
|
package network::hirschmann::standard::snmp::mode::processcount;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
sub prefix_proc_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Number of processes running: ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_proc_output', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'processes-running-current', nlabel => 'processes.running.current.count', set => {
|
||||||
|
key_values => [ { name => 'proc_run' } ],
|
||||||
|
output_template => '%s (current)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'processes-running-max', nlabel => 'processes.running.maximum.count', set => {
|
||||||
|
key_values => [ { name => 'proc_run_max' } ],
|
||||||
|
output_template => '%s (maximum last 30min)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
});
|
||||||
"warning:s" => { name => 'warning' },
|
|
||||||
"critical:s" => { name => 'critical' },
|
|
||||||
});
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
my $map_enable = {
|
||||||
my ($self, %options) = @_;
|
1 => 'enable', 2 => 'disable'
|
||||||
$self->SUPER::init(%options);
|
};
|
||||||
|
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
my $mapping = {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
hios => {
|
||||||
$self->{output}->option_exit();
|
measure_enable => { oid => '.1.3.6.1.4.1.248.11.22.1.8.1', map => $map_enable }, # hm2DiagEnableMeasurement
|
||||||
}
|
proc_run => { oid => '.1.3.6.1.4.1.248.11.22.1.8.10.3' }, # hm2DiagCpuRunningProcesses
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
proc_run_max => { oid => '.1.3.6.1.4.1.248.11.22.1.8.10.4' } # hm2DiagCpuMaxRunningProcesses
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
},
|
||||||
|
classic => {
|
||||||
|
measure_enable => { oid => '.1.3.6.1.4.1.248.14.2.15.1', map => $map_enable }, # hmEnableMeasurement
|
||||||
|
proc_run => { oid => '.1.3.6.1.4.1.248.14.2.15.2.3' }, # hmCpuRunningProcesses
|
||||||
|
proc_run_max => { oid => '.1.3.6.1.4.1.248.14.2.15.2.4' } # hmCpuMaxRunningProcesses
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_proc {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => 0);
|
||||||
|
return 0 if (!defined($result->{proc_run}));
|
||||||
|
|
||||||
|
if ($result->{measure_enable} eq 'disable') {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'resource measurement is disabled');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
$self->{global} = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
|
|
||||||
my $oid_hmCpuRunningProcesses = '.1.3.6.1.4.1.248.14.2.15.2.3.0';
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
|
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})) ],
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmCpuRunningProcesses],
|
nothing_quit => 1
|
||||||
nothing_quit => 1);
|
);
|
||||||
my $processcount = $result->{$oid_hmCpuRunningProcesses};
|
if ($self->check_proc(snmp => $options{snmp}, type => 'hios', snmp_result => $snmp_result) == 0) {
|
||||||
|
$self->check_proc(snmp => $options{snmp}, type => 'classic', snmp_result => $snmp_result);
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $processcount, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("Number of current processes running: %d", $processcount));
|
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => "nbproc",
|
|
||||||
value => $processcount,
|
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
|
||||||
min => 0);
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -84,17 +118,13 @@ __END__
|
|||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check number of processes.
|
Check number of processes.
|
||||||
hmEnableMeasurement must be activated (value = 1).
|
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Threshold warning (process count).
|
Thresholds.
|
||||||
|
Can be: 'processes-running-current', 'processes-running-max'.
|
||||||
=item B<--critical>
|
|
||||||
|
|
||||||
Threshold critical (process count).
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -30,14 +30,15 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
|
'configuration' => 'network::hirschmann::standard::snmp::mode::configuration',
|
||||||
'cpu' => 'network::hirschmann::standard::snmp::mode::cpu',
|
'cpu' => 'network::hirschmann::standard::snmp::mode::cpu',
|
||||||
'hardware' => 'network::hirschmann::standard::snmp::mode::hardware',
|
'hardware' => 'network::hirschmann::standard::snmp::mode::hardware',
|
||||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||||
'memory' => 'network::hirschmann::standard::snmp::mode::memory',
|
'memory' => 'network::hirschmann::standard::snmp::mode::memory',
|
||||||
'processcount' => 'network::hirschmann::standard::snmp::mode::processcount',
|
'processcount' => 'network::hirschmann::standard::snmp::mode::processcount'
|
||||||
);
|
};
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -48,6 +49,6 @@ __END__
|
|||||||
|
|
||||||
=head1 PLUGIN DESCRIPTION
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
Check Hirschmann in SNMP (HMPRIV-MGMT-SNMP-MIB).
|
Check Hirschmann in SNMP.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user