From ac3cc971adbfa5c904cd170a94f6159797a378ed Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 27 Jul 2020 10:39:50 +0200 Subject: [PATCH] Fix #2077 --- .../apps/citrix/local/mode/folder.pm | 6 ++- .../apps/citrix/local/mode/session.pm | 48 +++++++++++-------- .../apps/citrix/local/mode/zone.pm | 37 +++++++------- centreon-plugins/apps/citrix/local/plugin.pm | 12 ++--- 4 files changed, 58 insertions(+), 45 deletions(-) diff --git a/centreon-plugins/apps/citrix/local/mode/folder.pm b/centreon-plugins/apps/citrix/local/mode/folder.pm index 6f7fbf575..2076b8473 100644 --- a/centreon-plugins/apps/citrix/local/mode/folder.pm +++ b/centreon-plugins/apps/citrix/local/mode/folder.pm @@ -94,8 +94,11 @@ sub run { short_msg => $numServers . " servers in in folder '" . $folderDN . "'" ); } + $self->{output}->perfdata_add( - label => 'servers_' . $folderDN, + label => 'servers', + nlabel => 'folder.servers.count', + instances => $folderDN value => $numServers, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), @@ -103,7 +106,6 @@ sub run { ); } - $self->{output}->display(); $self->{output}->exit(); } diff --git a/centreon-plugins/apps/citrix/local/mode/session.pm b/centreon-plugins/apps/citrix/local/mode/session.pm index 1d2d94024..82df91403 100644 --- a/centreon-plugins/apps/citrix/local/mode/session.pm +++ b/centreon-plugins/apps/citrix/local/mode/session.pm @@ -31,19 +31,19 @@ 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', }, - "domain:s" => { name => 'domain', }, - "filter-domain" => { name => 'filter_domain', }, - "farm:s" => { name => 'farm', }, - "filter-farm" => { name => 'filter_farm', }, - "server:s" => { name => 'server', }, - "filter-server" => { name => 'filter_server', }, - "zone:s" => { name => 'zone', }, - "filter-zone" => { name => 'filter_zone', }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' }, + 'domain:s' => { name => 'domain' }, + 'filter-domain' => { name => 'filter_domain' }, + 'farm:s' => { name => 'farm' }, + 'filter-farm' => { name => 'filter_farm' }, + 'server:s' => { name => 'server' }, + 'filter-server' => { name => 'filter_server' }, + 'zone:s' => { name => 'zone' }, + 'filter-zone' => { name => 'filter_zone' } + }); + $self->{wql_filter} = ''; return $self; } @@ -101,9 +101,11 @@ sub check_options { sub run { my ($self, %options) = @_; - $self->{output}->output_add(severity => 'Ok', - short_msg => "All sessions are ok"); - + $self->{output}->output_add( + severity => 'Ok', + short_msg => 'All sessions are ok' + ); + my $wmi = Win32::OLE->GetObject('winmgmts:root\citrix'); if (!defined($wmi)) { $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); @@ -127,11 +129,15 @@ sub run { $self->{output}->output_add(severity => $exit, short_msg => "Server '" . $server . "' active sessions : " . $activeSessions . " [disconnected sessions : " . $disconnectedSessions . "] [total sessions : " . $sessions . "]"); } - $self->{output}->perfdata_add(label => 'active_sessions_' . $server, - value => $activeSessions, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); + $self->{output}->perfdata_add( + label => 'active_sessions', + nlabel => 'sessions.active.count', + instances => $server, + value => $activeSessions, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0 + ); } diff --git a/centreon-plugins/apps/citrix/local/mode/zone.pm b/centreon-plugins/apps/citrix/local/mode/zone.pm index 04b71c082..d5a1c56ee 100644 --- a/centreon-plugins/apps/citrix/local/mode/zone.pm +++ b/centreon-plugins/apps/citrix/local/mode/zone.pm @@ -31,13 +31,13 @@ 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', }, - "zone:s" => { name => 'zone', }, - "filter-zone" => { name => 'filter_zone', }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' }, + 'zone:s' => { name => 'zone' }, + 'filter-zone' => { name => 'filter_zone' } + }); + $self->{wql_filter} = ''; return $self; } @@ -68,9 +68,11 @@ sub check_options { sub run { my ($self, %options) = @_; - $self->{output}->output_add(severity => 'Ok', - short_msg => "All zones are ok"); - + $self->{output}->output_add( + severity => 'Ok', + short_msg => 'All zones are ok' + ); + my $wmi = Win32::OLE->GetObject('winmgmts:root\citrix'); if (!defined($wmi)) { $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError()); @@ -89,14 +91,17 @@ sub run { $self->{output}->output_add(severity => $exit, short_msg => $numServers . " servers in zone '" . $zone . "'"); } - $self->{output}->perfdata_add(label => 'servers_' . $zone, - value => $numServers, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); + $self->{output}->perfdata_add( + label => 'servers', + nlabel => 'zone.servers.count', + instances => $zone, + value => $numServers, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0 + ); } - $self->{output}->display(); $self->{output}->exit(); } diff --git a/centreon-plugins/apps/citrix/local/plugin.pm b/centreon-plugins/apps/citrix/local/plugin.pm index f5863eebe..9813451c3 100644 --- a/centreon-plugins/apps/citrix/local/plugin.pm +++ b/centreon-plugins/apps/citrix/local/plugin.pm @@ -30,12 +30,12 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'folder' => 'apps::citrix::local::mode::folder', - 'license' => 'apps::citrix::local::mode::license', - 'session' => 'apps::citrix::local::mode::session', - 'zone' => 'apps::citrix::local::mode::zone', - ); + $self->{modes} = { + 'folder' => 'apps::citrix::local::mode::folder', + 'license' => 'apps::citrix::local::mode::license', + 'session' => 'apps::citrix::local::mode::session', + 'zone' => 'apps::citrix::local::mode::zone' + }; return $self; }