enhance indent

This commit is contained in:
garnier-quentin 2020-01-22 10:25:52 +01:00
parent 1e11c6218f
commit 3fa466c595
12 changed files with 209 additions and 143 deletions

View File

@ -49,13 +49,13 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-severity:s@' => { name => 'filter_severity', },
"filter-severity:s@" => { name => 'filter_severity', }, 'filter-message:s' => { name => 'filter_message' },
"filter-message:s" => { name => 'filter_message' }, 'retention:s' => { name => 'retention' },
"retention:s" => { name => 'retention' }, 'memory' => { name => 'memory' },
"memory" => { name => 'memory' },
}); });
$self->{statefile_cache} = centreon::plugins::statefile->new(%options); $self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{severities} = {}; $self->{severities} = {};
return $self; return $self;

View File

@ -57,16 +57,22 @@ sub check {
next if ($self->absent_problem(section => 'blade', instance => $blade_dn)); next if ($self->absent_problem(section => 'blade', instance => $blade_dn));
next if ($self->check_filter(section => 'blade', instance => $blade_dn)); next if ($self->check_filter(section => 'blade', instance => $blade_dn));
$self->{output}->output_add(long_msg => sprintf("blade '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"blade '%s' state is '%s' [presence: %s].",
$blade_dn, $result2->{cucsComputeBladeOperState}, $blade_dn, $result2->{cucsComputeBladeOperState},
$result->{cucsComputeBladePresence}) $result->{cucsComputeBladePresence}
)
); );
my $exit = $self->get_severity(section => 'blade.presence', label => 'default.presence', value => $result->{cucsComputeBladePresence}); my $exit = $self->get_severity(section => 'blade.presence', label => 'default.presence', value => $result->{cucsComputeBladePresence});
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("blade '%s' presence is: '%s'", severity => $exit,
$blade_dn, $result->{cucsComputeBladePresence}) short_msg => sprintf(
"blade '%s' presence is: '%s'",
$blade_dn, $result->{cucsComputeBladePresence}
)
); );
next; next;
} }
@ -75,8 +81,10 @@ sub check {
$exit = $self->get_severity(section => 'blade.overall_status', label => 'default.overall_status', value => $result2->{cucsComputeBladeOperState}); $exit = $self->get_severity(section => 'blade.overall_status', label => 'default.overall_status', value => $result2->{cucsComputeBladeOperState});
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("blade '%s' state is '%s'", severity => $exit,
short_msg => sprintf(
"blade '%s' state is '%s'",
$blade_dn, $result2->{cucsComputeBladeOperState} $blade_dn, $result2->{cucsComputeBladeOperState}
) )
); );

View File

@ -56,13 +56,18 @@ sub check {
$self->{components}->{chassis}->{total}++; $self->{components}->{chassis}->{total}++;
$self->{output}->output_add(long_msg => sprintf("chassis '%s' state is '%s'.", $self->{output}->output_add(
$chassis_dn, $result->{cucsEquipmentChassisOperState}) long_msg => sprintf(
"chassis '%s' state is '%s'.",
$chassis_dn, $result->{cucsEquipmentChassisOperState}
)
); );
my $exit = $self->get_severity(section => 'chassis.operability', label => 'default.operability', value => $result->{cucsEquipmentChassisOperState}); my $exit = $self->get_severity(section => 'chassis.operability', label => 'default.operability', value => $result->{cucsEquipmentChassisOperState});
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("chassis '%s' state is '%s'", severity => $exit,
short_msg => sprintf(
"chassis '%s' state is '%s'",
$chassis_dn, $result->{cucsEquipmentChassisOperState} $chassis_dn, $result->{cucsEquipmentChassisOperState}
) )
); );

View File

@ -57,16 +57,22 @@ sub check {
next if ($self->absent_problem(section => 'cpu', instance => $cpu_dn)); next if ($self->absent_problem(section => 'cpu', instance => $cpu_dn));
next if ($self->check_filter(section => 'cpu', instance => $cpu_dn)); next if ($self->check_filter(section => 'cpu', instance => $cpu_dn));
$self->{output}->output_add(long_msg => sprintf("cpu '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"cpu '%s' state is '%s' [presence: %s].",
$cpu_dn, $result2->{cucsProcessorUnitOperState}, $cpu_dn, $result2->{cucsProcessorUnitOperState},
$result->{cucsProcessorUnitPresence}) $result->{cucsProcessorUnitPresence}
)
); );
my $exit = $self->get_severity(section => 'cpu.presence', label => 'default.presence', value => $result->{cucsProcessorUnitPresence}); my $exit = $self->get_severity(section => 'cpu.presence', label => 'default.presence', value => $result->{cucsProcessorUnitPresence});
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("cpu '%s' presence is: '%s'", severity => $exit,
$cpu_dn, $result->{cucsProcessorUnitPresence}) short_msg => sprintf(
"cpu '%s' presence is: '%s'",
$cpu_dn, $result->{cucsProcessorUnitPresence}
)
); );
next; next;
} }
@ -75,8 +81,10 @@ sub check {
$exit = $self->get_severity(section => 'cpu.operability', label => 'default.operability', value => $result2->{cucsProcessorUnitOperState}); $exit = $self->get_severity(section => 'cpu.operability', label => 'default.operability', value => $result2->{cucsProcessorUnitOperState});
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("cpu '%s' state is '%s'", severity => $exit,
short_msg => sprintf(
"cpu '%s' state is '%s'",
$cpu_dn, $result2->{cucsProcessorUnitOperState} $cpu_dn, $result2->{cucsProcessorUnitOperState}
) )
); );

View File

@ -57,16 +57,22 @@ sub check {
next if ($self->absent_problem(section => 'fan', instance => $fan_dn)); next if ($self->absent_problem(section => 'fan', instance => $fan_dn));
next if ($self->check_filter(section => 'fan', instance => $fan_dn)); next if ($self->check_filter(section => 'fan', instance => $fan_dn));
$self->{output}->output_add(long_msg => sprintf("fan '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"fan '%s' state is '%s' [presence: %s].",
$fan_dn, $result2->{cucsEquipmentFanOperState}, $fan_dn, $result2->{cucsEquipmentFanOperState},
$result->{cucsEquipmentFanPresence}) $result->{cucsEquipmentFanPresence}
)
); );
my $exit = $self->get_severity(section => 'fan.presence', label => 'default.presence', value => $result->{cucsEquipmentFanPresence}); my $exit = $self->get_severity(section => 'fan.presence', label => 'default.presence', value => $result->{cucsEquipmentFanPresence});
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("fan '%s' presence is: '%s'", severity => $exit,
$fan_dn, $result->{cucsEquipmentFanPresence}) short_msg => sprintf(
"fan '%s' presence is: '%s'",
$fan_dn, $result->{cucsEquipmentFanPresence}
)
); );
next; next;
} }
@ -75,8 +81,10 @@ sub check {
$exit = $self->get_severity(section => 'fan.operability', label => 'default.operability', value => $result2->{cucsEquipmentFanOperState}); $exit = $self->get_severity(section => 'fan.operability', label => 'default.operability', value => $result2->{cucsEquipmentFanOperState});
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("fan '%s' state is '%s'", severity => $exit,
short_msg => sprintf(
"fan '%s' state is '%s'",
$fan_dn, $result2->{cucsEquipmentFanOperState} $fan_dn, $result2->{cucsEquipmentFanOperState}
) )
); );

View File

@ -57,16 +57,22 @@ sub check {
next if ($self->absent_problem(section => 'fex', instance => $fex_dn)); next if ($self->absent_problem(section => 'fex', instance => $fex_dn));
next if ($self->check_filter(section => 'fex', instance => $fex_dn)); next if ($self->check_filter(section => 'fex', instance => $fex_dn));
$self->{output}->output_add(long_msg => sprintf("Fabric extender '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"Fabric extender '%s' state is '%s' [presence: %s].",
$fex_dn, $result2->{cucsEquipmentFexOperState}, $fex_dn, $result2->{cucsEquipmentFexOperState},
$result->{cucsEquipmentFexPresence}) $result->{cucsEquipmentFexPresence}
)
); );
my $exit = $self->get_severity(section => 'fex.presence', label => 'default.presence', value => $result->{cucsEquipmentFexPresence}); my $exit = $self->get_severity(section => 'fex.presence', label => 'default.presence', value => $result->{cucsEquipmentFexPresence});
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("Fabric extender '%s' presence is: '%s'", severity => $exit,
$fex_dn, $result->{cucsEquipmentFexPresence}) short_msg => sprintf(
"Fabric extender '%s' presence is: '%s'",
$fex_dn, $result->{cucsEquipmentFexPresence}
)
); );
next; next;
} }
@ -75,8 +81,10 @@ sub check {
$exit = $self->get_severity(section => 'fex.presence', label => 'default.operability', value => $result2->{cucsEquipmentFexOperState}); $exit = $self->get_severity(section => 'fex.presence', label => 'default.operability', value => $result2->{cucsEquipmentFexOperState});
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("Fabric extender '%s' state is '%s'.", severity => $exit,
short_msg => sprintf(
"Fabric extender '%s' state is '%s'.",
$fex_dn, $result2->{cucsEquipmentFexOperState} $fex_dn, $result2->{cucsEquipmentFexOperState}
) )
); );

View File

@ -58,16 +58,22 @@ sub check {
next if ($self->absent_problem(section => 'iocard', instance => $iocard_dn)); next if ($self->absent_problem(section => 'iocard', instance => $iocard_dn));
next if ($self->check_filter(section => 'iocard', instance => $iocard_dn)); next if ($self->check_filter(section => 'iocard', instance => $iocard_dn));
$self->{output}->output_add(long_msg => sprintf("IO cards '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"IO cards '%s' state is '%s' [presence: %s].",
$iocard_dn, $result2->{cucsEquipmentIOCardOperState}, $iocard_dn, $result2->{cucsEquipmentIOCardOperState},
$result->{cucsEquipmentIOCardPresence}) $result->{cucsEquipmentIOCardPresence}
)
); );
my $exit = $self->get_severity(section => 'iocard.presence', label => 'default.presence', value => $result->{cucsEquipmentIOCardPresence}); my $exit = $self->get_severity(section => 'iocard.presence', label => 'default.presence', value => $result->{cucsEquipmentIOCardPresence});
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("IO cards '%s' presence is: '%s'", severity => $exit,
$iocard_dn, $result->{cucsEquipmentIOCardPresence}) short_msg => sprintf(
"IO cards '%s' presence is: '%s'",
$iocard_dn, $result->{cucsEquipmentIOCardPresence}
)
); );
next; next;
} }
@ -76,8 +82,10 @@ sub check {
$exit = $self->get_severity(section => 'iocard.operability', label => 'default.operability', value => $result2->{cucsEquipmentIOCardOperState}); $exit = $self->get_severity(section => 'iocard.operability', label => 'default.operability', value => $result2->{cucsEquipmentIOCardOperState});
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("IO cards '%s' state is '%s'.", severity => $exit,
short_msg => sprintf(
"IO cards '%s' state is '%s'.",
$iocard_dn, $result2->{cucsEquipmentIOCardOperState} $iocard_dn, $result2->{cucsEquipmentIOCardOperState}
) )
); );

View File

@ -57,15 +57,20 @@ sub check {
next if ($self->absent_problem(section => 'localdisk', instance => $localdisk_dn)); next if ($self->absent_problem(section => 'localdisk', instance => $localdisk_dn));
next if ($self->check_filter(section => 'localdisk', instance => $localdisk_dn)); next if ($self->check_filter(section => 'localdisk', instance => $localdisk_dn));
$self->{output}->output_add(long_msg => sprintf("local disk '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"local disk '%s' state is '%s' [presence: %s].",
$localdisk_dn, $result2->{cucsStorageLocalDiskOperability}, $localdisk_dn, $result2->{cucsStorageLocalDiskOperability},
$result->{cucsStorageLocalDiskPresence}) $result->{cucsStorageLocalDiskPresence}
)
); );
my $exit = $self->get_severity(section => 'localdisk.presence', label => 'default.presence', value => $result->{cucsStorageLocalDiskPresence}); my $exit = $self->get_severity(section => 'localdisk.presence', label => 'default.presence', value => $result->{cucsStorageLocalDiskPresence});
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("local disk '%s' presence is: '%s'", severity => $exit,
short_msg => sprintf(
"local disk '%s' presence is: '%s'",
$localdisk_dn, $result->{cucsStorageLocalDiskPresence}) $localdisk_dn, $result->{cucsStorageLocalDiskPresence})
); );
next; next;
@ -75,8 +80,10 @@ sub check {
$exit = $self->get_severity(section => 'localdisk.operability', label => 'default.operability', value => $result2->{cucsStorageLocalDiskOperability}); $exit = $self->get_severity(section => 'localdisk.operability', label => 'default.operability', value => $result2->{cucsStorageLocalDiskOperability});
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("local disk '%s' state is '%s'", severity => $exit,
short_msg => sprintf(
"local disk '%s' state is '%s'",
$localdisk_dn, $result2->{cucsStorageLocalDiskOperability} $localdisk_dn, $result2->{cucsStorageLocalDiskOperability}
) )
); );

View File

@ -58,16 +58,22 @@ sub check {
next if ($self->absent_problem(section => 'memory', instance => $memory_dn)); next if ($self->absent_problem(section => 'memory', instance => $memory_dn));
next if ($self->check_filter(section => 'memory', instance => $memory_dn)); next if ($self->check_filter(section => 'memory', instance => $memory_dn));
$self->{output}->output_add(long_msg => sprintf("memory '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"memory '%s' state is '%s' [presence: %s].",
$memory_dn, $result2->{cucsMemoryUnitOperState}, $memory_dn, $result2->{cucsMemoryUnitOperState},
$result->{cucsMemoryUnitPresence}) $result->{cucsMemoryUnitPresence}
)
); );
my $exit = $self->get_severity(section => 'memory.presence', label => 'default.presence', value => $result->{cucsMemoryUnitPresence}); my $exit = $self->get_severity(section => 'memory.presence', label => 'default.presence', value => $result->{cucsMemoryUnitPresence});
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("memory '%s' presence is: '%s'", severity => $exit,
$memory_dn, $result->{cucsMemoryUnitPresence}) short_msg => sprintf(
"memory '%s' presence is: '%s'",
$memory_dn, $result->{cucsMemoryUnitPresence}
)
); );
next; next;
} }
@ -76,8 +82,10 @@ sub check {
$exit = $self->get_severity(section => 'memory.operability', label => 'default.operability', value => $result2->{cucsMemoryUnitOperState}); $exit = $self->get_severity(section => 'memory.operability', label => 'default.operability', value => $result2->{cucsMemoryUnitOperState});
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("memory '%s' state is '%s'", severity => $exit,
short_msg => sprintf(
"memory '%s' state is '%s'",
$memory_dn, $result2->{cucsMemoryUnitOperState} $memory_dn, $result2->{cucsMemoryUnitOperState}
) )
); );

View File

@ -58,16 +58,22 @@ sub check {
next if ($self->absent_problem(section => 'psu', instance => $psu_dn)); next if ($self->absent_problem(section => 'psu', instance => $psu_dn));
next if ($self->check_filter(section => 'psu', instance => $psu_dn)); next if ($self->check_filter(section => 'psu', instance => $psu_dn));
$self->{output}->output_add(long_msg => sprintf("power supply '%s' state is '%s' [presence: %s].", $self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' state is '%s' [presence: %s].",
$psu_dn, $result2->{cucsEquipmentPsuOperState}, $psu_dn, $result2->{cucsEquipmentPsuOperState},
$result->{cucsEquipmentPsuPresence}) $result->{cucsEquipmentPsuPresence}
)
); );
my $exit = $self->get_severity(section => 'psu.presence', label => 'default.presence', value => $result->{cucsEquipmentPsuPresence}); my $exit = $self->get_severity(section => 'psu.presence', label => 'default.presence', value => $result->{cucsEquipmentPsuPresence});
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("power supply '%s' presence is: '%s'", severity => $exit,
$psu_dn, $result->{cucsEquipmentPsuPresence}) short_msg => sprintf(
"power supply '%s' presence is: '%s'",
$psu_dn, $result->{cucsEquipmentPsuPresence}
)
); );
next; next;
} }
@ -76,8 +82,10 @@ sub check {
$exit = $self->get_severity(section => 'psu.operability', label => 'default.operability', value => $result2->{cucsEquipmentPsuOperState}); $exit = $self->get_severity(section => 'psu.operability', label => 'default.operability', value => $result2->{cucsEquipmentPsuOperState});
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("power supply '%s' state is '%s'.", severity => $exit,
short_msg => sprintf(
"power supply '%s' state is '%s'.",
$psu_dn, $result2->{cucsEquipmentPsuOperState} $psu_dn, $result2->{cucsEquipmentPsuOperState}
) )
); );

View File

@ -51,8 +51,7 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{
}); });
return $self; return $self;
@ -97,4 +96,3 @@ Example: --threshold-overload='fan.operability,OK,poweredOff|removed'
=back =back
=cut =cut