From 5cf7bc5d59101f5f1dbb32b8383272f4a54e88e6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Sun, 24 Jan 2016 21:30:54 +0100 Subject: [PATCH 1/4] + enhance output --- centreon-plugins/centreon/plugins/templates/counter.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/plugins/templates/counter.pm b/centreon-plugins/centreon/plugins/templates/counter.pm index 12bbf74b0..9ccd0394f 100644 --- a/centreon-plugins/centreon/plugins/templates/counter.pm +++ b/centreon-plugins/centreon/plugins/templates/counter.pm @@ -181,7 +181,7 @@ sub run_global { short_msg => "${prefix_output}${short_msg}${suffix_output}" ); } else { - $self->{output}->output_add(short_msg => "${prefix_output}${long_msg}${suffix_output}"); + $self->{output}->output_add(short_msg => "${prefix_output}${long_msg}${suffix_output}") if ($long_msg ne ''); } } From caa31d76dde31af711536ebe51a81731b4d5633c Mon Sep 17 00:00:00 2001 From: Yann Beulque Date: Mon, 25 Jan 2016 16:36:27 +0100 Subject: [PATCH 2/4] Update tablespaceusage.pm Add a spesific sql request for Oracle >= 11 The new sql request used Oracle View DBA_TABLESPACE_USAGE_METRICS Reduces the time of the request by the 20 large database --- .../database/oracle/mode/tablespaceusage.pm | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/centreon-plugins/database/oracle/mode/tablespaceusage.pm b/centreon-plugins/database/oracle/mode/tablespaceusage.pm index a60016bdc..610381c06 100644 --- a/centreon-plugins/database/oracle/mode/tablespaceusage.pm +++ b/centreon-plugins/database/oracle/mode/tablespaceusage.pm @@ -29,10 +29,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $self->{version} = '1.0'; $options{options}->add_options(arguments => - { + { "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, "filter:s" => { name => 'filter', }, @@ -67,7 +67,24 @@ sub run { $self->{sql}->connect(); my $query; - if ($self->{sql}->is_version_minimum(version => '9')) { + if ($self->{sql}->is_version_minimum(version => '11')) { + $query = q{ + SELECT + tum.tablespace_name "Tablespace", + t.status "Status", + t.contents "Type", + t.extent_management "Extent Mgmt", + tum.used_space*t.block_size bytes, + tum.tablespace_size*t.block_size bytes_max + FROM + DBA_TABLESPACE_USAGE_METRICS tum + INNER JOIN + dba_tablespaces t on tum.tablespace_name=t.tablespace_name + WHERE + t.contents<>'UNDO' + OR (t.contents='UNDO' AND t.tablespace_name =(SELECT value FROM v$parameter WHERE name='undo_tablespace')) + }; + } elsif ($self->{sql}->is_version_minimum(version => '9')) { $query = q{ SELECT a.tablespace_name "Tablespace", @@ -263,18 +280,24 @@ sub run { my ($name, $status, $type, $extentmgmt, $bytes, $bytes_max, $bytes_free) = @$row; next if (defined($self->{option_results}->{filter}) && $name !~ /$self->{option_results}->{filter}/); next if (defined($self->{option_results}->{skip}) && $status =~ /offline/i); - + if (!defined($bytes)) { # seems corrupted, cannot get value $self->{output}->output_add(severity => 'UNKNOWN', short_msg => sprintf("tbs '%s' cannot get data", $name)); next; } - + $status = lc $status; $type = lc $type; my ($percent_used, $percent_free, $used, $free, $size); - if ((!defined($bytes_max)) || ($bytes_max == 0)) { + if ($self->{sql}->is_version_minimum(version => '11')) { + $percent_used = $bytes / $bytes_max * 100; + $size = $bytes_max; + $free = $bytes_max - $bytes; + $used = $bytes; + } + elsif ((!defined($bytes_max)) || ($bytes_max == 0)) { $percent_used = ($bytes - $bytes_free) / $bytes * 100; $size = $bytes; $free = $bytes_free; @@ -306,7 +329,7 @@ sub run { min => 0, max => $size); } else { - my $exit_code = $self->{perfdata}->threshold_check(value => $percent_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $percent_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("tbs '%s' Used: %.2f%s (%.2f%%) Size: %.2f%s", $name, $used_value, $used_unit, $percent_used, $size_value, $size_unit)); From 552707add90ddf9f55ae5f00de9f5c49f7761d93 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 25 Jan 2016 17:02:53 +0100 Subject: [PATCH 3/4] + FIx indent --- centreon-plugins/database/oracle/mode/tablespaceusage.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/centreon-plugins/database/oracle/mode/tablespaceusage.pm b/centreon-plugins/database/oracle/mode/tablespaceusage.pm index 610381c06..14976bcd8 100644 --- a/centreon-plugins/database/oracle/mode/tablespaceusage.pm +++ b/centreon-plugins/database/oracle/mode/tablespaceusage.pm @@ -296,8 +296,7 @@ sub run { $size = $bytes_max; $free = $bytes_max - $bytes; $used = $bytes; - } - elsif ((!defined($bytes_max)) || ($bytes_max == 0)) { + } elsif ((!defined($bytes_max)) || ($bytes_max == 0)) { $percent_used = ($bytes - $bytes_free) / $bytes * 100; $size = $bytes; $free = $bytes_free; From 33fa104f9af077d51fba5ddcf8c07f1fabdf58b1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 27 Jan 2016 10:17:53 +0100 Subject: [PATCH 4/4] + Fix EMC navisphere disk mode: check last disk --- centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm index 62bfd9baa..9bd8cbada 100644 --- a/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon-plugins/centreon/common/emc/navisphere/mode/disk.pm @@ -264,6 +264,9 @@ sub run { #Busy Ticks: 462350 #Idle Ticks: 388743630 #Raid Group ID: 0 + + # Add a "\n" for the end. + $response .= "\n"; while ($response =~ /^Bus\s+(\S+)\s+Enclosure\s+(\S+)\s+Disk\s+(\S+)(.*?)\n\n/msgi) { my $disk_instance = "$1_$2_$3"; my $values = $4; @@ -319,7 +322,6 @@ sub run { $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); } - $self->{output}->output_add(long_msg => "Disk '$disk_instance':$long_msg"); $self->{output}->perfdata_add(label => $_ . '_' . $disk_instance, unit => $maps_counters->{$_}->{unit}, value => sprintf($maps_counters->{$_}->{perfdata}, $value_check), warning => $warning, @@ -327,6 +329,7 @@ sub run { min => 0); } + $self->{output}->output_add(long_msg => "Disk '$disk_instance':$long_msg"); $exit = $self->{output}->get_most_critical(status => [ @exits ]); if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { $self->{output}->output_add(severity => $exit,