diff --git a/network/citrix/netscaler/snmp/mode/cpu.pm b/network/citrix/netscaler/snmp/mode/cpu.pm index abc25cc86..ff394a999 100644 --- a/network/citrix/netscaler/snmp/mode/cpu.pm +++ b/network/citrix/netscaler/snmp/mode/cpu.pm @@ -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; } diff --git a/network/citrix/netscaler/snmp/mode/memory.pm b/network/citrix/netscaler/snmp/mode/memory.pm index 3b8468ea4..eadba110c 100644 --- a/network/citrix/netscaler/snmp/mode/memory.pm +++ b/network/citrix/netscaler/snmp/mode/memory.pm @@ -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; } @@ -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%%)", - $total_value . " " . $total_unit, - $used_value . " " . $used_unit, $result->{$oid_resMemUsage}, - $free_value . " " . $free_unit, (100 - $result->{$oid_resMemUsage}))); + $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}) + ) + ); - $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); + $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 + ); $self->{output}->display(); $self->{output}->exit(); diff --git a/network/citrix/netscaler/snmp/mode/storage.pm b/network/citrix/netscaler/snmp/mode/storage.pm index 5fd583096..926e2eec8 100644 --- a/network/citrix/netscaler/snmp/mode/storage.pm +++ b/network/citrix/netscaler/snmp/mode/storage.pm @@ -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}\.(.*)$/); diff --git a/network/citrix/netscaler/snmp/mode/vserverstatus.pm b/network/citrix/netscaler/snmp/mode/vserverstatus.pm index ae71ebefe..ac92b2c11 100644 --- a/network/citrix/netscaler/snmp/mode/vserverstatus.pm +++ b/network/citrix/netscaler/snmp/mode/vserverstatus.pm @@ -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,17 +222,22 @@ my $mapping2 = { sub manage_selection { my ($self, %options) = @_; - 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); + 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 + ); + $self->{vservers} = {}; foreach my $oid (keys %{$snmp_result}) { next if ($oid !~ /^$mapping->{vsvrFullName}->{oid}\.(.*)$/); my $instance = $1; 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 '' && $result->{vsvrEntityType} !~ /$self->{option_results}->{filter_type}/) { $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} }; } + + 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} + $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}}) { 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}->{$_}->{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')) . '_' .