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

@ -35,7 +35,7 @@ sub new {
'discovery' => 'apps::automation::ansible::tower::mode::discovery',
'inventory-statistics' => 'apps::automation::ansible::tower::mode::inventorystatistics',
);
$self->{custom_modes}{towercli} = 'apps::automation::ansible::tower::custom::towercli';
return $self;
}

View File

@ -49,13 +49,13 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-severity:s@" => { name => 'filter_severity', },
"filter-message:s" => { name => 'filter_message' },
"retention:s" => { name => 'retention' },
"memory" => { name => 'memory' },
});
$options{options}->add_options(arguments => {
'filter-severity:s@' => { name => 'filter_severity', },
'filter-message:s' => { name => 'filter_message' },
'retention:s' => { name => 'retention' },
'memory' => { name => 'memory' },
});
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{severities} = {};
return $self;
@ -214,4 +214,4 @@ Event older (current time - retention time) is not checked (in seconds).
=back
=cut

View File

@ -57,17 +57,23 @@ sub check {
next if ($self->absent_problem(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].",
$blade_dn, $result2->{cucsComputeBladeOperState},
$result->{cucsComputeBladePresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"blade '%s' state is '%s' [presence: %s].",
$blade_dn, $result2->{cucsComputeBladeOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("blade '%s' presence is: '%s'",
$blade_dn, $result->{cucsComputeBladePresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"blade '%s' presence is: '%s'",
$blade_dn, $result->{cucsComputeBladePresence}
)
);
next;
}
@ -75,11 +81,13 @@ sub check {
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("blade '%s' state is '%s'",
$blade_dn, $result2->{cucsComputeBladeOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"blade '%s' state is '%s'",
$blade_dn, $result2->{cucsComputeBladeOperState}
)
);
}
}
}

View File

@ -56,16 +56,21 @@ sub check {
$self->{components}->{chassis}->{total}++;
$self->{output}->output_add(long_msg => sprintf("chassis '%s' state is '%s'.",
$chassis_dn, $result->{cucsEquipmentChassisOperState})
);
$self->{output}->output_add(
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});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("chassis '%s' state is '%s'",
$chassis_dn, $result->{cucsEquipmentChassisOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"chassis '%s' state is '%s'",
$chassis_dn, $result->{cucsEquipmentChassisOperState}
)
);
}
}
}

View File

@ -57,31 +57,39 @@ sub check {
next if ($self->absent_problem(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].",
$cpu_dn, $result2->{cucsProcessorUnitOperState},
$result->{cucsProcessorUnitPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"cpu '%s' state is '%s' [presence: %s].",
$cpu_dn, $result2->{cucsProcessorUnitOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("cpu '%s' presence is: '%s'",
$cpu_dn, $result->{cucsProcessorUnitPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"cpu '%s' presence is: '%s'",
$cpu_dn, $result->{cucsProcessorUnitPresence}
)
);
next;
}
$self->{components}->{cpu}->{total}++;
$exit = $self->get_severity(section => 'cpu.operability', label => 'default.operability', value => $result2->{cucsProcessorUnitOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("cpu '%s' state is '%s'",
$cpu_dn, $result2->{cucsProcessorUnitOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"cpu '%s' state is '%s'",
$cpu_dn, $result2->{cucsProcessorUnitOperState}
)
);
}
}
}
1;
1;

View File

@ -57,17 +57,23 @@ sub check {
next if ($self->absent_problem(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].",
$fan_dn, $result2->{cucsEquipmentFanOperState},
$result->{cucsEquipmentFanPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' state is '%s' [presence: %s].",
$fan_dn, $result2->{cucsEquipmentFanOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' presence is: '%s'",
$fan_dn, $result->{cucsEquipmentFanPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"fan '%s' presence is: '%s'",
$fan_dn, $result->{cucsEquipmentFanPresence}
)
);
next;
}
@ -75,13 +81,15 @@ sub check {
$exit = $self->get_severity(section => 'fan.operability', label => 'default.operability', value => $result2->{cucsEquipmentFanOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' state is '%s'",
$fan_dn, $result2->{cucsEquipmentFanOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"fan '%s' state is '%s'",
$fan_dn, $result2->{cucsEquipmentFanOperState}
)
);
}
}
}
1;
1;

View File

@ -57,29 +57,37 @@ sub check {
next if ($self->absent_problem(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].",
$fex_dn, $result2->{cucsEquipmentFexOperState},
$result->{cucsEquipmentFexPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"Fabric extender '%s' state is '%s' [presence: %s].",
$fex_dn, $result2->{cucsEquipmentFexOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fabric extender '%s' presence is: '%s'",
$fex_dn, $result->{cucsEquipmentFexPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Fabric extender '%s' presence is: '%s'",
$fex_dn, $result->{cucsEquipmentFexPresence}
)
);
next;
}
$self->{components}->{fex}->{total}++;
$exit = $self->get_severity(section => 'fex.presence', label => 'default.operability', value => $result2->{cucsEquipmentFexOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fabric extender '%s' state is '%s'.",
$fex_dn, $result2->{cucsEquipmentFexOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Fabric extender '%s' state is '%s'.",
$fex_dn, $result2->{cucsEquipmentFexOperState}
)
);
}
}
}

View File

@ -58,29 +58,37 @@ sub check {
next if ($self->absent_problem(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].",
$iocard_dn, $result2->{cucsEquipmentIOCardOperState},
$result->{cucsEquipmentIOCardPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"IO cards '%s' state is '%s' [presence: %s].",
$iocard_dn, $result2->{cucsEquipmentIOCardOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("IO cards '%s' presence is: '%s'",
$iocard_dn, $result->{cucsEquipmentIOCardPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"IO cards '%s' presence is: '%s'",
$iocard_dn, $result->{cucsEquipmentIOCardPresence}
)
);
next;
}
$self->{components}->{iocard}->{total}++;
$exit = $self->get_severity(section => 'iocard.operability', label => 'default.operability', value => $result2->{cucsEquipmentIOCardOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("IO cards '%s' state is '%s'.",
$iocard_dn, $result2->{cucsEquipmentIOCardOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"IO cards '%s' state is '%s'.",
$iocard_dn, $result2->{cucsEquipmentIOCardOperState}
)
);
}
}
}

View File

@ -35,7 +35,7 @@ my $oid_cucsStorageLocalDiskDn = '.1.3.6.1.4.1.9.9.719.1.45.4.1.2';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} },
{ oid => $mapping2->{cucsStorageLocalDiskOperability}->{oid} }, { oid => $oid_cucsStorageLocalDiskDn };
}
@ -53,35 +53,42 @@ sub check {
my $localdisk_dn = $self->{results}->{$oid_cucsStorageLocalDiskDn}->{$oid};
my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsStorageLocalDiskPresence}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsStorageLocalDiskOperability}->{oid}}, instance => $instance);
next if ($self->absent_problem(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].",
$localdisk_dn, $result2->{cucsStorageLocalDiskOperability},
$result->{cucsStorageLocalDiskPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"local disk '%s' state is '%s' [presence: %s].",
$localdisk_dn, $result2->{cucsStorageLocalDiskOperability},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("local disk '%s' presence is: '%s'",
$localdisk_dn, $result->{cucsStorageLocalDiskPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"local disk '%s' presence is: '%s'",
$localdisk_dn, $result->{cucsStorageLocalDiskPresence})
);
next;
}
$self->{components}->{localdisk}->{total}++;
$exit = $self->get_severity(section => 'localdisk.operability', label => 'default.operability', value => $result2->{cucsStorageLocalDiskOperability});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("local disk '%s' state is '%s'",
$localdisk_dn, $result2->{cucsStorageLocalDiskOperability}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"local disk '%s' state is '%s'",
$localdisk_dn, $result2->{cucsStorageLocalDiskOperability}
)
);
}
}
}
1;
1;

View File

@ -58,17 +58,23 @@ sub check {
next if ($self->absent_problem(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].",
$memory_dn, $result2->{cucsMemoryUnitOperState},
$result->{cucsMemoryUnitPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"memory '%s' state is '%s' [presence: %s].",
$memory_dn, $result2->{cucsMemoryUnitOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("memory '%s' presence is: '%s'",
$memory_dn, $result->{cucsMemoryUnitPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"memory '%s' presence is: '%s'",
$memory_dn, $result->{cucsMemoryUnitPresence}
)
);
next;
}
@ -76,13 +82,15 @@ sub check {
$exit = $self->get_severity(section => 'memory.operability', label => 'default.operability', value => $result2->{cucsMemoryUnitOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("memory '%s' state is '%s'",
$memory_dn, $result2->{cucsMemoryUnitOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"memory '%s' state is '%s'",
$memory_dn, $result2->{cucsMemoryUnitOperState}
)
);
}
}
}
1;
1;

View File

@ -58,29 +58,37 @@ sub check {
next if ($self->absent_problem(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].",
$psu_dn, $result2->{cucsEquipmentPsuOperState},
$result->{cucsEquipmentPsuPresence})
);
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' state is '%s' [presence: %s].",
$psu_dn, $result2->{cucsEquipmentPsuOperState},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("power supply '%s' presence is: '%s'",
$psu_dn, $result->{cucsEquipmentPsuPresence})
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"power supply '%s' presence is: '%s'",
$psu_dn, $result->{cucsEquipmentPsuPresence}
)
);
next;
}
$self->{components}->{psu}->{total}++;
$exit = $self->get_severity(section => 'psu.operability', label => 'default.operability', value => $result2->{cucsEquipmentPsuOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("power supply '%s' state is '%s'.",
$psu_dn, $result2->{cucsEquipmentPsuOperState}
)
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"power supply '%s' state is '%s'.",
$psu_dn, $result2->{cucsEquipmentPsuOperState}
)
);
}
}
}

View File

@ -28,20 +28,20 @@ use hardware::server::cisco::ucs::mode::components::resources qw($thresholds);
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|chassis|iocard|blade|fex|cpu|memory|localdisk)\.(presence|operability|overall_status)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = $thresholds;
$self->{components_path} = 'hardware::server::cisco::ucs::mode::components';
$self->{components_module} = ['fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
@ -50,10 +50,9 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -97,4 +96,3 @@ Example: --threshold-overload='fan.operability,OK,poweredOff|removed'
=back
=cut