enhance imm
This commit is contained in:
parent
ffb1894886
commit
b95ee6ca18
|
@ -40,7 +40,7 @@ sub check {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking cpus");
|
||||
$self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0};
|
||||
$self->{components}->{cpu} = { name => 'cpus', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'cpu'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpuEntry}})) {
|
||||
|
@ -51,12 +51,20 @@ sub check {
|
|||
next if ($self->check_filter(section => 'cpu', instance => $instance));
|
||||
|
||||
$self->{components}->{cpu}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("CPU '%s' is '%s' [instance = %s]",
|
||||
$result->{cpuDescr}, $result->{cpuHealthStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'health', value => $result->{cpuHealthStatus});
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"cpu '%s' is '%s' [instance = %s]",
|
||||
$result->{cpuDescr},
|
||||
$result->{cpuHealthStatus},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'health', section => 'cpu', value => $result->{cpuHealthStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("CPU '%s' is '%s'", $result->{cpuDescr}, $result->{cpuHealthStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("CPU '%s' is '%s'", $result->{cpuDescr}, $result->{cpuHealthStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ sub check {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking disks");
|
||||
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
|
||||
$self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'disk'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_diskEntry}})) {
|
||||
|
@ -51,12 +51,20 @@ sub check {
|
|||
next if ($self->check_filter(section => 'disk', instance => $instance));
|
||||
|
||||
$self->{components}->{disk}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Disk '%s' is '%s' [instance = %s]",
|
||||
$result->{diskDescr}, $result->{diskHealthStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'health', value => $result->{diskHealthStatus});
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"disk '%s' is '%s' [instance = %s]",
|
||||
$result->{diskDescr},
|
||||
$result->{diskHealthStatus},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'health', section => 'disk', value => $result->{diskHealthStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Disk '%s' is '%s'", $result->{diskDescr}, $result->{diskHealthStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Disk '%s' is '%s'", $result->{diskDescr}, $result->{diskHealthStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ sub check {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$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'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanEntry}})) {
|
||||
|
@ -54,12 +54,18 @@ sub check {
|
|||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
|
||||
$self->{components}->{fan}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' speed is '%s' [instance = %s]",
|
||||
$result->{fanDescr}, $result->{fanSpeed}, $instance));
|
||||
my $exit = $self->get_severity(section => 'health', value => $result->{fanHealthStatus});
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fan '%s' speed is '%s' [instance = %s]",
|
||||
$result->{fanDescr}, $result->{fanSpeed}, $instance
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'health', section => 'fan', value => $result->{fanHealthStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' is '%s'", $result->{fanDescr}, $result->{fanHealthStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' is '%s'", $result->{fanDescr}, $result->{fanHealthStatus})
|
||||
);
|
||||
}
|
||||
|
||||
next if ($result->{fanSpeed} !~ /(\d+)/);
|
||||
|
@ -67,16 +73,19 @@ sub check {
|
|||
my $fan_speed = $1;
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $fan_speed);
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Fan '%s' is '%s' %%", $result->{fanDescr}, $fan_speed));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("Fan '%s' is '%s' %%", $result->{fanDescr}, $fan_speed)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'fan', unit => '%',
|
||||
nlabel => 'hardware.fan.speed.percentage',
|
||||
instances => $result->{fanDescr},
|
||||
value => $fan_speed,
|
||||
warning => $warn,
|
||||
critical => $crit, min => 0, max => 100
|
||||
critical => $crit,
|
||||
unit => '%',
|
||||
min => 0, max => 100
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,13 +54,21 @@ sub check {
|
|||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{systemHealthStat}->{oid}}, instance => '0');
|
||||
$self->{components}->{global}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("system health status is '%s'",
|
||||
$result->{systemHealthStat}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"system health status is '%s'",
|
||||
$result->{systemHealthStat}
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'global', value => $result->{systemHealthStat});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("System health status is '%s'.",
|
||||
$result->{systemHealthStat}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"System health status is '%s'.",
|
||||
$result->{systemHealthStat}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ sub check {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking memorys");
|
||||
$self->{components}->{memory} = {name => 'memorys', total => 0, skip => 0};
|
||||
$self->{components}->{memory} = { name => 'memorys', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'memory'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_memoryEntry}})) {
|
||||
|
@ -51,12 +51,18 @@ sub check {
|
|||
next if ($self->check_filter(section => 'memory', instance => $instance));
|
||||
|
||||
$self->{components}->{memory}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Memory '%s' is '%s' [instance = %s]",
|
||||
$result->{memoryDescr}, $result->{memoryHealthStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'health', value => $result->{memoryHealthStatus});
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"memory '%s' is '%s' [instance = %s]",
|
||||
$result->{memoryDescr}, $result->{memoryHealthStatus}, $instance
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'health', section => 'memory', value => $result->{memoryHealthStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Memory '%s' is '%s'", $result->{memoryDescr}, $result->{memoryHealthStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Memory '%s' is '%s'", $result->{memoryDescr}, $result->{memoryHealthStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ sub check {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking powers");
|
||||
$self->{components}->{power} = {name => 'powers', total => 0, skip => 0};
|
||||
$self->{components}->{power} = { name => 'powers', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'power'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerEntry}})) {
|
||||
|
@ -51,12 +51,18 @@ sub check {
|
|||
next if ($self->check_filter(section => 'power', instance => $instance));
|
||||
|
||||
$self->{components}->{power}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Power '%s' is '%s' [instance = %s]",
|
||||
$result->{powerDescr}, $result->{powerHealthStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'health', value => $result->{powerHealthStatus});
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"power '%s' is '%s' [instance = %s]",
|
||||
$result->{powerDescr}, $result->{powerHealthStatus}, $instance
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'health', section => 'power', value => $result->{powerHealthStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power '%s' is '%s'", $result->{powerDescr}, $result->{powerHealthStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Power '%s' is '%s'", $result->{powerDescr}, $result->{powerHealthStatus})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,13 @@ sub check {
|
|||
$result->{tempDescr} = centreon::plugins::misc::trim($result->{tempDescr});
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' value is %s C [instance: %s].",
|
||||
$result->{tempDescr}, $result->{tempReading}, $instance));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"temperature '%s' value is %s C [instance: %s].",
|
||||
$result->{tempDescr}, $result->{tempReading}, $instance
|
||||
)
|
||||
);
|
||||
|
||||
if (defined($result->{tempReading})) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{tempReading});
|
||||
if ($checked == 0) {
|
||||
|
@ -75,11 +79,13 @@ sub check {
|
|||
$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 '%s' is %s C", $result->{tempDescr}, $result->{tempReading}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' is %s C", $result->{tempDescr}, $result->{tempReading})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "temp", unit => 'C',
|
||||
unit => 'C',
|
||||
nlabel => 'hardware.temperature.celsius',
|
||||
instances => $result->{tempDescr},
|
||||
value => $result->{tempReading},
|
||||
|
|
|
@ -56,9 +56,13 @@ sub check {
|
|||
$result->{voltDescr} = centreon::plugins::misc::trim($result->{voltDescr});
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("voltage '%s' value is %s [instance: %s].",
|
||||
$result->{voltDescr}, $result->{voltReading}, $instance));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"voltage '%s' value is %s [instance: %s].",
|
||||
$result->{voltDescr}, $result->{voltReading}, $instance
|
||||
)
|
||||
);
|
||||
|
||||
if (defined($result->{voltReading})) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltReading});
|
||||
if ($checked == 0) {
|
||||
|
@ -75,11 +79,12 @@ sub check {
|
|||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' is %s", $result->{voltDescr}, $result->{voltReading}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' is %s", $result->{voltDescr}, $result->{voltReading})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "volt",
|
||||
nlabel => 'hardware.voltage.volt',
|
||||
instances => $result->{voltDescr},
|
||||
value => $result->{voltReading},
|
||||
|
|
|
@ -28,7 +28,7 @@ use warnings;
|
|||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(fan|temperature|voltage)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(?:fan|temperature|voltage)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
|
@ -59,7 +59,7 @@ sub snmp_execute {
|
|||
|
||||
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 => {});
|
||||
|
|
Loading…
Reference in New Issue