From 5bea403b69e517b73b36e6c1d20a15f4dcb4adb6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Aug 2019 15:23:40 +0200 Subject: [PATCH 1/3] add oracle container option --- centreon-plugins/database/oracle/dbi.pm | 12 +++++++++++- centreon-plugins/database/oracle/plugin.pm | 9 ++++++++- centreon-plugins/database/oracle/sqlpluscmd.pm | 9 ++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/database/oracle/dbi.pm b/centreon-plugins/database/oracle/dbi.pm index b0b6a714c..0bc209df3 100644 --- a/centreon-plugins/database/oracle/dbi.pm +++ b/centreon-plugins/database/oracle/dbi.pm @@ -37,6 +37,13 @@ sub connect_oracle { ); } +sub check_options { + my ($self, %options) = @_; + + $self->{container} = defined($self->{option_results}->{container}[0]) ? $self->{option_results}->{container}[0] : undef; + return $self->SUPER::check_options(%options); +} + sub connect { my ($self, %options) = @_; my $dontquit = (defined($options{dontquit}) && $options{dontquit} == 1) ? 1 : 0; @@ -76,8 +83,11 @@ sub connect { } return (-1, $err_msg); } - + $self->set_version(); + if (defined($self->{container}) and $self->{container} ne '') { + $self->query(query => "alter session set container=$self->{container}"); + } return 0; } diff --git a/centreon-plugins/database/oracle/plugin.pm b/centreon-plugins/database/oracle/plugin.pm index 25209c030..2c6389a9f 100644 --- a/centreon-plugins/database/oracle/plugin.pm +++ b/centreon-plugins/database/oracle/plugin.pm @@ -75,6 +75,7 @@ sub init { 'port:s@' => { name => 'port' }, 'sid:s' => { name => 'sid' }, 'servicename:s' => { name => 'servicename' }, + 'container:s' => { name => 'container' }, }); $self->{options}->parse_options(); @@ -99,9 +100,11 @@ sub init { $self->{sqldefault}->{dbi}[$i]->{data_source} .= ';service_name=' . $options_result->{servicename}; $self->{sqldefault}->{sqlpluscmd}[$i]->{service_name} = $options_result->{servicename}; } + $self->{sqldefault}->{dbi}[$i]->{container} = $options_result->{container}; + $self->{sqldefault}->{sqlpluscmd}[$i]->{container} = $options_result->{container}; } } - $self->SUPER::init(%options); + $self->SUPER::init(%options); } 1; @@ -130,6 +133,10 @@ Database SID. Database Service Name. +=item B<--container> + +Change container (does an alter session set container command). + =back =cut diff --git a/centreon-plugins/database/oracle/sqlpluscmd.pm b/centreon-plugins/database/oracle/sqlpluscmd.pm index 869fa7132..2fbad25d8 100644 --- a/centreon-plugins/database/oracle/sqlpluscmd.pm +++ b/centreon-plugins/database/oracle/sqlpluscmd.pm @@ -109,12 +109,13 @@ sub check_options { # return 1 = ok still data_source # return 0 = no data_source left - $self->{sid} = defined($self->{option_results}->{sid}[0]) ? $self->{option_results}->{sid}[0]: $self->{option_results}->{tnsnames_sid}; - $self->{service_name} = defined($self->{option_results}->{service_name}[0]) ? $self->{option_results}->{service_name}[0]: $self->{option_results}->{tnsnames_servicename}; + $self->{sid} = defined($self->{option_results}->{sid}[0]) ? $self->{option_results}->{sid}[0] : $self->{option_results}->{tnsnames_sid}; + $self->{service_name} = defined($self->{option_results}->{service_name}[0]) ? $self->{option_results}->{service_name}[0] : $self->{option_results}->{tnsnames_servicename}; $self->{oracle_home} = defined($self->{option_results}->{oracle_home}) ? $self->{option_results}->{oracle_home} : $ENV{'ORACLE_HOME'}; $self->{tnsadmin_home} = defined($self->{option_results}->{tnsadmin_home}) ? $self->{option_results}->{tnsadmin_home} : $ENV{'TNSADMIN'}; $self->{local_connexion} = $self->{option_results}->{local_connexion}; $self->{sqlplus_cmd} = $self->{option_results}->{sqlplus_cmd}; + $self->{container} = defined($self->{option_results}->{container}[0]) ? $self->{option_results}->{container}[0] : undef; $self->{output}->output_add(long_msg => "*** DEBUG MODE****\n", debug => 1); $self->{output}->output_add(long_msg => Data::Dumper::Dumper($self->{option_results}), debug => 1); @@ -286,8 +287,10 @@ sub connect { } $self->{version} = $self->fetchrow_array(); - $self->{output}->output_add(long_msg => "VERSION: " . $self->{version}, debug => 1); + if (defined($self->{container}) and $self->{container} ne '') { + $self->query(query => "alter session set container=$self->{container}"); + } return 0; } From e388f1a84e5b57622c7500cb6a35493b2a4c4355 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Aug 2019 15:48:47 +0200 Subject: [PATCH 2/3] Fix #1599 --- .../apps/activedirectory/local/mode/dcdiag.pm | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm b/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm index 3ed092158..b46ab7e03 100644 --- a/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm +++ b/centreon-plugins/apps/activedirectory/local/mode/dcdiag.pm @@ -34,18 +34,19 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "config:s" => { name => 'config' }, - "language:s" => { name => 'language', default => 'en' }, - "dfsr" => { name => 'dfsr' }, - "noeventlog" => { name => 'noeventlog' }, - "nomachineaccount" => { name => 'nomachineaccount' }, - "timeout:s" => { name => 'timeout', default => 30 }, - }); + $options{options}->add_options(arguments => { + 'config:s' => { name => 'config' }, + 'language:s' => { name => 'language', default => 'en' }, + 'dfsr' => { name => 'dfsr' }, + 'noeventlog' => { name => 'noeventlog' }, + 'nomachineaccount' => { name => 'nomachineaccount' }, + 'timeout:s' => { name => 'timeout', default => 30 }, + }); + $self->{os_is2003} = 0; $self->{os_is2008} = 0; $self->{os_is2012} = 0; + $self->{os_is2016} = 0; $self->{msg} = { global => undef, ok => undef, warning => undef, critical => undef }; return $self; @@ -71,12 +72,15 @@ sub check_version { # 5.1, 5.2 => XP/2003 # 6.0, 6.1 => Vista/7/2008 # 6.2, 6.3 => 2012 + # 10.0 => 2016, 2019 if ($ver_major == 5 && ($ver_minor == 1 || $ver_minor == 2)) { $self->{os_is2003} = 1; } elsif ($ver_major == 6 && ($ver_minor == 0 || $ver_minor == 1)) { $self->{os_is2008} = 1; } elsif ($ver_major == 6 && ($ver_minor == 2 || $ver_minor == 3)) { $self->{os_is2012} = 1; + } elsif ($ver_major == 10 && $ver_minor == 0) { + $self->{os_is2016} = 1; } else { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => 'OS version ' . $ver_major . '.' . $ver_minor . ' not managed.'); @@ -135,19 +139,21 @@ sub dcdiag { my $dcdiag_cmd = 'dcdiag /test:services /test:replications /test:advertising /test:fsmocheck /test:ridmanager'; $dcdiag_cmd .= ' /test:machineaccount' if (!defined($self->{option_results}->{nomachineaccount})); $dcdiag_cmd .= ' /test:frssysvol' if ($self->{os_is2003} == 1); - $dcdiag_cmd .= ' /test:sysvolcheck' if ($self->{os_is2008} == 1 || $self->{os_is2012} == 1); + $dcdiag_cmd .= ' /test:sysvolcheck' if ($self->{os_is2008} == 1 || $self->{os_is2012} == 1 || $self->{os_is2016} == 1); if (!defined($self->{option_results}->{noeventlog})) { $dcdiag_cmd .= ' /test:frsevent /test:kccevent' if ($self->{os_is2003} == 1); - $dcdiag_cmd .= ' /test:frsevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1) && !defined($self->{option_results}->{dfsr})); - $dcdiag_cmd .= ' /test:dfsrevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1) && defined($self->{option_results}->{dfsr})); + $dcdiag_cmd .= ' /test:frsevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1 || $self->{os_is2016} == 1) && !defined($self->{option_results}->{dfsr})); + $dcdiag_cmd .= ' /test:dfsrevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1 || $self->{os_is2016} == 1) && defined($self->{option_results}->{dfsr})); } - my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, - timeout => $self->{option_results}->{timeout}, - command => $dcdiag_cmd, - command_path => undef, - command_options => undef); + my ($stdout) = centreon::plugins::misc::windows_execute( + output => $self->{output}, + timeout => $self->{option_results}->{timeout}, + command => $dcdiag_cmd, + command_path => undef, + command_options => undef + ); my $match = 0; while ($stdout =~ /$self->{msg}->{global}/imsg) { From f4a0ab420a170bf08a648552b0fb602675b2ae56 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 1 Aug 2019 16:35:36 +0200 Subject: [PATCH 3/3] Fix #1597 --- centreon-plugins/snmp_standard/mode/printererror.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/snmp_standard/mode/printererror.pm b/centreon-plugins/snmp_standard/mode/printererror.pm index d436460eb..f4f38df84 100644 --- a/centreon-plugins/snmp_standard/mode/printererror.pm +++ b/centreon-plugins/snmp_standard/mode/printererror.pm @@ -75,10 +75,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "ok-status:s" => { name => 'ok_status', default => '%{status} =~ /ok/' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /.*/' }, - "critical-status:s" => { name => 'critical_status', default => '' }, + 'ok-status:s' => { name => 'ok_status', default => '%{status} =~ /ok/' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /.*/' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, }); return $self; @@ -121,7 +121,10 @@ sub manage_selection { my $instance = $1; # 16 bits value my $value = unpack('S', $result->{$_}); - + if (!defined($value)) { + $value = ord($result->{$_}); + } + $self->{printer}->{$instance} = { display => $instance, errors => {} }; my $i = 0; foreach my $key (keys %errors_printer) {