enhance indent

This commit is contained in:
garnier-quentin 2019-10-04 09:35:30 +02:00
parent a246cf2664
commit afa004da2e
15 changed files with 170 additions and 136 deletions

View File

@ -80,11 +80,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{instanceState} ne %{instanceWantedState} or %{instanceState} ne %{instanceStateLast}' },
});
$options{options}->add_options(arguments => {
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{instanceState} ne %{instanceWantedState} or %{instanceState} ne %{instanceStateLast}' },
});
return $self;
}
@ -110,8 +109,11 @@ sub manage_selection {
my ($self, %options) = @_;
$self->{vrrp} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_vrrpInstanceEntry, end => $mapping->{vrrpInstancePrimaryInterface}->{oid},
nothing_quit => 1);
my $snmp_result = $options{snmp}->get_table(
oid => $oid_vrrpInstanceEntry,
end => $mapping->{vrrpInstancePrimaryInterface}->{oid},
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{vrrpInstanceState}->{oid}\.(.*)$/);

View File

@ -31,7 +31,7 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'vrrp-status' => 'apps::keepalived::snmp::mode::vrrpstatus',
'vrrp-status' => 'apps::keepalived::snmp::mode::vrrpstatus',
);
return $self;

View File

@ -122,7 +122,7 @@ sub set_counters {
sub prefix_global_output {
my ($self, %options) = @_;
return "Scenario ";
return 'Scenario ';
}
sub prefix_step_output {
@ -137,24 +137,24 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"sahi-hostname:s" => { name => 'sahi_hostname' },
"sahi-port:s" => { name => 'sahi_port', default => 9999 },
"sahi-proto:s" => { name => 'sahi_proto', default => 'http' },
"sahi-http-timeout:s" => { name => 'sahi_http_timeout', default => 5 },
"sahi-endpoint:s" => { name => 'sahi_endpoint', default => '/_s_/dyn/' },
"sahi-suite:s" => { name => 'sahi_suite' },
"sahi-threads:s" => { name => 'sahi_threads', default => 1 },
"sahi-startwith:s" => { name => 'sahi_startwith', default => 'BROWSER' },
"sahi-browsertype:s" => { name => 'sahi_browsertype', default => 'chrome' },
"sahi-baseurl:s" => { name => 'sahi_baseurl' },
"timeout:s" => { name => 'timeout' },
"retries-scenario-status:s" => { name => 'retries_scenario_status' },
"interval-scenario-status:s" => { name => 'interval_scenario_status', default => 10 },
"unknown-run-status:s" => { name => 'unknown_run_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
"warning-run-status:s" => { name => 'warning_run_status' },
"critical-run-status:s" => { name => 'critical_run_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} ne "SUCCESS"' },
'sahi-hostname:s' => { name => 'sahi_hostname' },
'sahi-port:s' => { name => 'sahi_port', default => 9999 },
'sahi-proto:s' => { name => 'sahi_proto', default => 'http' },
'sahi-http-timeout:s' => { name => 'sahi_http_timeout', default => 5 },
'sahi-endpoint:s' => { name => 'sahi_endpoint', default => '/_s_/dyn/' },
'sahi-suite:s' => { name => 'sahi_suite' },
'sahi-threads:s' => { name => 'sahi_threads', default => 1 },
'sahi-startwith:s' => { name => 'sahi_startwith', default => 'BROWSER' },
'sahi-browsertype:s' => { name => 'sahi_browsertype', default => 'chrome' },
'sahi-baseurl:s' => { name => 'sahi_baseurl' },
'timeout:s' => { name => 'timeout' },
'retries-scenario-status:s' => { name => 'retries_scenario_status' },
'interval-scenario-status:s' => { name => 'interval_scenario_status', default => 10 },
'unknown-run-status:s' => { name => 'unknown_run_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
'warning-run-status:s' => { name => 'warning_run_status' },
'critical-run-status:s' => { name => 'critical_run_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "SUCCESS"' },
});
$self->{http} = centreon::plugins::http->new(%options);
@ -179,7 +179,7 @@ sub handle_ALRM {
my $self = shift;
$self->killed_scenario();
$self->{output}->add_option_msg(short_msg => "Cannot finished scenario execution (timeout received)");
$self->{output}->add_option_msg(short_msg => 'Cannot finished scenario execution (timeout received)');
$self->{output}->option_exit();
}
@ -190,7 +190,7 @@ sub check_options {
foreach my $option (('sahi_hostname', 'sahi_suite', 'sahi_startwith', 'sahi_browsertype')) {
(my $label = $option) =~ s/_/-/g;
if (!defined($self->{option_results}->{$option}) || $self->{option_results}->{$option} eq '') {
$self->{output}->add_option_msg(short_msg => "Please set " . $label . " option");
$self->{output}->add_option_msg(short_msg => 'Please set ' . $label . ' option');
$self->{output}->option_exit();
}
}
@ -232,7 +232,7 @@ sub generate_user_defined_id {
my ($self, %options) = @_;
my ($seconds, $microseconds) = Time::HiRes::gettimeofday();
my $user_defined_id = strftime("%d%B%Y__%H_%M_%S_", localtime($seconds));
my $user_defined_id = strftime('%d%B%Y__%H_%M_%S_', localtime($seconds));
$user_defined_id .= $microseconds;
return $user_defined_id;
@ -301,7 +301,7 @@ sub run_scenario {
);
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => "run scenario issue:" . $content);
$self->{output}->add_option_msg(short_msg => 'run scenario issue:' . $content);
$self->{output}->option_exit();
}
@ -325,7 +325,7 @@ sub check_scenario_status {
);
if ($self->{http}->get_code() != 200) {
if ($retries == $self->{option_results}->{retries_scenario_status}) {
$self->{output}->add_option_msg(short_msg => "check scenario status issue:" . $content);
$self->{output}->add_option_msg(short_msg => 'check scenario status issue:' . $content);
$self->{output}->option_exit();
}
$retries++;
@ -362,13 +362,13 @@ sub get_suite_report {
);
if ($self->{http}->get_code() != 200) {
$self->cleanup_option_exit(short_msg => "get suite report issue:" . $content);
$self->cleanup_option_exit(short_msg => 'get suite report issue:' . $content);
}
my $response = $self->decode_xml_response(response => $content, ForceArray => ['summary']);
if (!defined($response->{suite}->{scriptSummaries}->{summary})) {
$self->{output}->output_add(long_msg => $response, debug => 1);
$self->cleanup_option_exit(short_msg => "get suite report issue: unknown response format");
$self->cleanup_option_exit(short_msg => 'get suite report issue: unknown response format');
}
# in milliseconds
@ -396,13 +396,13 @@ sub get_script_report {
);
if ($self->{http}->get_code() != 200) {
$self->cleanup_option_exit(short_msg => "get suite report issue:" . $content);
$self->cleanup_option_exit(short_msg => 'get suite report issue:' . $content);
}
my $response = $self->decode_xml_response(response => $content, ForceArray => ['step']);
if (!defined($response->{steps}->{step})) {
$self->{output}->output_add(long_msg => $response, debug => 1);
$self->cleanup_option_exit(short_msg => "get script report issue: unknown response format");
$self->cleanup_option_exit(short_msg => 'get script report issue: unknown response format');
}
$self->{steps} = {};

View File

@ -101,12 +101,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
"warning-ap-status:s" => { name => 'warning_ap_status', default => '' },
"critical-ap-status:s" => { name => 'critical_ap_status', default => '%{state} eq "disconnected"' },
});
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'warning-ap-status:s' => { name => 'warning_ap_status', default => '' },
'critical-ap-status:s' => { name => 'critical_ap_status', default => '%{state} eq "disconnected"' },
});
return $self;
}
@ -138,11 +138,15 @@ sub manage_selection {
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $mapping->{coDevDisState}->{oid} },
{ oid => $mapping->{coDevDisSystemName}->{oid} },
{ oid => $mapping2->{coDevWirCliStaMACAddress}->{oid} },
], nothing_quit => 1, return_type => 1);
],
nothing_quit => 1,
return_type => 1
);
$self->{ap} = {};
$self->{global} = { total_ap => 0, total_users => 0 };

View File

@ -83,10 +83,9 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -97,8 +96,13 @@ sub manage_selection {
my $oid_coUsInfoCpuUse5Sec = '.1.3.6.1.4.1.8744.5.21.1.1.6.0';
my $oid_coUsInfoCpuUse10Sec = '.1.3.6.1.4.1.8744.5.21.1.1.7.0';
my $oid_coUsInfoCpuUse20Sec = '.1.3.6.1.4.1.8744.5.21.1.1.8.0';
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_coUsInfoCpuUseNow,
$oid_coUsInfoCpuUse5Sec, $oid_coUsInfoCpuUse10Sec, $oid_coUsInfoCpuUse20Sec], nothing_quit => 1);
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_coUsInfoCpuUseNow, $oid_coUsInfoCpuUse5Sec,
$oid_coUsInfoCpuUse10Sec, $oid_coUsInfoCpuUse20Sec
],
nothing_quit => 1
);
$self->{global} = {
usage_now => $snmp_result->{$oid_coUsInfoCpuUseNow},

View File

@ -71,9 +71,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -84,8 +83,13 @@ sub manage_selection {
my $oid_coUsInfoLoadAverage1Min = '.1.3.6.1.4.1.8744.5.21.1.1.5.0';
my $oid_coUsInfoLoadAverage5Min = '.1.3.6.1.4.1.8744.5.21.1.1.6.0';
my $oid_coUsInfoLoadAverage15Min = '.1.3.6.1.4.1.8744.5.21.1.1.7.0';
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_coUsInfoLoadAverage1Min,
$oid_coUsInfoLoadAverage5Min, $oid_coUsInfoLoadAverage15Min], nothing_quit => 1);
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_coUsInfoLoadAverage1Min,
$oid_coUsInfoLoadAverage5Min, $oid_coUsInfoLoadAverage15Min
],
nothing_quit => 1
);
$self->{global} = {
load1 => $snmp_result->{$oid_coUsInfoLoadAverage1Min},

View File

@ -30,11 +30,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
$options{options}->add_options(arguments => {
'warning:s' => { name => 'warning' },
'critical:s' => { name => 'critical' },
});
return $self;
}
@ -44,12 +43,12 @@ sub check_options {
$self->SUPER::init(%options);
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();
$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} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
@ -62,10 +61,13 @@ sub run {
my $oid_coUsInfoRamBuffer = '.1.3.6.1.4.1.8744.5.21.1.1.11.0';
my $oid_coUsInfoRamCached = '.1.3.6.1.4.1.8744.5.21.1.1.12.0';
my $result = $self->{snmp}->get_leef(oids => [
$oid_coUsInfoRamTotal, $oid_coUsInfoRamFree,
$oid_coUsInfoRamBuffer, $oid_coUsInfoRamCached
], nothing_quit => 1);
my $result = $self->{snmp}->get_leef(
oids => [
$oid_coUsInfoRamTotal, $oid_coUsInfoRamFree,
$oid_coUsInfoRamBuffer, $oid_coUsInfoRamCached
],
nothing_quit => 1
);
my $cached_used = $result->{$oid_coUsInfoRamCached};
my $buffer_used = $result->{$oid_coUsInfoRamBuffer};
@ -82,25 +84,35 @@ sub run {
my ($buffer_value, $buffer_unit) = $self->{perfdata}->change_bytes(value => $buffer_used);
my ($cached_value, $cached_unit) = $self->{perfdata}->change_bytes(value => $cached_used);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Ram Total: %s, Used (-buffers/cache): %s (%.2f%%), Buffer: %s, Cached: %s",
$total_value . " " . $total_unit,
$nobuf_value . " " . $nobuf_unit, $prct_used,
$buffer_value . " " . $buffer_unit,
$cached_value . " " . $cached_unit));
$self->{output}->perfdata_add(label => "cached", unit => 'B',
value => $cached_used,
min => 0);
$self->{output}->perfdata_add(label => "buffer", unit => 'B',
value => $buffer_used,
min => 0);
$self->{output}->perfdata_add(label => "used", unit => 'B',
value => $nobuf_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
min => 0, max => $total_size);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Ram Total: %s, Used (-buffers/cache): %s (%.2f%%), Buffer: %s, Cached: %s",
$total_value . " " . $total_unit,
$nobuf_value . " " . $nobuf_unit, $prct_used,
$buffer_value . " " . $buffer_unit,
$cached_value . " " . $cached_unit
)
);
$self->{output}->perfdata_add(
label => "cached", unit => 'B',
value => $cached_used,
min => 0
);
$self->{output}->perfdata_add(
label => "buffer", unit => 'B',
value => $buffer_used,
min => 0
);
$self->{output}->perfdata_add(
label => "used", unit => 'B',
value => $nobuf_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
min => 0, max => $total_size
);
$self->{output}->display();
$self->{output}->exit();
}

View File

@ -59,10 +59,9 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -71,9 +70,12 @@ sub manage_selection {
my $oid_coUsInfoStorageUsePermanent = '.1.3.6.1.4.1.8744.5.21.1.1.13.0';
my $oid_coUsInfoStorageUseTemporary = '.1.3.6.1.4.1.8744.5.21.1.1.14.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_coUsInfoStorageUsePermanent, $oid_coUsInfoStorageUseTemporary,
], nothing_quit => 1);
],
nothing_quit => 1
);
$self->{storage} = {
perm_used => $snmp_result->{$oid_coUsInfoStorageUsePermanent},

View File

@ -31,14 +31,14 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'ap-usage' => 'network::colubris::snmp::mode::apusage',
'cpu' => 'network::colubris::snmp::mode::cpu',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'load' => 'network::colubris::snmp::mode::load',
'memory' => 'network::colubris::snmp::mode::memory',
'storage' => 'network::colubris::snmp::mode::storage',
);
'ap-usage' => 'network::colubris::snmp::mode::apusage',
'cpu' => 'network::colubris::snmp::mode::cpu',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'load' => 'network::colubris::snmp::mode::load',
'memory' => 'network::colubris::snmp::mode::memory',
'storage' => 'network::colubris::snmp::mode::storage',
);
return $self;
}

View File

@ -50,10 +50,9 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -61,9 +60,12 @@ sub manage_selection {
my ($self, %options) = @_;
my $oid_ibSystemMonitorCpuUsage = '.1.3.6.1.4.1.7779.3.1.1.2.1.8.1.1.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_ibSystemMonitorCpuUsage
], nothing_quit => 1);
],
nothing_quit => 1
);
$self->{global} = { cpu => $snmp_result->{$oid_ibSystemMonitorCpuUsage} };
}

View File

@ -78,11 +78,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
});
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
});
return $self;
}
@ -121,10 +120,13 @@ my $oid_ibDHCPSubnetEntry = '.1.3.6.1.4.1.7779.3.1.1.4.1.1.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_ibDHCPStatistics },
{ oid => $oid_ibDHCPSubnetEntry },
], nothing_quit => 1);
],
nothing_quit => 1
);
$self->{dhcp} = {};
foreach my $oid (keys %{$snmp_result->{$oid_ibDHCPSubnetEntry}}) {

View File

@ -100,10 +100,9 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
});
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
});
return $self;
}
@ -138,10 +137,13 @@ sub manage_selection {
}
$self->{dns} = {};
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_ibZoneStatisticsEntry },
{ oid => $oid_ibDnsModule, start => $mapping2->{ibDnsHitRatio}->{oid} },
], nothing_quit => 1);
],
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result->{$oid_ibZoneStatisticsEntry}}) {
next if ($oid !~ /^$mapping->{ibBindZoneName}->{oid}\.(.*)$/);

View File

@ -59,9 +59,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -71,9 +70,12 @@ sub manage_selection {
my $oid_ibSystemMonitorMemUsage = '.1.3.6.1.4.1.7779.3.1.1.2.1.8.2.1.0';
my $oid_ibSystemMonitorSwapUsage = '.1.3.6.1.4.1.7779.3.1.1.2.1.8.3.1.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_ibSystemMonitorMemUsage, $oid_ibSystemMonitorSwapUsage,
], nothing_quit => 1);
],
nothing_quit => 1
);
$self->{memory} = {
ram_used => $snmp_result->{$oid_ibSystemMonitorMemUsage},

View File

@ -51,9 +51,7 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {});
return $self;
}

View File

@ -31,14 +31,14 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::infoblox::snmp::mode::cpu',
'dhcp-usage' => 'network::infoblox::snmp::mode::dhcpusage',
'dns-usage' => 'network::infoblox::snmp::mode::dnsusage',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::infoblox::snmp::mode::memory',
'services' => 'network::infoblox::snmp::mode::services',
);
'cpu' => 'network::infoblox::snmp::mode::cpu',
'dhcp-usage' => 'network::infoblox::snmp::mode::dhcpusage',
'dns-usage' => 'network::infoblox::snmp::mode::dnsusage',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::infoblox::snmp::mode::memory',
'services' => 'network::infoblox::snmp::mode::services',
);
return $self;
}