This commit is contained in:
qgarnier 2021-03-11 14:15:05 +01:00 committed by GitHub
parent 4fb907b3e3
commit d968bc235c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 787 additions and 294 deletions

View File

@ -23,48 +23,111 @@ package network::hirschmann::standard::snmp::mode::components::fan;
use strict;
use warnings;
my %map_fan_status = (
my $map_classic_fan_state = {
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 = {
hmFanState => { oid => '.1.3.6.1.4.1.248.14.1.3.1.3', map => \%map_fan_status },
my $mapping_classic_fan = {
fan_state => { oid => '.1.3.6.1.4.1.248.14.1.3.1.3', map => $map_classic_fan_state } # hmFanState
};
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 {
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 {
sub check_fan_classic {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'fan'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{hmFanState}->{oid}}})) {
next if ($oid !~ /^$mapping->{hmFanState}->{oid}\.(.*)$/);
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, results => $self->{results}->{$mapping->{hmFanState}->{oid}}, instance => $instance);
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->{hmFanState},
$instance
));
my $exit = $self->get_severity(section => 'fan', value => $result->{hmFanState});
$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->{hmFanState}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"fan '%s' status is %s",
$instance, $result->{fan_state}
)
);
}
}
}
1;
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 {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'fan'));
check_fan_classic($self) if ($self->{os_type} eq 'classic');
check_fan_hios($self) if ($self->{os_type} eq 'hios');
}
1;

View File

@ -23,84 +23,149 @@ package network::hirschmann::standard::snmp::mode::components::led;
use strict;
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',
2 => 'green',
3 => 'yellow',
4 => 'red',
);
# In MIB 'hmpriv.mib'
my $oid_hmLEDGroup = '.1.3.6.1.4.1.248.14.1.1.35';
4 => 'red'
};
my $mapping_hios_led = {
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_classic_led_group = '.1.3.6.1.4.1.248.14.1.1.35'; # hmLEDGroup
sub load {
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 $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}}) {
next if (!defined($result->{$name}));
$options{mapping}->{$name}->{oid} =~ /\.(\d+)$/;
my $instance = $1;
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].",
$instance, $result->{$name},
$instance
));
$self->{output}->output_add(
long_msg => sprintf(
"led '%s' status is %s [instance: %s].",
$instance, $result->{$name},
$instance
)
);
my $exit = $self->get_severity(section => 'led', value => $result->{$name});
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",
$instance, $result->{$name}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Led '%s' status is %s",
$instance, $result->{$name}
)
);
}
}
}
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'));
sub check_classic_led {
my ($self, %options) = @_;
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 = {
hmLEDRSPowerSupply => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.1', map => \%map_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' },
hmLEDRSRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.1.3', map => \%map_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' },
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_classic_led_status, desc => 'Standby' },
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_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 = {
hmLEDOctPowerSupply1 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.1', map => \%map_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' },
hmLEDOctRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.2.3', map => \%map_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' },
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_classic_led_status, desc => 'PowerSupply2' },
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_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 = {
hmLEDRSRPowerSupply => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.1', map => \%map_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' },
hmLEDRSRRedundancyManager => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.3', map => \%map_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' },
hmLEDRSRRelay1 => { oid => '.1.3.6.1.4.1.248.14.1.1.35.3.5', map => \%map_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' },
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_classic_led_status, desc => 'Standby' },
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_classic_led_status, desc => 'Fault' },
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_classic_led_status, desc => 'Relay2' }
};
} else {
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;

View File

@ -23,73 +23,148 @@ package network::hirschmann::standard::snmp::mode::components::psu;
use strict;
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',
2 => 'failed',
3 => 'notInstalled',
4 => 'unknown',
);
my %map_psu_state = (
1 => 'error', 2 => 'ignore',
);
my %map_psid = (
1 => 9, # hmDevMonSensePS1State
2 => 10, # hmDevMonSensePS2State
3 => 14, # hmDevMonSensePS3State
4 => 15, # hmDevMonSensePS4State
5 => 17, # hmDevMonSensePS5State
6 => 18, # hmDevMonSensePS6State
7 => 19, # hmDevMonSensePS7State
8 => 20, # hmDevMonSensePS8State
);
# In MIB 'hmpriv.mib'
my $mapping = {
hmPSState => { oid => '.1.3.6.1.4.1.248.14.1.2.1.3', map => \%map_psu_status },
4 => 'unknown'
};
my $map_classic_psu_mon = {
1 => 'error', 2 => 'ignore'
};
my $mapping_classic_devmon = {
ps1_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.9', map => $map_classic_psu_mon }, # hmDevMonSensePS1State
ps2_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.10', map => $map_classic_psu_mon }, # hmDevMonSensePS2State
ps3_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.14', map => $map_classic_psu_mon }, # hmDevMonSensePS3State
ps4_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.15', map => $map_classic_psu_mon }, # hmDevMonSensePS4State
ps5_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.17', map => $map_classic_psu_mon }, # hmDevMonSensePS5State
ps6_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.18', map => $map_classic_psu_mon }, # hmDevMonSensePS6State
ps7_mon => { oid => '.1.3.6.1.4.1.248.14.2.12.3.1.19', map => $map_classic_psu_mon }, # hmDevMonSensePS7State
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 = {
psu_state => { oid => '.1.3.6.1.4.1.248.14.1.2.1.3', map => $map_classic_psu_state } # hmPSState
};
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 {
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 {
sub check_psu_classic {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{hmPSState}->{oid}}})) {
next if ($oid !~ /^$mapping->{hmPSState}->{oid}\.(\d+)\.(\d+)$/);
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, results => $self->{results}->{$mapping->{hmPSState}->{oid}}, instance => $instance);
my $result = $self->{snmp}->map_instance(
mapping => $mapping_classic_psu,
results => $self->{results}->{ $mapping_classic_psu->{psu_state}->{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');
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->{hmPSState} =~ /notInstalled/i &&
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->{hmPSState},
$instance
));
my $exit = $self->get_severity(section => 'psu', value => $result->{hmPSState});
$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->{hmPSState}));
$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 {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'Checking power supplies');
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
check_psu_classic($self) if ($self->{os_type} eq 'classic');
check_psu_hios($self) if ($self->{os_type} eq 'hios');
}
1;

View File

@ -23,57 +23,84 @@ package network::hirschmann::standard::snmp::mode::components::temperature;
use strict;
use warnings;
# In MIB 'hmpriv.mib'
my $mapping = {
hmTemperature => { oid => '.1.3.6.1.4.1.248.14.2.5.1' },
hmTempUprLimit => { oid => '.1.3.6.1.4.1.248.14.2.5.2' },
hmTempLwrLimit => { oid => '.1.3.6.1.4.1.248.14.2.5.3' },
my $mapping_classic_temp = {
temp_current => { oid => '.1.3.6.1.4.1.248.14.2.5.1' }, # hmTemperature
temp_upper_limit => { oid => '.1.3.6.1.4.1.248.14.2.5.2' }, # hmTempUprLimit
temp_lower_limit => { oid => '.1.3.6.1.4.1.248.14.2.5.3' } # hmTempLwrLimit
};
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 {
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 {
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'));
return if (!defined($self->{results}->{$oid_hmTempTable}->{$mapping->{hmTemperature}->{oid} . '.0'}));
sub check_temp {
my ($self, %options) = @_;
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));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature is %dC [instance: %s].",
$result->{hmTemperature},
$instance));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{hmTemperature});
$self->{output}->output_add(
long_msg => sprintf(
"temperature is %dC [instance: %s].",
$result->{temp_current},
$instance
)
);
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temp_current});
if ($checked == 0) {
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 => 'critical-temperature-instance-' . $instance, value => $crit_th);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature is %s degree centigrade", $result->{hmTemperature}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Temperature is %s degree centigrade", $result->{hmTemperature})
);
}
$self->{output}->perfdata_add(
label => "temp", unit => 'C',
nlabel => 'hardware.temperature.celsius',
value => $result->{hmTemperature},
unit => 'C',
value => $result->{temp_current},
warning => $warn,
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;

View 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

View File

@ -20,61 +20,98 @@
package network::hirschmann::standard::snmp::mode::cpu;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use strict;
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 {
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;
$options{options}->add_options(arguments => {
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
my $map_enable = {
1 => 'enable', 2 => 'disable'
};
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
my $mapping = {
hios => {
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
cpu_util_avg => { oid => '.1.3.6.1.4.1.248.11.22.1.8.10.2' } # hm2DiagCpuAverageUtilization
},
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->{global} = {
cpu_util => $result->{cpu_util},
cpu_util_avg => $result->{cpu_util_avg}
};
}
sub run {
sub manage_selection {
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 $result = $self->{snmp}->get_leef(oids => [$oid_hmCpuUtilization],
nothing_quit => 1);
my $cpu = $result->{$oid_hmCpuUtilization};
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();
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})) ],
nothing_quit => 1
);
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);
}
}
1;
@ -83,18 +120,14 @@ __END__
=head1 MODE
Check CPU usage.
hmEnableMeasurement must be activated (value = 1).
Check cpu.
=over 8
=item B<--warning>
=item B<--warning-*> B<--critical-*>
Threshold warning in %.
=item B<--critical>
Threshold critical in %.
Thresholds.
Can be: 'cpu-utilization-current' (%), 'cpu-utilization-30m' (%).
=back

View File

@ -28,44 +28,76 @@ use warnings;
sub set_system {
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->{thresholds} = {
fan => [
#hios
['not-available', 'OK'],
['available-and-ok', 'OK'],
['available-but-failure', 'CRITICAL'],
# classic
['ok', 'OK'],
['failed', 'CRITICAL'],
['failed', 'CRITICAL']
],
psu => [
# classic
['ok', 'OK'],
['failed', 'CRITICAL'],
['notInstalled', 'OK'],
['unknown', 'UNKNOWN'],
['ignore', 'OK'],
# hios
['present', 'OK'],
['defective', 'CRITICAL']
],
led => [
['off', 'OK'],
['green', 'OK'],
['yellow', 'WARNING'],
['red', 'CRITICAL'],
],
['red', 'CRITICAL']
]
};
$self->{myrequest} = {
classic => [],
hios => []
};
$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 {
my ($self, %options) = @_;
$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 {
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;
$options{options}->add_options(arguments => {});
@ -79,7 +111,7 @@ __END__
=head1 MODE
Check Hardware (Power Supplies, Fans, Temperatures, LEDs).
Check hardware.
=over 8

View File

@ -20,71 +20,116 @@
package network::hirschmann::standard::snmp::mode::memory;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use strict;
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 {
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;
$options{options}->add_options(arguments => {
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
my $map_enable = {
1 => 'enable', 2 => 'disable'
};
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
my $mapping = {
hios => {
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
ram_free => { oid => '.1.3.6.1.4.1.248.11.22.1.8.11.2' } # hm2DiagMemoryRamFree
},
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();
}
$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) = @_;
$self->{snmp} = $options{snmp};
my $oid_hmMemoryFree = '.1.3.6.1.4.1.248.14.2.15.3.2.0'; # in KBytes
my $oid_hmMemoryAllocated = '.1.3.6.1.4.1.248.14.2.15.3.1.0'; # in KBytes
my $result = $self->{snmp}->get_leef(oids => [$oid_hmMemoryFree, $oid_hmMemoryAllocated],
nothing_quit => 1);
my $mem_free = $result->{$oid_hmMemoryFree} * 1024;
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();
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})) ],
nothing_quit => 1
);
if ($self->check_memory(snmp => $options{snmp}, type => 'hios', snmp_result => $snmp_result) == 0) {
$self->check_memory(snmp => $options{snmp}, type => 'classic', snmp_result => $snmp_result);
}
}
1;
@ -93,18 +138,14 @@ __END__
=head1 MODE
Check Memory usage.
hmEnableMeasurement must be activated (value = 1).
Check memory.
=over 8
=item B<--warning>
=item B<--warning-*> B<--critical-*>
Threshold warning in %.
=item B<--critical>
Threshold critical in %.
Thresholds.
Can be: 'memory-usage' (B), 'memory-usage-free' (B), 'memory-usage-prct' (%).
=back

View File

@ -20,61 +20,95 @@
package network::hirschmann::standard::snmp::mode::processcount;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use strict;
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 {
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;
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
$options{options}->add_options(arguments => {
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
my $map_enable = {
1 => 'enable', 2 => 'disable'
};
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
my $mapping = {
hios => {
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
proc_run_max => { oid => '.1.3.6.1.4.1.248.11.22.1.8.10.4' } # hm2DiagCpuMaxRunningProcesses
},
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->{global} = $result;
}
sub run {
sub manage_selection {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_hmCpuRunningProcesses = '.1.3.6.1.4.1.248.14.2.15.2.3.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_hmCpuRunningProcesses],
nothing_quit => 1);
my $processcount = $result->{$oid_hmCpuRunningProcesses};
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();
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%{$mapping->{hios}}), values(%{$mapping->{classic}})) ],
nothing_quit => 1
);
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);
}
}
1;
@ -84,17 +118,13 @@ __END__
=head1 MODE
Check number of processes.
hmEnableMeasurement must be activated (value = 1).
=over 8
=item B<--warning>
=item B<--warning-*> B<--critical-*>
Threshold warning (process count).
=item B<--critical>
Threshold critical (process count).
Thresholds.
Can be: 'processes-running-current', 'processes-running-max'.
=back

View File

@ -30,14 +30,15 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
$self->{modes} = {
'configuration' => 'network::hirschmann::standard::snmp::mode::configuration',
'cpu' => 'network::hirschmann::standard::snmp::mode::cpu',
'hardware' => 'network::hirschmann::standard::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::hirschmann::standard::snmp::mode::memory',
'processcount' => 'network::hirschmann::standard::snmp::mode::processcount',
);
'processcount' => 'network::hirschmann::standard::snmp::mode::processcount'
};
return $self;
}
@ -48,6 +49,6 @@ __END__
=head1 PLUGIN DESCRIPTION
Check Hirschmann in SNMP (HMPRIV-MGMT-SNMP-MIB).
Check Hirschmann in SNMP.
=cut