From d63c1e898b539766e62a56611d88443a26f0ab68 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 23 Jun 2020 13:51:44 +0200 Subject: [PATCH] Ref #2034 --- .../citrix/netscaler/snmp/mode/connections.pm | 40 +++++++-------- network/citrix/netscaler/snmp/mode/memory.pm | 16 +++--- network/citrix/netscaler/snmp/mode/storage.pm | 16 +++--- .../netscaler/snmp/mode/vserverstatus.pm | 49 ++++++++----------- 4 files changed, 56 insertions(+), 65 deletions(-) diff --git a/network/citrix/netscaler/snmp/mode/connections.pm b/network/citrix/netscaler/snmp/mode/connections.pm index 22f032fcb..3b8da7a36 100644 --- a/network/citrix/netscaler/snmp/mode/connections.pm +++ b/network/citrix/netscaler/snmp/mode/connections.pm @@ -33,33 +33,30 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'active', set => { + { label => 'active', nlabel => 'connections.server.active.count', set => { key_values => [ { name => 'active' } ], - output_template => 'Active Server TCP connections : %s', + output_template => 'Active Server TCP connections: %s', perfdatas => [ - { label => 'active_server', value => 'active', template => '%s', - unit => 'con', min => 0 }, - ], + { label => 'active_server', template => '%s', unit => 'con', min => 0 } + ] } }, - { label => 'server', set => { + { label => 'server', nlabel => 'connections.server.count', set => { key_values => [ { name => 'server' } ], - output_template => 'Server TCP connections : %s', + output_template => 'Server TCP connections: %s', perfdatas => [ - { label => 'server', value => 'server', template => '%s', - unit => 'con', min => 0 }, - ], + { label => 'server', template => '%s', unit => 'con', min => 0 } + ] } }, - { label => 'client', set => { + { label => 'client', nlabel => 'connections.client.count', set => { key_values => [ { name => 'client' } ], - output_template => 'Client TCP connections : %s', + output_template => 'Client TCP connections: %s', perfdatas => [ - { label => 'client', value => 'client', template => '%s', - unit => 'con', min => 0 }, - ], + { label => 'client', template => '%s', unit => 'con', min => 0 } + ] } - }, + } ]; } @@ -67,11 +64,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } @@ -110,4 +106,4 @@ Can be: 'server', 'active', 'client'. =back -=cut \ No newline at end of file +=cut diff --git a/network/citrix/netscaler/snmp/mode/memory.pm b/network/citrix/netscaler/snmp/mode/memory.pm index 7648ed122..1bbc954d3 100644 --- a/network/citrix/netscaler/snmp/mode/memory.pm +++ b/network/citrix/netscaler/snmp/mode/memory.pm @@ -29,10 +29,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { 'warning:s' => { name => 'warning' }, - 'critical:s' => { name => 'critical' }, + 'critical:s' => { name => 'critical' } }); return $self; @@ -64,9 +64,11 @@ sub run { my $used = $result->{$oid_resMemUsage} * $total_size / 100; my $free = $total_size - $used; - my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_resMemUsage}, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - + my $exit = $self->{perfdata}->threshold_check( + value => $result->{$oid_resMemUsage}, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ] + ); + my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used); my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free); @@ -82,7 +84,9 @@ sub run { ); $self->{output}->perfdata_add( - label => "used", unit => 'B', + label => 'used', + nlabel => 'memory.usage.bytes', + 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), diff --git a/network/citrix/netscaler/snmp/mode/storage.pm b/network/citrix/netscaler/snmp/mode/storage.pm index 5a97076d0..68947b8d9 100644 --- a/network/citrix/netscaler/snmp/mode/storage.pm +++ b/network/citrix/netscaler/snmp/mode/storage.pm @@ -27,20 +27,20 @@ use warnings; sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'storage', type => 1, cb_prefix_output => 'prefix_storage_output', message_multiple => 'All storages are ok' } ]; - + $self->{maps_counters}->{storage} = [ { label => 'usage', set => { key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), closure_custom_perfdata => $self->can('custom_usage_perfdata'), - closure_custom_threshold_check => $self->can('custom_usage_threshold'), + closure_custom_threshold_check => $self->can('custom_usage_threshold') } - }, + } ]; } @@ -112,7 +112,7 @@ sub custom_usage_calc { sub prefix_volume_output { my ($self, %options) = @_; - + return "Storage '" . $options{instance_value}->{display} . "' "; } @@ -124,7 +124,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-name:s' => { name => 'filter_name' }, 'units:s' => { name => 'units', default => '%' }, - 'free' => { name => 'free' }, + 'free' => { name => 'free' } }); return $self; @@ -156,7 +156,7 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $result->{sysHealthDiskName} . "': no matching filter.", debug => 1); next; } - + $result->{sysHealthDiskSize} *= 1024 * 1024; $result->{sysHealthDiskUsed} *= 1024 * 1024; $self->{storage}->{$instance} = { @@ -167,7 +167,7 @@ sub manage_selection { } if (scalar(keys %{$self->{storage}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "No storage found."); + $self->{output}->add_option_msg(short_msg => 'No storage found.'); $self->{output}->option_exit(); } } diff --git a/network/citrix/netscaler/snmp/mode/vserverstatus.pm b/network/citrix/netscaler/snmp/mode/vserverstatus.pm index ae570f0dd..1b63be094 100644 --- a/network/citrix/netscaler/snmp/mode/vserverstatus.pm +++ b/network/citrix/netscaler/snmp/mode/vserverstatus.pm @@ -36,59 +36,58 @@ sub set_counters { $self->{maps_counters}->{vservers} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'state' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_threshold_output'), + closure_custom_threshold_check => $self->can('custom_threshold_output') } }, - { label => 'health', set => { + { label => 'health', nlabel => 'vserver.health.percentage', set => { key_values => [ { name => 'health' }, { name => 'display' } ], output_template => 'Health: %.2f %%', output_error_template => 'Health: %s', perfdatas => [ { label => 'health', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, - ], + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'in-traffic', set => { + { label => 'in-traffic', nlabel => 'vserver.traffic.in.bitspersecond', set => { key_values => [ { name => 'in', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ { label => 'traffic_in', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'out-traffic', set => { + { label => 'out-traffic', nlabel => 'vserver.traffic.out.bitspersecond', set => { key_values => [ { name => 'out', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ { label => 'traffic_out', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'clients', set => { + { label => 'clients', nlabel => 'vserver.connections.client.count', set => { key_values => [ { name => 'clients', diff => 1 }, { name => 'display' } ], output_template => 'Total Client Connections : %s', perfdatas => [ { label => 'clients', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'servers', set => { + { label => 'servers', nlabel => 'vserver.connections.server.count', set => { key_values => [ { name => 'servers', diff => 1 }, { name => 'display' } ], output_template => 'Total Server Connections : %s', perfdatas => [ { label => 'servers', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -138,16 +137,8 @@ sub custom_threshold_output { sub custom_status_output { my ($self, %options) = @_; - my $msg = 'State : ' . $self->{result_values}->{state}; - return $msg; -} - -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; - return 0; + return 'State : ' . $self->{result_values}->{state}; } sub new { @@ -158,7 +149,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-name:s' => { name => 'filter_name' }, 'filter-type:s' => { name => 'filter_type' }, - 'threshold-overload:s@' => { name => 'threshold_overload' }, + 'threshold-overload:s@' => { name => 'threshold_overload' } }); return $self; @@ -226,7 +217,7 @@ sub manage_selection { oids => [ { oid => $mapping->{vsvrFullName}->{oid} }, { oid => $mapping->{vsvrState}->{oid} }, - { oid => $mapping->{vsvrEntityType}->{oid} }, + { oid => $mapping->{vsvrEntityType}->{oid} } ], return_type => 1, nothing_quit => 1