enhance indentation
This commit is contained in:
parent
c7aeae5941
commit
41ea3fee92
|
@ -30,11 +30,10 @@ 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 => {
|
||||||
{
|
'warning:s' => { name => 'warning' },
|
||||||
"warning:s" => { name => 'warning' },
|
'critical:s' => { name => 'critical' },
|
||||||
"critical:s" => { name => 'critical' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,10 @@ 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 => {
|
||||||
{
|
'warning:s' => { name => 'warning' },
|
||||||
"warning:s" => { name => 'warning' },
|
'critical:s' => { name => 'critical' },
|
||||||
"critical:s" => { name => 'critical' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -72,17 +71,23 @@ sub run {
|
||||||
my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used);
|
my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used);
|
||||||
my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free);
|
my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free);
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
severity => $exit,
|
||||||
$total_value . " " . $total_unit,
|
short_msg => sprintf(
|
||||||
$used_value . " " . $used_unit, $result->{$oid_resMemUsage},
|
"Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||||
$free_value . " " . $free_unit, (100 - $result->{$oid_resMemUsage})));
|
$total_value . " " . $total_unit,
|
||||||
|
$used_value . " " . $used_unit, $result->{$oid_resMemUsage},
|
||||||
|
$free_value . " " . $free_unit, (100 - $result->{$oid_resMemUsage})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => "used", unit => 'B',
|
$self->{output}->perfdata_add(
|
||||||
value => int($used),
|
label => "used", unit => 'B',
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
|
value => int($used),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
|
||||||
min => 0, max => $total_size);
|
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}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
|
|
|
@ -122,9 +122,9 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
"units:s" => { name => 'units', default => '%' },
|
'units:s' => { name => 'units', default => '%' },
|
||||||
"free" => { name => 'free' },
|
'free' => { name => 'free' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -141,9 +141,10 @@ sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{storage} = {};
|
$self->{storage} = {};
|
||||||
my $snmp_result = $options{snmp}->get_table(oid => $oid_nsSysHealthDiskEntry,
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
nothing_quit => 1);
|
oid => $oid_nsSysHealthDiskEntry,
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
next if ($oid !~ /^$mapping->{sysHealthDiskName}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{sysHealthDiskName}->{oid}\.(.*)$/);
|
||||||
|
|
|
@ -156,9 +156,9 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
"filter-type:s" => { name => 'filter_type' },
|
'filter-type:s' => { name => 'filter_type' },
|
||||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
'threshold-overload:s@' => { name => 'threshold_overload' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -222,17 +222,22 @@ my $mapping2 = {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
|
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||||
{ oid => $mapping->{vsvrFullName}->{oid} },
|
oids => [
|
||||||
{ oid => $mapping->{vsvrState}->{oid} },
|
{ oid => $mapping->{vsvrFullName}->{oid} },
|
||||||
{ oid => $mapping->{vsvrEntityType}->{oid} },
|
{ oid => $mapping->{vsvrState}->{oid} },
|
||||||
], return_type => 1, nothing_quit => 1);
|
{ oid => $mapping->{vsvrEntityType}->{oid} },
|
||||||
|
],
|
||||||
|
return_type => 1,
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
$self->{vservers} = {};
|
$self->{vservers} = {};
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
next if ($oid !~ /^$mapping->{vsvrFullName}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{vsvrFullName}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
$result->{vsvrEntityType} !~ /$self->{option_results}->{filter_type}/) {
|
$result->{vsvrEntityType} !~ /$self->{option_results}->{filter_type}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping Virtual Server '" . $result->{vsvrFullName} . "'.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping Virtual Server '" . $result->{vsvrFullName} . "'.", debug => 1);
|
||||||
|
@ -246,15 +251,23 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{vservers}->{$instance} = { display => $result->{vsvrFullName}, state => $result->{vsvrState} };
|
$self->{vservers}->{$instance} = { display => $result->{vsvrFullName}, state => $result->{vsvrState} };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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},
|
$options{snmp}->load(
|
||||||
$mapping2->{vsvrTotalResponseBytesLow}->{oid}, $mapping2->{vsvrTotalResponseBytesHigh}->{oid},
|
oids => [
|
||||||
$mapping2->{vsvrTotalRequestBytes}->{oid}, $mapping2->{vsvrTotalResponseBytes}->{oid},
|
$mapping2->{vsvrTotalRequestBytesLow}->{oid}, $mapping2->{vsvrTotalRequestBytesHigh}->{oid},
|
||||||
$mapping2->{vsvrTotalClients}->{oid}, $mapping2->{vsvrHealth}->{oid}, $mapping2->{vsvrTotalServers}->{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);
|
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
|
||||||
|
|
||||||
foreach (keys %{$self->{vservers}}) {
|
foreach (keys %{$self->{vservers}}) {
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_);
|
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_);
|
||||||
|
|
||||||
|
@ -266,12 +279,7 @@ sub manage_selection {
|
||||||
$self->{vservers}->{$_}->{clients} = $result->{vsvrTotalClients};
|
$self->{vservers}->{$_}->{clients} = $result->{vsvrTotalClients};
|
||||||
$self->{vservers}->{$_}->{servers} = $result->{vsvrTotalServers};
|
$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() . '_' .
|
$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_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')) . '_' .
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
|
||||||
|
|
Loading…
Reference in New Issue