From b5adc5218d115b85396bd5fb75120b8b007c8fff Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 29 Jan 2020 15:03:26 +0100 Subject: [PATCH] break change: manage total license users --- network/juniper/common/ive/mode/users.pm | 94 ++++++++++++++++++------ 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/network/juniper/common/ive/mode/users.pm b/network/juniper/common/ive/mode/users.pm index a027551a5..d17c236fb 100644 --- a/network/juniper/common/ive/mode/users.pm +++ b/network/juniper/common/ive/mode/users.pm @@ -25,52 +25,89 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub custom_node_output { + my ($self, %options) = @_; + + if ($self->{result_values}->{node_total_absolute} ne '') { + return sprintf( + 'concurrent users licenses usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', + $self->{result_values}->{node_total_absolute}, + $self->{result_values}->{node_used_absolute}, + $self->{result_values}->{node_used_absolute} * 100 / $self->{result_values}->{node_total_absolute}, + $self->{result_values}->{node_total_absolute} - $self->{result_values}->{node_used_absolute}, + ($self->{result_values}->{node_total_absolute} - $self->{result_values}->{node_used_absolute}) * 100 / $self->{result_values}->{node_total_absolute} + ); + } else { + return sprintf( + 'concurrent users licenses used: %s', + $self->{result_values}->{node_used_absolute} + ); + } +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0, message_separator => ' - ' }, + { name => 'global', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } }, ]; $self->{maps_counters}->{global} = [ - { label => 'web', set => { + { label => 'node-users-usage', nlabel => 'node.users.usage.count', set => { + key_values => [ { name => 'node_used' }, { name => 'node_total' } ], + closure_custom_output => $self->can('custom_node_output'), + perfdatas => [ + { value => 'node_used_absolute', template => '%d', min => 0, max => 'node_total_absolute' }, + ], + } + }, + { label => 'node-users-free', nlabel => 'node.users.free.count', display_ok => 0, set => { + key_values => [ { name => 'node_free' }, { name => 'node_used' }, { name => 'node_total' } ], + closure_custom_output => $self->can('custom_node_output'), + perfdatas => [ + { value => 'node_free_absolute', template => '%d', min => 0, max => 'node_total_absolute' }, + ], + } + }, + { label => 'node-users-usage-prct', nlabel => 'node.users.usage.percentage', display_ok => 0, set => { + key_values => [ { name => 'prct_node_used' } ], + output_template => 'concurrent users licenses used: %.2f %%', + perfdatas => [ + { value => 'prct_node_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%' }, + ], + } + }, + { label => 'web-users-signedin-usage', nlabel => 'web.users.signedin.usage.count', set => { key_values => [ { name => 'web' } ], - output_template => 'Current concurrent signed-in web users connections: %s', output_error_template => 'Current concurrent signed-in web users connections: %s', + output_template => 'current concurrent signed-in web users connections: %s', perfdatas => [ - { label => 'web', value => 'web_absolute', template => '%s', min => 0 }, + { value => 'web_absolute', template => '%s', min => 0 }, ], } }, - { label => 'meeting', set => { + { label => 'meeting-users-usage', nlabel => 'meeting.users.usage.count', set => { key_values => [ { name => 'meeting' } ], - output_template => 'Current concurrent meeting users connections: %s', output_error_template => 'Current concurrent meeting users connections: %s', + output_template => 'current concurrent meeting users connections: %s', perfdatas => [ - { label => 'meeting', value => 'meeting_absolute', template => '%s', min => 0 }, + { value => 'meeting_absolute', template => '%s', min => 0 }, ], } }, - { label => 'node', set => { - key_values => [ { name => 'node' } ], - output_template => 'Current concurrent node logged users connections: %s', output_error_template => 'Current concurrent node logged users connections: %s', - perfdatas => [ - { label => 'node', value => 'node_absolute', template => '%s', min => 0 }, - ], - } - }, - { label => 'cluster', set => { + { label => 'cluster-users-usage', nlabel => 'cluster.users.usage.count', set => { key_values => [ { name => 'cluster' } ], - output_template => 'Current concurrent cluster logged users connections: %s', output_error_template => 'Current concurrent cluster logged users connections: %s', + output_template => 'current concurrent cluster logged users connections: %s', perfdatas => [ - { label => 'cluster', value => 'cluster_absolute', template => '%s', min => 0 }, + { value => 'cluster_absolute', template => '%s', min => 0 }, ], } - }, + } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -86,18 +123,27 @@ sub manage_selection { my $oid_meetingUserCount = '.1.3.6.1.4.1.12532.9.0'; my $oid_iveConcurrentUsers = '.1.3.6.1.4.1.12532.12.0'; my $oid_clusterConcurrentUsers = '.1.3.6.1.4.1.12532.13.0'; + my $oid_iveMaxConcurrentUsersLicenseCapacity = '.1.3.6.1.4.1.12532.55.0'; my $result = $options{snmp}->get_leef( oids => [ $oid_signedInWebUsers, $oid_meetingUserCount, - $oid_iveConcurrentUsers, $oid_clusterConcurrentUsers + $oid_iveConcurrentUsers, $oid_clusterConcurrentUsers, + $oid_iveMaxConcurrentUsersLicenseCapacity ], nothing_quit => 1 ); + $self->{global} = { web => $result->{$oid_signedInWebUsers}, meeting => $result->{$oid_meetingUserCount}, - node => $result->{$oid_iveConcurrentUsers}, - cluster => $result->{$oid_clusterConcurrentUsers} + cluster => $result->{$oid_clusterConcurrentUsers}, + node_used => $result->{$oid_iveConcurrentUsers}, + node_free => defined($result->{$oid_iveMaxConcurrentUsersLicenseCapacity}) && $result->{$oid_iveMaxConcurrentUsersLicenseCapacity} > 0 ? + $result->{$oid_iveMaxConcurrentUsersLicenseCapacity} - $result->{$oid_iveConcurrentUsers} : undef, + node_total => defined($result->{$oid_iveMaxConcurrentUsersLicenseCapacity}) && $result->{$oid_iveMaxConcurrentUsersLicenseCapacity} > 0 ? $result->{$oid_iveMaxConcurrentUsersLicenseCapacity} : '', + prct_node_used => + defined($result->{$oid_iveMaxConcurrentUsersLicenseCapacity}) && $result->{$oid_iveMaxConcurrentUsersLicenseCapacity} > 0 ? + $result->{$oid_iveConcurrentUsers} * 100 / $result->{$oid_iveMaxConcurrentUsersLicenseCapacity} : undef }; } @@ -114,7 +160,7 @@ Check users connections (web users, cluster users, node users, meeting users) (J =item B<--filter-counters> Only display some counters (regexp can be used). -Example: --filter-counters='^web|meeting$' +Example: --filter-counters='web|meeting' =item B<--warning-*> B<--critical-*>