enhance indentation

This commit is contained in:
garnier-quentin 2019-11-28 14:45:06 +01:00
parent c7aeae5941
commit 41ea3fee92
4 changed files with 60 additions and 47 deletions

View File

@ -30,10 +30,9 @@ 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;

View File

@ -30,10 +30,9 @@ 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;
@ -72,17 +71,23 @@ sub run {
my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used);
my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_value . " " . $total_unit,
$used_value . " " . $used_unit, $result->{$oid_resMemUsage},
$free_value . " " . $free_unit, (100 - $result->{$oid_resMemUsage})));
$free_value . " " . $free_unit, (100 - $result->{$oid_resMemUsage})
)
);
$self->{output}->perfdata_add(label => "used", unit => 'B',
$self->{output}->perfdata_add(
label => "used", unit => 'B',
value => int($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);
min => 0, max => $total_size
);
$self->{output}->display();
$self->{output}->exit();

View File

@ -122,9 +122,9 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
'filter-name:s' => { name => 'filter_name' },
'units:s' => { name => 'units', default => '%' },
'free' => { name => 'free' },
});
return $self;
@ -141,9 +141,10 @@ sub manage_selection {
my ($self, %options) = @_;
$self->{storage} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_nsSysHealthDiskEntry,
nothing_quit => 1);
my $snmp_result = $options{snmp}->get_table(
oid => $oid_nsSysHealthDiskEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{sysHealthDiskName}->{oid}\.(.*)$/);

View File

@ -156,9 +156,9 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' },
"filter-type:s" => { name => 'filter_type' },
"threshold-overload:s@" => { name => 'threshold_overload' },
'filter-name:s' => { name => 'filter_name' },
'filter-type:s' => { name => 'filter_type' },
'threshold-overload:s@' => { name => 'threshold_overload' },
});
return $self;
@ -222,11 +222,16 @@ my $mapping2 = {
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 => $mapping->{vsvrFullName}->{oid} },
{ oid => $mapping->{vsvrState}->{oid} },
{ oid => $mapping->{vsvrEntityType}->{oid} },
], return_type => 1, nothing_quit => 1);
],
return_type => 1,
nothing_quit => 1
);
$self->{vservers} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{vsvrFullName}->{oid}\.(.*)$/);
@ -247,12 +252,20 @@ sub manage_selection {
$self->{vservers}->{$instance} = { display => $result->{vsvrFullName}, state => $result->{vsvrState} };
}
$options{snmp}->load(oids => [$mapping2->{vsvrTotalRequestBytesLow}->{oid}, $mapping2->{vsvrTotalRequestBytesHigh}->{oid},
if (scalar(keys %{$self->{vservers}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No virtual server found.");
$self->{output}->option_exit();
}
$options{snmp}->load(
oids => [
$mapping2->{vsvrTotalRequestBytesLow}->{oid}, $mapping2->{vsvrTotalRequestBytesHigh}->{oid},
$mapping2->{vsvrTotalResponseBytesLow}->{oid}, $mapping2->{vsvrTotalResponseBytesHigh}->{oid},
$mapping2->{vsvrTotalRequestBytes}->{oid}, $mapping2->{vsvrTotalResponseBytes}->{oid},
$mapping2->{vsvrTotalClients}->{oid}, $mapping2->{vsvrHealth}->{oid}, $mapping2->{vsvrTotalServers}->{oid}
],
instances => [keys %{$self->{vservers}}], instance_regexp => '^(.*)$');
instances => [keys %{$self->{vservers}}], instance_regexp => '^(.*)$'
);
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
foreach (keys %{$self->{vservers}}) {
@ -267,11 +280,6 @@ sub manage_selection {
$self->{vservers}->{$_}->{servers} = $result->{vsvrTotalServers};
}
if (scalar(keys %{$self->{vservers}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No virtual server found.");
$self->{output}->option_exit();
}
$self->{cache_name} = "citrix_netscaler_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(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')) . '_' .