From 4b8e193dc49eccecbf45728100b026bd0224784c Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Fri, 22 Jan 2016 21:42:16 +0100 Subject: [PATCH 01/22] Added new apcupsd format --- apps/apcupsd/local/mode/libgetdata.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/apcupsd/local/mode/libgetdata.pm b/apps/apcupsd/local/mode/libgetdata.pm index f82e703b9..0d9f3d4e1 100644 --- a/apps/apcupsd/local/mode/libgetdata.pm +++ b/apps/apcupsd/local/mode/libgetdata.pm @@ -41,7 +41,7 @@ sub getdata { my ($value); #print $stdout; foreach (split(/\n/, $stdout)) { - if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal)/i) { + if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal|C|F)/i) { $valueok = "1"; $value = $1; #print $value; From 09582826aa915dfd2f575d74891347b727049139 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sat, 23 Jan 2016 14:40:16 +0100 Subject: [PATCH 02/22] + add tables-size mode to plugin.pm --- database/mysql/plugin.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/database/mysql/plugin.pm b/database/mysql/plugin.pm index 5ae0b6c5c..916f9f133 100644 --- a/database/mysql/plugin.pm +++ b/database/mysql/plugin.pm @@ -47,6 +47,7 @@ sub new { 'sql' => 'centreon::common::protocols::sql::mode::sql', 'threads-connected' => 'database::mysql::mode::threadsconnected', 'uptime' => 'database::mysql::mode::uptime', + 'tables-size' => 'database::mysql::mode::tablessize', ); $self->{sql_modes}{mysqlcmd} = 'database::mysql::mysqlcmd'; From e905d5d1f9db793b24d7af7e53605ab7e16c0fad Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sat, 23 Jan 2016 14:43:06 +0100 Subject: [PATCH 03/22] + add tablessize.pm mode enhancement: https://github.com/centreon/centreon-plugins/issues/293 --- database/mysql/mode/tablessize.pm | 137 ++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 database/mysql/mode/tablessize.pm diff --git a/database/mysql/mode/tablessize.pm b/database/mysql/mode/tablessize.pm new file mode 100644 index 000000000..71541766d --- /dev/null +++ b/database/mysql/mode/tablessize.pm @@ -0,0 +1,137 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package database::mysql::mode::tablessize; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +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', }, + "db-table:s" => { name => 'db_table', }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{db_table}) || $self->{option_results}->{db_table} !~ /\./) { + $self->{output}->add_option_msg(short_msg => "Check --db-table option (mandatory) formatting"); + $self->{output}->option_exit(); + } + + ($self->{db}, $self->{table}) = split(/\./, $self->{option_results}->{db_table}) if (defined ($self->{option_results}->{db_table})); + +} + +sub run { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + my $multiple = 0; + my $query = "SELECT table_name AS NAME, ROUND(data_length+index_length) + FROM information_schema.TABLES + WHERE table_schema = '" . $self->{db}. "' AND table_name LIKE '" . $self->{table} . "'"; + + $self->{sql}->query(query => $query); + my $result = $self->{sql}->fetchall_arrayref(); + + if (!($self->{sql}->is_version_minimum(version => '5'))) { + $self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported."); + $self->{output}->option_exit(); + } + + if (scalar (@$result) > 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => "All tables are ok."); + $multiple = 1; + } + + foreach my $row (@$result) { + my $exit_code = $self->{perfdata}->threshold_check(value => $$row[1], threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my ($value, $value_unit) = $self->{perfdata}->change_bytes(value => $$row[1]); + $self->{output}->output_add(long_msg => sprintf("Table '" . $$row[0] . "' size: %s%s", $value, $value_unit)); + if ($multiple == 0 || !$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("Table '%s' size is '%i%s'", $$row[0], $value, $value_unit)); + } + $self->{output}->perfdata_add(label => $$row[0] . '_size', unit => 'B', + value => $$row[1], + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0); + } + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => sprintf("Didn't find table '%s' in '%s' database !", $self->{table}, $self->{db})) if (scalar(@$result) == 0); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check MySQL tables size. + +=over 8 + +=item B<--warning> + +Threshold warning in bytes. + +=item B<--critical> + +Threshold critical in bytes. + +=item B<--db-table> + +Filter database and table to check [use '%' wildcard with caution!] +e.g unique : --db-table database.table_name +e.g multiple : --db-table database.table_% + +=back + +=cut From 4c16b235dcea5f5571f8eed1ad149c4a95d03ddd Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sat, 23 Jan 2016 20:05:10 +0100 Subject: [PATCH 04/22] + update tablessize.pm after PR comment see https://github.com/centreon/centreon-plugins/pull/299 --- database/mysql/mode/tablessize.pm | 55 ++++++++++++++----------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/database/mysql/mode/tablessize.pm b/database/mysql/mode/tablessize.pm index 71541766d..3a93c93a1 100644 --- a/database/mysql/mode/tablessize.pm +++ b/database/mysql/mode/tablessize.pm @@ -35,7 +35,7 @@ sub new { { "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, - "db-table:s" => { name => 'db_table', }, + "db-table:s@" => { name => 'db_table', }, }); return $self; @@ -53,13 +53,18 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } - if (!defined($self->{option_results}->{db_table}) || $self->{option_results}->{db_table} !~ /\./) { - $self->{output}->add_option_msg(short_msg => "Check --db-table option (mandatory) formatting"); + if (!defined(@{$self->{option_results}->{db_table}})) { + $self->{output}->add_option_msg(short_msg => "Please define --db-table option"); $self->{output}->option_exit(); } - - ($self->{db}, $self->{table}) = split(/\./, $self->{option_results}->{db_table}) if (defined ($self->{option_results}->{db_table})); - + foreach (@{$self->{option_results}->{db_table}}) { + my ($db, $table) = split /\./; + if (!defined($db) || !defined($table)) { + $self->{output}->add_option_msg(short_msg => "Check --db-table option formatting : '" . $_ . "'"); + $self->{output}->option_exit(); + } + $self->{filter}->{$db.$table} = 1; + } } sub run { @@ -67,13 +72,9 @@ sub run { # $options{sql} = sqlmode object $self->{sql} = $options{sql}; $self->{sql}->connect(); - - my $multiple = 0; - my $query = "SELECT table_name AS NAME, ROUND(data_length+index_length) - FROM information_schema.TABLES - WHERE table_schema = '" . $self->{db}. "' AND table_name LIKE '" . $self->{table} . "'"; - - $self->{sql}->query(query => $query); + $self->{sql}->query(query => "SELECT table_schema AS DB, table_name AS NAME, ROUND(data_length + index_length) + FROM information_schema.TABLES"); + my $result = $self->{sql}->fetchall_arrayref(); if (!($self->{sql}->is_version_minimum(version => '5'))) { @@ -81,28 +82,24 @@ sub run { $self->{output}->option_exit(); } - if (scalar (@$result) > 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => "All tables are ok."); - $multiple = 1; - } + $self->{output}->output_add(severity => 'OK', + short_msg => "All tables are ok."); foreach my $row (@$result) { - my $exit_code = $self->{perfdata}->threshold_check(value => $$row[1], threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - my ($value, $value_unit) = $self->{perfdata}->change_bytes(value => $$row[1]); - $self->{output}->output_add(long_msg => sprintf("Table '" . $$row[0] . "' size: %s%s", $value, $value_unit)); - if ($multiple == 0 || !$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { + next if (!defined($self->{filter}->{$$row[0].$$row[1]}) || !defined($$row[2])); + my $exit_code = $self->{perfdata}->threshold_check(value => $$row[2], threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my ($value, $value_unit) = $self->{perfdata}->change_bytes(value => $$row[2]); + $self->{output}->output_add(long_msg => sprintf("Database: '%s' Table: '%s' Size: '%s%s'", $$row[0], $$row[1], $value, $value_unit)); + if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Table '%s' size is '%i%s'", $$row[0], $value, $value_unit)); + short_msg => sprintf("Table '%s' size in db '%s' is '%i%s'", $$row[0], $$row[1], $value, $value_unit)); } - $self->{output}->perfdata_add(label => $$row[0] . '_size', unit => 'B', - value => $$row[1], + $self->{output}->perfdata_add(label => $$row[0] . '_' . $$row[1] . '_size', unit => 'B', + value => $$row[2], warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); } - $self->{output}->output_add(severity => 'UNKNOWN', - short_msg => sprintf("Didn't find table '%s' in '%s' database !", $self->{table}, $self->{db})) if (scalar(@$result) == 0); $self->{output}->display(); $self->{output}->exit(); @@ -128,9 +125,7 @@ Threshold critical in bytes. =item B<--db-table> -Filter database and table to check [use '%' wildcard with caution!] -e.g unique : --db-table database.table_name -e.g multiple : --db-table database.table_% +Filter database and table to check (multiple: eg: --db-table centreon_storage.data_bin --db-table centreon_storage.logs) =back From 2e7ef058d9b3c689fa940e1477fb3ab2a017db13 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sun, 24 Jan 2016 11:58:05 +0100 Subject: [PATCH 05/22] + init filter for greater clarity --- database/mysql/mode/tablessize.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/mysql/mode/tablessize.pm b/database/mysql/mode/tablessize.pm index 3a93c93a1..4fe8f75ab 100644 --- a/database/mysql/mode/tablessize.pm +++ b/database/mysql/mode/tablessize.pm @@ -37,7 +37,7 @@ sub new { "critical:s" => { name => 'critical', }, "db-table:s@" => { name => 'db_table', }, }); - + $self->{filter} = {}; return $self; } From 2ac22a50feaf1c5c17250dd43262d713da825a49 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sun, 24 Jan 2016 21:13:10 +0100 Subject: [PATCH 06/22] + refactor tablessize.pm with new template --- database/mysql/mode/tablessize.pm | 123 +++++++++++++++++------------- 1 file changed, 70 insertions(+), 53 deletions(-) diff --git a/database/mysql/mode/tablessize.pm b/database/mysql/mode/tablessize.pm index 4fe8f75ab..1bc21020b 100644 --- a/database/mysql/mode/tablessize.pm +++ b/database/mysql/mode/tablessize.pm @@ -20,11 +20,45 @@ package database::mysql::mode::tablessize; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'table', type => 1, cb_prefix_output => 'prefix_table_output', message_multiple => 'All tables sizes are ok' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => 'Total Size : %s%s', + output_change_bytes => 1, + perfdatas => [ + { label => 'total', value => 'total_absolute', template => '%s', + unit => 'B', min => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{table} = [ + { label => 'table', set => { + key_values => [ { name => 'size' }, { name => 'display' } ], + output_template => 'size : %s%s', + output_change_bytes => 1, + perfdatas => [ + { label => 'table', value => 'size_absolute', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -33,48 +67,26 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - "db-table:s@" => { name => 'db_table', }, + "filter-db:s" => { name => 'filter_db' }, + "filter-table:s" => { name => 'filter_table' }, }); - $self->{filter} = {}; return $self; } -sub check_options { +sub prefix_table_output { my ($self, %options) = @_; - $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (!defined(@{$self->{option_results}->{db_table}})) { - $self->{output}->add_option_msg(short_msg => "Please define --db-table option"); - $self->{output}->option_exit(); - } - foreach (@{$self->{option_results}->{db_table}}) { - my ($db, $table) = split /\./; - if (!defined($db) || !defined($table)) { - $self->{output}->add_option_msg(short_msg => "Check --db-table option formatting : '" . $_ . "'"); - $self->{output}->option_exit(); - } - $self->{filter}->{$db.$table} = 1; - } + return "Table '" . $options{instance_value}->{display} . "' "; } -sub run { +sub manage_selection { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; $self->{sql}->connect(); + $self->{sql}->query(query => "SELECT table_schema AS DB, table_name AS NAME, ROUND(data_length + index_length) FROM information_schema.TABLES"); - my $result = $self->{sql}->fetchall_arrayref(); if (!($self->{sql}->is_version_minimum(version => '5'))) { @@ -82,27 +94,24 @@ sub run { $self->{output}->option_exit(); } - $self->{output}->output_add(severity => 'OK', - short_msg => "All tables are ok."); + $self->{global} = { total => 0 }; + $self->{table} = {}; foreach my $row (@$result) { - next if (!defined($self->{filter}->{$$row[0].$$row[1]}) || !defined($$row[2])); - my $exit_code = $self->{perfdata}->threshold_check(value => $$row[2], threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - my ($value, $value_unit) = $self->{perfdata}->change_bytes(value => $$row[2]); - $self->{output}->output_add(long_msg => sprintf("Database: '%s' Table: '%s' Size: '%s%s'", $$row[0], $$row[1], $value, $value_unit)); - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Table '%s' size in db '%s' is '%i%s'", $$row[0], $$row[1], $value, $value_unit)); + next if (!defined($$row[2])); + if (defined($self->{option_results}->{filter_table}) && $self->{option_results}->{filter_table} ne '' && + $$row[1] !~ /$self->{option_results}->{filter_table}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1); + next; } - $self->{output}->perfdata_add(label => $$row[0] . '_' . $$row[1] . '_size', unit => 'B', - value => $$row[2], - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); + if (defined($self->{option_results}->{filter_db}) && $self->{option_results}->{filter_db} ne '' && + $$row[0] !~ /$self->{option_results}->{filter_db}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1); + next + } + $self->{table}->{$$row[0].'.'.$$row[1]} = { size => $$row[2], display => $$row[0].'.'.$$row[1] }; + $self->{global}->{total} += $$row[2] if defined($self->{table}->{$$row[0].'.'.$$row[1]}); } - - $self->{output}->display(); - $self->{output}->exit(); } 1; @@ -111,21 +120,29 @@ __END__ =head1 MODE -Check MySQL tables size. +Check AP status. =over 8 -=item B<--warning> +=item B<--filter-counters> -Threshold warning in bytes. +Only display some counters (regexp can be used). -=item B<--critical> +=item B<--filter-db> -Threshold critical in bytes. +Filter DB name (can be a regexp). -=item B<--db-table> +=item B<--filter-table> -Filter database and table to check (multiple: eg: --db-table centreon_storage.data_bin --db-table centreon_storage.logs) +Filter table name (can be a regexp). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'total', 'table' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'total', 'table' =back From 2d0a8e2b2b082c8ae9a7cb678ac1f3c2b2b1ca8e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Sun, 24 Jan 2016 21:30:54 +0100 Subject: [PATCH 07/22] + enhance output --- centreon/plugins/templates/counter.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index 12bbf74b0..9ccd0394f 100644 --- a/centreon/plugins/templates/counter.pm +++ b/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 07fecc04665254a79daf7184e4ded6f3659a54b0 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sun, 24 Jan 2016 21:46:51 +0100 Subject: [PATCH 08/22] + fix help mode description --- database/mysql/mode/tablessize.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/mysql/mode/tablessize.pm b/database/mysql/mode/tablessize.pm index 1bc21020b..da2699bd9 100644 --- a/database/mysql/mode/tablessize.pm +++ b/database/mysql/mode/tablessize.pm @@ -120,7 +120,7 @@ __END__ =head1 MODE -Check AP status. +Check size of one (or more) table from one (or more) databases =over 8 From 80a73422e049d106cb4e5e16db2a869930917374 Mon Sep 17 00:00:00 2001 From: Yann Beulque Date: Mon, 25 Jan 2016 16:36:27 +0100 Subject: [PATCH 09/22] 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/database/oracle/mode/tablespaceusage.pm b/database/oracle/mode/tablespaceusage.pm index a60016bdc..610381c06 100644 --- a/database/oracle/mode/tablespaceusage.pm +++ b/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 e07c1cec1645ac12ca53308192543cffdd91fc4b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 25 Jan 2016 17:02:53 +0100 Subject: [PATCH 10/22] + FIx indent --- database/oracle/mode/tablespaceusage.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/oracle/mode/tablespaceusage.pm b/database/oracle/mode/tablespaceusage.pm index 610381c06..14976bcd8 100644 --- a/database/oracle/mode/tablespaceusage.pm +++ b/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 52296a8cde96517ece3c1c203b1b5380ddf3beee Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 27 Jan 2016 10:17:53 +0100 Subject: [PATCH 11/22] + Fix EMC navisphere disk mode: check last disk --- centreon/common/emc/navisphere/mode/disk.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/centreon/common/emc/navisphere/mode/disk.pm b/centreon/common/emc/navisphere/mode/disk.pm index 62bfd9baa..9bd8cbada 100644 --- a/centreon/common/emc/navisphere/mode/disk.pm +++ b/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, From b29ed25a26364b2837a11b641c964988b7fbd590 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 27 Jan 2016 10:39:23 +0100 Subject: [PATCH 12/22] + fix typo in error message --- centreon/common/powershell/exchange/2010/replicationhealth.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon/common/powershell/exchange/2010/replicationhealth.pm b/centreon/common/powershell/exchange/2010/replicationhealth.pm index fe436d15c..2188505c1 100644 --- a/centreon/common/powershell/exchange/2010/replicationhealth.pm +++ b/centreon/common/powershell/exchange/2010/replicationhealth.pm @@ -89,7 +89,7 @@ sub check { } if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $status, - short_msg => sprintf("Replicatin test '%s' status on '%s' is '%s' [error: %s]", + short_msg => sprintf("Replication test '%s' status on '%s' is '%s' [error: %s]", $self->{data}->{check}, $self->{data}->{server}, $self->{data}->{result}, $self->{data}->{error})); } } @@ -108,4 +108,4 @@ __END__ Method to check Exchange 2010 queues. -=cut \ No newline at end of file +=cut From 918b718fb970adb0465d3e2896b9175b897cec26 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 29 Jan 2016 13:26:44 +0100 Subject: [PATCH 13/22] + Fix #306 --- .../common/cisco/standard/snmp/mode/ipsla.pm | 697 ++++++++---------- centreon/plugins/templates/counter.pm | 3 +- 2 files changed, 304 insertions(+), 396 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/ipsla.pm b/centreon/common/cisco/standard/snmp/mode/ipsla.pm index 0f49960f9..8bcb53c07 100644 --- a/centreon/common/cisco/standard/snmp/mode/ipsla.pm +++ b/centreon/common/cisco/standard/snmp/mode/ipsla.pm @@ -20,286 +20,292 @@ package centreon::common::cisco::standard::snmp::mode::ipsla; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::statefile; -use centreon::plugins::values; use Digest::MD5 qw(md5_hex); use Math::Complex; -my $maps_counters = { - '000_status' => { class => 'centreon::plugins::values', obj => undef, threshold => 0, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, - { name => 'rttMonCtrlAdminTag' }, - { name => 'rttMonCtrlAdminRttType' }, - { name => 'rttMonCtrlAdminThreshold' }, - { name => 'rttMonEchoAdminPrecision' }, - { name => 'rttMonLatestRttOperCompletionTime' }, - { name => 'rttMonLatestRttOperSense' }, - { name => 'rttMonLatestRttOperApplSpecificSense' }, - ], - closure_custom_calc => \&custom_status_calc, - closure_custom_output => \&custom_status_output, - closure_custom_perfdata => \&custom_status_perfdata, - closure_custom_threshold_check => \&custom_status_threshold, - } - }, - '001_NumberOverThresholds' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OverThresholds_1' }, { name => 'OverThresholds_2' }, { name => 'OverThresholds_times' }, - ], - closure_custom_calc => \&custom_NumberOverThresholds_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Number Over Thresholds : %s', - threshold_use => 'value', - perfdatas => [ - { label => 'number_over_thresholds', value => 'value', template => '%s', - label_extra_instance => 1 }, - ], - } - }, - '002_AverageDelaySD' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - ], - closure_custom_calc => \&custom_AverageDelaySD_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Delay SD : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'average_delay_sd', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '003_AverageDelayDS' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - ], - closure_custom_calc => \&custom_AverageDelayDS_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Delay DS : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'average_delay_ds', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '004_PacketLossRatio' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'PacketLossDS_1' }, { name => 'PacketLossDS_2' }, { name => 'PacketLossDS_times' }, - { name => 'PacketLossSD_1' }, { name => 'PacketLossSD_2' }, { name => 'PacketLossSD_times' }, - { name => 'PacketMIA_1' }, { name => 'PacketMIA_2' }, { name => 'PacketMIA_times' }, - { name => 'PacketLateArrival_1' }, { name => 'PacketLateArrival_2' }, { name => 'PacketLateArrival_times' }, - { name => 'PacketOutOfSequence_1' }, { name => 'PacketOutOfSequence_2' }, { name => 'PacketOutOfSequence_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_PacketLossRatio_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Packet Loss Ratio : %.2f %%', - threshold_use => 'value', - perfdatas => [ - { label => 'packet_loss_ratio', value => 'value', template => '%.2f', unit => '%', - label_extra_instance => 1, min => 0, max => 100 }, - ], - } - }, - '005_PercentagePacketsPositiveJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_PercentagePacketsPositiveJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Percentage of Packets that had Positive Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'prct_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1, }, - ], - } - }, - '006_AverageJitterPerPacketPositiveJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_AverageJitterPerPacketPositiveJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Jitter per Packet that had Positive Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'average_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1 }, - ], - } - }, - '007_PercentagePacketsNegativeJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_PercentagePacketsNegativeJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Percentage of Packets that had Negative Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'prct_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1, }, - ], - } - }, - '008_AverageJitterPerPacketNegativeJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - ], - closure_custom_calc => \&custom_AverageJitterPerPacketNegativeJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Jitter per Packet that had Negative Jitter : %.2f', - threshold_use => 'value', - perfdatas => [ - { label => 'average_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', - label_extra_instance => 1 }, - ], - } - }, - '009_AverageJitter' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, - { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, - { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, - { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, - { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, - { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, - { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, - { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, - ], - closure_custom_calc => \&custom_AverageJitter_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Average Jitter : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'average_jitter', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '010_RTTStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'RTTSum2High_1' }, { name => 'RTTSum2High_2' }, { name => 'RTTSum2High_times' }, - { name => 'RTTSum2Low_1' }, { name => 'RTTSum2Low_2' }, { name => 'RTTSum2Low_times' }, - { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, - { name => 'RTTSum_1' }, { name => 'RTTSum_2' }, { name => 'RTTSum_times' }, - ], - closure_custom_calc => \&custom_RTTStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'Round-Trip Time Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'rtt_standard_deviation', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '011_DelaySource2DestinationStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSum2SDHigh_1' }, { name => 'OWSum2SDHigh_2' }, { name => 'OWSum2SDHigh_times' }, - { name => 'OWSum2SDLow_1' }, { name => 'OWSum2SDLow_2' }, { name => 'OWSum2SDLow_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, - ], - closure_custom_calc => \&custom_DelaySource2DestinationStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Delay Source to Destination Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'delay_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - - '012_DelayDestination2SourceStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'OWSum2DSHigh_1' }, { name => 'OWSum2DSHigh_2' }, { name => 'OWSum2DSHigh_times' }, - { name => 'OWSum2DSLow_1' }, { name => 'OWSum2DSLow_2' }, { name => 'OWSum2DSLow_times' }, - { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, - { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, - ], - closure_custom_calc => \&custom_DelayDestination2SourceStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Delay Destination to Source Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'delay_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '013_JitterSource2DestinationStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'Sum2PositivesSDHigh_1' }, { name => 'Sum2PositivesSDHigh_2' }, { name => 'Sum2PositivesSDHigh_times' }, - { name => 'Sum2PositivesSDLow_1' }, { name => 'Sum2PositivesSDLow_2' }, { name => 'Sum2PositivesSDLow_times' }, - { name => 'Sum2NegativesSDHigh_1' }, { name => 'Sum2NegativesSDHigh_2' }, { name => 'Sum2NegativesSDHigh_times' }, - { name => 'Sum2NegativesSDLow_1' }, { name => 'Sum2NegativesSDLow_2' }, { name => 'Sum2NegativesSDLow_times' }, - { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, - { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, - { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, - { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, - ], - closure_custom_calc => \&custom_JitterSource2DestinationStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Jitter Source to Destination Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'jitter_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, - '014_JitterDestination2SourceStandardDeviation' => { class => 'centreon::plugins::values', obj => undef, - set => { - key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, - { name => 'Sum2PositivesDSHigh_1' }, { name => 'Sum2PositivesDSHigh_2' }, { name => 'Sum2PositivesDSHigh_times' }, - { name => 'Sum2PositivesDSLow_1' }, { name => 'Sum2PositivesDSLow_2' }, { name => 'Sum2PositivesDSLow_times' }, - { name => 'Sum2NegativesDSHigh_1' }, { name => 'Sum2NegativesDSHigh_2' }, { name => 'Sum2NegativesDSHigh_times' }, - { name => 'Sum2NegativesDSLow_1' }, { name => 'Sum2NegativesDSLow_2' }, { name => 'Sum2NegativesDSLow_times' }, - { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, - { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, - { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, - { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, - ], - closure_custom_calc => \&custom_JitterDestination2SourceStandardDeviation_calc, - closure_custom_output => \&custom_generic_output, - output_template => 'One-Way Jitter Destination to Source Standard Deviation : %.2f ms', - threshold_use => 'value', - perfdatas => [ - { label => 'jitter_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', - label_extra_instance => 1 }, - ], - } - }, -}; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'tag', type => 1, cb_prefix_output => 'prefix_tag_output', message_multiple => 'All RTT controls are ok', + skipped_code => { -2 => 1 } } + ]; + $self->{maps_counters}->{tag} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, + { name => 'rttMonCtrlAdminTag' }, + { name => 'rttMonCtrlAdminRttType' }, + { name => 'rttMonCtrlAdminThreshold' }, + { name => 'rttMonEchoAdminPrecision' }, + { name => 'rttMonLatestRttOperCompletionTime' }, + { name => 'rttMonLatestRttOperSense' }, + { name => 'rttMonLatestRttOperApplSpecificSense' }, + ], + 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_status_threshold'), + } + }, + { label => 'CompletionTime', set => { + key_values => [ { name => 'rttMonLatestRttOperCompletionTime' }, { name => 'rttMonEchoAdminPrecision' }, { name => 'rttMonCtrlAdminTag' } + ], + output_template => 'Completion Time : %s', + perfdatas => [ + { label => 'completion_time', value => 'rttMonLatestRttOperCompletionTime_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'NumberOverThresholds', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OverThresholds_1' }, { name => 'OverThresholds_2' }, { name => 'OverThresholds_times' }, + ], + closure_custom_calc => $self->can('custom_NumberOverThresholds_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Number Over Thresholds : %s', + threshold_use => 'value', + perfdatas => [ + { label => 'number_over_thresholds', value => 'value', template => '%s', + label_extra_instance => 1 }, + ], + } + }, + { label => 'AverageDelaySD', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + ], + closure_custom_calc => $self->can('custom_AverageDelaySD_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Delay SD : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'average_delay_sd', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'AverageDelayDS', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + ], + closure_custom_calc => $self->can('custom_AverageDelayDS_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Delay DS : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'average_delay_ds', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'PacketLossRatio', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'PacketLossDS_1' }, { name => 'PacketLossDS_2' }, { name => 'PacketLossDS_times' }, + { name => 'PacketLossSD_1' }, { name => 'PacketLossSD_2' }, { name => 'PacketLossSD_times' }, + { name => 'PacketMIA_1' }, { name => 'PacketMIA_2' }, { name => 'PacketMIA_times' }, + { name => 'PacketLateArrival_1' }, { name => 'PacketLateArrival_2' }, { name => 'PacketLateArrival_times' }, + { name => 'PacketOutOfSequence_1' }, { name => 'PacketOutOfSequence_2' }, { name => 'PacketOutOfSequence_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_PacketLossRatio_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Packet Loss Ratio : %.2f %%', + threshold_use => 'value', + perfdatas => [ + { label => 'packet_loss_ratio', value => 'value', template => '%.2f', unit => '%', + label_extra_instance => 1, min => 0, max => 100 }, + ], + } + }, + { label => 'PercentagePacketsPositiveJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_PercentagePacketsPositiveJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Percentage of Packets that had Positive Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'prct_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1, }, + ], + } + }, + { label => 'AverageJitterPerPacketPositiveJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_AverageJitterPerPacketPositiveJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Jitter per Packet that had Positive Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'average_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1 }, + ], + } + }, + { label => 'PercentagePacketsNegativeJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_PercentagePacketsNegativeJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Percentage of Packets that had Negative Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'prct_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1, }, + ], + } + }, + { label => 'AverageJitterPerPacketNegativeJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + ], + closure_custom_calc => $self->can('custom_AverageJitterPerPacketNegativeJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Jitter per Packet that had Negative Jitter : %.2f', + threshold_use => 'value', + perfdatas => [ + { label => 'average_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f', + label_extra_instance => 1 }, + ], + } + }, + { label => 'AverageJitter', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, + { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, + { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, + { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, + { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, + { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, + { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, + { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, + ], + closure_custom_calc => $self->can('custom_AverageJitter_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Average Jitter : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'average_jitter', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'RTTStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'RTTSum2High_1' }, { name => 'RTTSum2High_2' }, { name => 'RTTSum2High_times' }, + { name => 'RTTSum2Low_1' }, { name => 'RTTSum2Low_2' }, { name => 'RTTSum2Low_times' }, + { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' }, + { name => 'RTTSum_1' }, { name => 'RTTSum_2' }, { name => 'RTTSum_times' }, + ], + closure_custom_calc => $self->can('custom_RTTStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'Round-Trip Time Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'rtt_standard_deviation', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'DelaySource2DestinationStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSum2SDHigh_1' }, { name => 'OWSum2SDHigh_2' }, { name => 'OWSum2SDHigh_times' }, + { name => 'OWSum2SDLow_1' }, { name => 'OWSum2SDLow_2' }, { name => 'OWSum2SDLow_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' }, + ], + closure_custom_calc => $self->can('custom_DelaySource2DestinationStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Delay Source to Destination Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'delay_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'DelayDestination2SourceStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'OWSum2DSHigh_1' }, { name => 'OWSum2DSHigh_2' }, { name => 'OWSum2DSHigh_times' }, + { name => 'OWSum2DSLow_1' }, { name => 'OWSum2DSLow_2' }, { name => 'OWSum2DSLow_times' }, + { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' }, + { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' }, + ], + closure_custom_calc => $self->can('custom_DelayDestination2SourceStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Delay Destination to Source Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'delay_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'JitterSource2DestinationStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'Sum2PositivesSDHigh_1' }, { name => 'Sum2PositivesSDHigh_2' }, { name => 'Sum2PositivesSDHigh_times' }, + { name => 'Sum2PositivesSDLow_1' }, { name => 'Sum2PositivesSDLow_2' }, { name => 'Sum2PositivesSDLow_times' }, + { name => 'Sum2NegativesSDHigh_1' }, { name => 'Sum2NegativesSDHigh_2' }, { name => 'Sum2NegativesSDHigh_times' }, + { name => 'Sum2NegativesSDLow_1' }, { name => 'Sum2NegativesSDLow_2' }, { name => 'Sum2NegativesSDLow_times' }, + { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' }, + { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' }, + { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' }, + { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' }, + ], + closure_custom_calc => $self->can('custom_JitterSource2DestinationStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Jitter Source to Destination Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'jitter_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + { label => 'JitterDestination2SourceStandardDeviation', set => { + key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' }, + { name => 'Sum2PositivesDSHigh_1' }, { name => 'Sum2PositivesDSHigh_2' }, { name => 'Sum2PositivesDSHigh_times' }, + { name => 'Sum2PositivesDSLow_1' }, { name => 'Sum2PositivesDSLow_2' }, { name => 'Sum2PositivesDSLow_times' }, + { name => 'Sum2NegativesDSHigh_1' }, { name => 'Sum2NegativesDSHigh_2' }, { name => 'Sum2NegativesDSHigh_times' }, + { name => 'Sum2NegativesDSLow_1' }, { name => 'Sum2NegativesDSLow_2' }, { name => 'Sum2NegativesDSLow_times' }, + { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' }, + { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' }, + { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' }, + { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' }, + ], + closure_custom_calc => $self->can('custom_JitterDestination2SourceStandardDeviation_calc'), + closure_custom_output => $self->can('custom_generic_output'), + output_template => 'One-Way Jitter Destination to Source Standard Deviation : %.2f ms', + threshold_use => 'value', + perfdatas => [ + { label => 'jitter_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms', + label_extra_instance => 1 }, + ], + } + }, + ]; +} + +sub prefix_tag_output { + my ($self, %options) = @_; + + return "RTT '" . $options{instance_value}->{rttMonCtrlAdminTag} . "' "; +} my $ipsla; my $thresholds = { @@ -348,18 +354,6 @@ sub check_buffer_creation { ###### STATUS ###### -sub custom_status_perfdata { - my ($self, %options) = @_; - - my $extra_label = ''; - if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { - $extra_label .= '_' . $self->{result_values}->{rttMonCtrlAdminTag}; - } - $self->{output}->perfdata_add(label => 'completion_time' . $extra_label, unit => $self->{result_values}->{rttMonEchoAdminPrecision}, - value => $self->{result_values}->{rttMonLatestRttOperCompletionTime}, - min => 0); -} - sub custom_status_threshold { my ($self, %options) = @_; my $status = 'ok'; @@ -803,31 +797,16 @@ my $mapping3 = { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "filter-tag:s" => { name => 'filter_tag', default => '.*' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + "filter-tag:s" => { name => 'filter_tag', default => '.*' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, }); - $self->{statefile_value} = centreon::plugins::statefile->new(%options); - foreach (keys %{$maps_counters}) { - my ($id, $name) = split /_/; - if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { - $options{options}->add_options(arguments => { - 'warning-' . $name . ':s' => { name => 'warning-' . $name }, - 'critical-' . $name . ':s' => { name => 'critical-' . $name }, - }); - } - my $class = $maps_counters->{$_}->{class}; - $maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value}, - output => $self->{output}, perfdata => $self->{perfdata}, - label => $name); - $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); - } return $self; } @@ -835,10 +814,6 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - foreach (keys %{$maps_counters}) { - next if (defined($maps_counters->{$_}->{threshold}) && $maps_counters->{$_}->{threshold} == 0); - $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); - } $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*?),(.*)$/) { @@ -854,94 +829,26 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } - $self->{statefile_value}->check_options(%options); # to be used on custom function $ipsla = $self; } -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - $self->{snmp_port} = $self->{snmp}->get_port(); - - $self->manage_selection(); - - $self->{new_datas} = {}; - $self->{statefile_value}->read(statefile => "cache_cisco_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . - (defined($self->{option_results}->{filter_tag}) ? md5_hex($self->{option_results}->{filter_tag}) : md5_hex('all'))); - $self->{new_datas}->{last_timestamp} = time(); - - my $multiple = 1; - if (scalar(keys %{$self->{datas}}) == 1) { - $multiple = 0; - } - - if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All RTT controls are ok'); - } - - foreach my $id (sort keys %{$self->{datas}}) { - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters}) { - $maps_counters->{$_}->{obj}->set(instance => $id); - - my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{datas}->{$id}, - new_datas => $self->{new_datas}); - next if ($value_check == -2); - if ($value_check != 0) { - $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); - $long_msg_append = ', '; - next; - } - my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); - push @exits, $exit2; - - my $output = $maps_counters->{$_}->{obj}->output(); - $long_msg .= $long_msg_append . $output; - $long_msg_append = ', '; - - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= $short_msg_append . $output; - $short_msg_append = ', '; - } - - $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); - } - - $self->{output}->output_add(long_msg => "RTT '" . $self->{datas}->{$id}->{rttMonCtrlAdminTag} . "' $long_msg"); - my $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, - short_msg => "RTT '" . $self->{datas}->{$id}->{rttMonCtrlAdminTag} . "' $short_msg" - ); - } - - if ($multiple == 0) { - $self->{output}->output_add(short_msg => "RTT '" . $self->{datas}->{$id}->{rttMonCtrlAdminTag} . "' $long_msg"); - } - } - - $self->{statefile_value}->write(data => $self->{new_datas}); - $self->{output}->display(); - $self->{output}->exit(); -} - sub manage_selection { my ($self, %options) = @_; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_rttMonCtrlAdminEntry }, + $self->{cache_name} = "cache_cisco_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_tag}) ? md5_hex($self->{option_results}->{filter_tag}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_rttMonCtrlAdminEntry }, { oid => $oid_rttMonEchoAdminPrecision }, { oid => $oid_rttMonLatestRttOperEntry }, { oid => $oid_rttMonJitterStatsEntry }, ], - nothing_quit => 1); + nothing_quit => 1); - $self->{datas} = {}; - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) { + $self->{tag} = {}; + foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) { next if ($oid !~ /^$mapping->{rttMonCtrlAdminTag}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance); @@ -950,7 +857,7 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping: please set a tag name"); next; } - if (defined($self->{datas}->{$tag_name})) { + if (defined($self->{tag}->{$tag_name})) { $self->{output}->output_add(long_msg => "skipping '" . $tag_name . "': duplicate (please change the tag name)."); next; } @@ -959,29 +866,29 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $tag_name . "': no matching filter."); next; } - $self->{datas}->{$tag_name} = { %{$result} }; + $self->{tag}->{$tag_name} = { %{$result} }; $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_rttMonEchoAdminPrecision}, instance => $instance); - $self->{datas}->{$tag_name} = { %{$result}, %{$self->{datas}->{$tag_name}} }; + $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} }; $result = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_rttMonLatestRttOperEntry}, instance => $instance); - $self->{datas}->{$tag_name} = { %{$result}, %{$self->{datas}->{$tag_name}} }; + $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} }; # there are two entries with rotation: 1 -> last hour, 2 -> current hour. foreach my $key (keys %{$oids_jitter_stats}) { - $self->{datas}->{$tag_name}->{$key . '_1'} = 0; - $self->{datas}->{$tag_name}->{$key . '_2'} = 0; + $self->{tag}->{$tag_name}->{$key . '_1'} = 0; + $self->{tag}->{$tag_name}->{$key . '_2'} = 0; my $i = 1; my $instances = []; foreach my $oid2 ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonJitterStatsEntry}})) { next if ($oid2 !~ /^$oids_jitter_stats->{$key}\.$instance.(\d+)/); push @{$instances}, $1; - $self->{datas}->{$tag_name}->{$key . '_' . $i} = $self->{results}->{$oid_rttMonJitterStatsEntry}->{$oid2}; + $self->{tag}->{$tag_name}->{$key . '_' . $i} = $self->{results}->{$oid_rttMonJitterStatsEntry}->{$oid2}; $i++; } - $self->{datas}->{$tag_name}->{$key . '_times'} = join('_', @{$instances}); + $self->{tag}->{$tag_name}->{$key . '_times'} = join('_', @{$instances}); } } - if (scalar(keys %{$self->{datas}}) <= 0) { + if (scalar(keys %{$self->{tag}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->option_exit(); } @@ -1032,7 +939,7 @@ Example: --threshold-overload='opersense,CRITICAL,^(?!(ok)$)' =item B<--warning-*> Threshold warning. -Can be: 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', +Can be: 'CompletionTime', 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', 'PercentagePacketsPositiveJitter', 'AverageJitterPerPacketPositiveJitter', 'PercentagePacketsNegativeJitter', 'AverageJitterPerPacketNegativeJitter', 'AverageJitter', 'RTTStandardDeviation', 'DelaySource2DestinationStandardDeviation', 'DelayDestination2SourceStandardDeviation', 'JitterSource2DestinationStandardDeviation', 'JitterDestination2SourceStandardDeviation'. @@ -1040,7 +947,7 @@ Can be: 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossR =item B<--critical-*> Threshold critical. -Can be: 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', +Can be: 'CompletionTime', 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio', 'PercentagePacketsPositiveJitter', 'AverageJitterPerPacketPositiveJitter', 'PercentagePacketsNegativeJitter', 'AverageJitterPerPacketNegativeJitter', 'AverageJitter', 'RTTStandardDeviation', 'DelaySource2DestinationStandardDeviation', 'DelayDestination2SourceStandardDeviation', 'JitterSource2DestinationStandardDeviation', 'JitterDestination2SourceStandardDeviation'. diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index 9ccd0394f..dff402983 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -146,6 +146,7 @@ sub run_global { my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{config}->{name}}); + next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check})); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); $long_msg_append = $message_separator; @@ -215,7 +216,7 @@ sub run_instances { my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{config}->{name}}->{$id}); - + next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check})); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); $long_msg_append = $message_separator; From f36ff60116365393206b977a1ed7f36755788d01 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 29 Jan 2016 14:05:08 +0100 Subject: [PATCH 14/22] + add video qoe mode for lync --- apps/lync/2013/mssql/mode/videoqoe.pm | 152 ++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 apps/lync/2013/mssql/mode/videoqoe.pm diff --git a/apps/lync/2013/mssql/mode/videoqoe.pm b/apps/lync/2013/mssql/mode/videoqoe.pm new file mode 100644 index 000000000..96cc688ac --- /dev/null +++ b/apps/lync/2013/mssql/mode/videoqoe.pm @@ -0,0 +1,152 @@ +package apps::lync::2013::mssql::mode::videoqoe; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'video_post_fecplr', type => 0 }, + { name => 'video_local_frame_loss_prct_avg', type => 0 }, + { name => 'recv_frame_rate_avg', type => 0 }, + { name => 'video_packet_loss_rate', type => 0 }, + { name => 'inbound_video_frame_rate_avg', type => 0 }, + { name => 'outbound_video_frame_rate_avg', type => 0 }, + ]; + + $self->{maps_counters}->{video_post_fecplr} = [ + { label => 'post-fecplr', set => { + key_values => [ { name => 'value' } ], + output_template => 'VideoPostFECPLR : %d', + perfdatas => [ + { label => 'video_post_fecplr', value => 'value_absolute', template => '%d', + unit => '', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{video_local_frame_loss_prct_avg} = [ + { label => 'local-frame-loss', set => { + key_values => [ { name => 'value' } ], + output_template => 'VideoLocalFrameLossPercentageAvg : %d', + perfdatas => [ + { label => 'video_frame_loss_prct_avg', value => 'value_absolute', template => '%d', + unit => '', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{recv_frame_rate_avg} = [ + { label => 'recv-frame', set => { + key_values => [ { name => 'value' } ], + output_template => 'RecvFrameRateAverage : %d', + perfdatas => [ + { label => 'rcv_frame_rate_avg', value => 'value_absolute', template => '%d', + unit => '', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{video_packet_loss_rate} = [ + { label => 'packet-loss', set => { + key_values => [ { name => 'value' } ], + output_template => 'video_packet_loss_rate : %.2f%%', + perfdatas => [ + { label => 'video_pckt_loss_rate', value => 'value_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{inbound_video_frame_rate_avg} = [ + { label => 'inbound-frame', set => { + key_values => [ { name => 'value' } ], + output_template => 'inbound_video_frame_rate_avg : %.2f%%', + perfdatas => [ + { label => 'inbound_video_frame_rate_avg', value => 'value_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{outbound_video_frame_rate_avg} = [ + { label => 'outbound-frame', set => { + key_values => [ { name => 'value' } ], + output_template => 'outbound_video_frame_rate_avg : %.2f%%', + perfdatas => [ + { label => 'outbound_video_frame_rate_avg', value => 'value_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; +} + +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 => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{select avg(VideoPostFECPLR) + ,avg(VideoLocalFrameLossPercentageAvg) + ,avg(RecvFrameRateAverage) + ,avg(VideoPacketLossRate) + ,avg(InboundVideoFrameRateAvg) + ,avg(OutboundVideoFrameRateAvg) + from [QoEMetrics].[dbo].VideoStream + } + ); + + my ($video_post_fecplr, $video_local_frame_loss_prct_avg, $recv_frame_rate_avg, + $video_packet_loss_rate, $inbound_video_frame_rate_avg, $outbound_video_frame_rate_avg) = $self->{sql}->fetchrow_array(); + + $self->{video_post_fecplr} = { value => $video_post_fecplr }; + $self->{video_local_frame_loss_prct_avg} = { value => $video_local_frame_loss_prct_avg }; + $self->{recv_frame_rate_avg} = { value => $recv_frame_rate_avg }; + $self->{video_packet_loss_rate} = { value => $video_packet_loss_rate }; + $self->{inbound_video_frame_rate_avg} = { value => $inbound_video_frame_rate_avg }; + $self->{outbound_video_frame_rate_avg} = { value => $outbound_video_frame_rate_avg }; + +} + +1; + +__END__ + +=head1 MODE + +Check video metrics QoE from SQL Server Lync Database [QoEMetrics].[dbo].VideoStream + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for QoE metrics. Can be : 'recv-frame', 'local-frame-loss', 'post-fecplr', ''packet-loss', 'inboud-frame', 'outbound-frame' + +=item B<--critical-*> + +Set critical threshold for QoE. Can be : 'recv-frame', 'local-frame-loss', 'post-fecplr', ''packet-loss', 'inboud-frame', 'outbound-frame' + +=back + +=cut From 6478da5aba8eb4462e5041a2dcfd0722387adfcf Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 29 Jan 2016 14:06:54 +0100 Subject: [PATCH 15/22] + add sessionstypes.pm mode for lync check number of sessions (video,audio,instant messaging...) --- apps/lync/2013/mssql/mode/sessionstypes.pm | 181 +++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 apps/lync/2013/mssql/mode/sessionstypes.pm diff --git a/apps/lync/2013/mssql/mode/sessionstypes.pm b/apps/lync/2013/mssql/mode/sessionstypes.pm new file mode 100644 index 000000000..8ad9703d2 --- /dev/null +++ b/apps/lync/2013/mssql/mode/sessionstypes.pm @@ -0,0 +1,181 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::lync::2013::mssql::mode::sessionstypes; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'instant_messaging', type => 0 }, + { name => 'file_transfer', type => 0 }, + { name => 'remote_assistance', type => 0 }, + { name => 'app_sharing', type => 0 }, + { name => 'audio', type => 0 }, + { name => 'video', type => 0 }, + { name => 'app_invite', type => 0 }, + ]; + + $self->{maps_counters}->{instant_messaging} = [ + { label => 'instant-messaging', set => { + key_values => [ { name => 'value' } ], + output_template => 'Instant Messaging : %d', + perfdatas => [ + { label => 'instant_messaging', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{file_transfer} = [ + { label => 'file-transfer', set => { + key_values => [ { name => 'value' } ], + output_template => 'File transfer : %d', + perfdatas => [ + { label => 'file_transfer', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{remote_assistance} = [ + { label => 'remote-assistance', set => { + key_values => [ { name => 'value' } ], + output_template => 'Remote assistance : %d', + perfdatas => [ + { label => 'remote_assistance', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{app_sharing} = [ + { label => 'app-sharing', set => { + key_values => [ { name => 'value' } ], + output_template => 'App Sharing : %d', + perfdatas => [ + { label => 'app_sharing', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{audio} = [ + { label => 'audio', set => { + key_values => [ { name => 'value' } ], + output_template => 'Audio : %d', + perfdatas => [ + { label => 'audio', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{video} = [ + { label => 'video', set => { + key_values => [ { name => 'value' } ], + output_template => 'Video : %d', + perfdatas => [ + { label => 'video', value => 'value_absolute', template => '%d', + unit => 'sessions', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + +} + +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 => + { + 'lookback:s' => { name => 'lookback', default => '5' }, + }); + return $self; +} + +my %mapping_types = ( + 1 => 'instant_messaging', + 2 => 'file_transfer', + 4 => 'remote_assistance', + 8 => 'app_sharing', + 16 => 'audio', + 32 => 'video', + 64 => 'app_invite', +); + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + foreach my $bit (keys %mapping_types) { + my $query = "SELECT count(*) + FROM [LcsCDR].[dbo].[SessionDetails] s + left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId + WHERE MediaTypes=".$bit." + AND s.SessionIdTime>=dateadd(minute,-".$self->{option_results}->{lookback}.",getdate())"; + + $self->{sql}->query(query => $query); + my $value = $self->{sql}->fetchrow_array(); + $self->{$mapping_types{$bit}} = { value => $value }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check number of sessions ordered by type during last X minutes + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--lookback> + +Minutes to lookback (From you to UTC) + +=item B<--warning-*> + +Set warning threshold Can be : 'instant-messaging', 'app-sharing', 'audio', 'video', 'app-invite', 'remote-assistance' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'instant-messaging', 'app-sharing', 'audio', 'video', 'app-invite', 'remote-assistance' + +=back + +=cut From 7a35c285c456ef2da04099f513aa3719a85d6b13 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 29 Jan 2016 14:09:18 +0100 Subject: [PATCH 16/22] + add audioqoe.pm mode --- apps/lync/2013/mssql/mode/audioqoe.pm | 172 ++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 apps/lync/2013/mssql/mode/audioqoe.pm diff --git a/apps/lync/2013/mssql/mode/audioqoe.pm b/apps/lync/2013/mssql/mode/audioqoe.pm new file mode 100644 index 000000000..2e8f9895b --- /dev/null +++ b/apps/lync/2013/mssql/mode/audioqoe.pm @@ -0,0 +1,172 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::lync::2013::mssql::mode::audioqoe; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'jittermin', type => 0 }, + { name => 'jittermax', type => 0 }, + { name => 'jitteravg', type => 0 }, + { name => 'pcktlossmin', type => 0 }, + { name => 'pcktlossmax', type => 0 }, + { name => 'pcktlossavg', type => 0 }, + ]; + + $self->{maps_counters}->{jittermin} = [ + { label => 'jitter-min', set => { + key_values => [ { name => 'min' } ], + output_template => 'Jitter(Min) : %d ms', + perfdatas => [ + { label => 'jitter_min', value => 'min_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{jittermax} = [ + { label => 'jitter-max', set => { + key_values => [ { name => 'max' } ], + output_template => 'Jitter(Max) : %d ms', + perfdatas => [ + { label => 'jitter_max', value => 'max_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{jitteravg} = [ + { label => 'jitter-avg', set => { + key_values => [ { name => 'avg' } ], + output_template => 'Jitter(Avg) : %d ms', + perfdatas => [ + { label => 'jitter_avg', value => 'avg_absolute', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{pcktlossmin} = [ + { label => 'loss-min', set => { + key_values => [ { name => 'min' } ], + output_template => 'Packet-loss(Min) : %.2f%%', + perfdatas => [ + { label => 'pckt_loss_min', value => 'min_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{pcktlossmax} = [ + { label => 'loss-max', set => { + key_values => [ { name => 'max' } ], + output_template => 'Packet-loss(Max) : %.2f%%', + perfdatas => [ + { label => 'pckt_loss_max', value => 'max_absolute', template => '%.2f', + unit => '%', min => 0, max => 100 }, + ], + } + }, + ]; + $self->{maps_counters}->{pcktlossavg} = [ + { label => 'loss-avg', set => { + key_values => [ { name => 'avg' } ], + output_template => 'Packet-loss(Avg) : %.2f%%', + perfdatas => [ + { label => 'pckt_loss_avg', value => 'avg_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 0 }, + ], + } + }, + ]; + +} + +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 => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{select min(cast(JitterInterArrival as bigint)) as JitterMin, + max(cast(JitterInterArrival as bigint)) as JitterMax, + avg(cast(JitterInterArrival as bigint)) as JitterAvg, + min(PacketLossRate) as PacketLossMin, + max(PacketLossRate) as PacketLossMax, + avg(PacketLossRate) as PacketLossRateAvg + from [QoEMetrics].[dbo].AudioStream + } + ); + + my ($jittermin, $jittermax, $jitteravg, $pcktlossmin, $pcktlossmax, $pcktlossavg) = $self->{sql}->fetchrow_array(); + + $self->{jittermin} = { min => $jittermin }; + $self->{jittermax} = { max => $jittermax }; + $self->{jitteravg} = { avg => $jitteravg }; + $self->{pcktlossmin} = { min => $pcktlossmin }; + $self->{pcktlossmax} = { max => $pcktlossmax }; + $self->{pcktlossavg} = { avg => $pcktlossavg }; + +} + +1; + +__END__ + +=head1 MODE + +Check audio metrics QoE from SQL Server Lync Database [QoEMetrics].[dbo].AudioStream + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'jitter-min', 'jitter-max', 'jitter-avg', 'loss-min', 'loss-max', 'loss-avg' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'jitter-min', 'jitter-max', 'jitter-avg', 'loss-min', 'loss-max', 'loss-avg' + +=back + +=cut From 8410a3c16bfe83360f973768a9d0070a70cb84fe Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 29 Jan 2016 14:10:37 +0100 Subject: [PATCH 17/22] + add appsharingqoe.pm mode for lync --- apps/lync/2013/mssql/mode/appsharingqoe.pm | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 apps/lync/2013/mssql/mode/appsharingqoe.pm diff --git a/apps/lync/2013/mssql/mode/appsharingqoe.pm b/apps/lync/2013/mssql/mode/appsharingqoe.pm new file mode 100644 index 000000000..87e15beea --- /dev/null +++ b/apps/lync/2013/mssql/mode/appsharingqoe.pm @@ -0,0 +1,134 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::lync::2013::mssql::mode::appsharingqoe; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'spoiled_tile_prct_total_avg', type => 0 }, + { name => 'rdp_tile_processing_latency_avg', type => 0 }, + { name => 'relative_one_way_average', type => 0 }, + ]; + + $self->{maps_counters}->{spoiled_tile_prct_total_avg} = [ + { label => 'spoiled-tile-prct-total-avg', set => { + key_values => [ { name => 'value' } ], + output_template => 'SpoiledTilePercentTotal(Avg) : %.2f ms', + perfdatas => [ + { label => 'spoiled_tile_prct_total_avg', value => 'value_absolute', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + + $self->{maps_counters}->{rdp_tile_processing_latency_avg} = [ + { label => 'rdp-tile-processing-latency-avg', set => { + key_values => [ { name => 'value' } ], + output_template => 'RDPTileProcessingLatencyAverage : %.2f ms', + perfdatas => [ + { label => 'rdp_tile_processing_latency_avg', value => 'value_absolute', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{relative_one_way_average} = [ + { label => 'relative-one-way-average', set => { + key_values => [ { name => 'value' } ], + output_template => 'RelativeOneWayAverage : %.2f ms', + perfdatas => [ + { label => 'relative_one_way_average', value => 'value_absolute', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; +} + +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 => + { + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => q{SELECT avg(SpoiledTilePercentTotal) + ,avg(RDPTileProcessingLatencyAverage) + ,avg(RelativeOneWayAverage) + FROM [QoEMetrics].[dbo].AppSharingStream}); + + my ($spoiled_tile_prct_total_avg, $rdp_tile_processing_latency_avg, $relative_one_way_average) = $self->{sql}->fetchrow_array(); + + $self->{spoiled_tile_prct_total_avg} = { value => $spoiled_tile_prct_total_avg }; + $self->{rdp_tile_processing_latency_avg} = { value => $rdp_tile_processing_latency_avg }; + $self->{relative_one_way_average} = { value => $relative_one_way_average }; + +} + +1; + +__END__ + +=head1 MODE + +Check AppSharing Qoe metrics from SQL Server Lync 2013 Database ([QoEMetrics].[dbo].AppSharingStream) + +MS Recommandations : + +SpoiledTilePercentTotal (Total percentage of the content that did not reach the viewer but was instead discarded and overwritten by fresh content) > 36 +RDPTileProcessingLatencyAverage (Average processing time for remote desktop protocol (RDP) tiles. A higher total equates to a longer delay in the viewing experience) > 400 +RelativeOneWayAverage (Average amount of one-way latency. Relative one-way latency measures the delay between the client and the server) > 1.75 + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--warning-*> + +Set warning threshold for number of user. Can be : 'spoiled-tile-prct-total-avg', 'rdp-tile-processing-latency-avg', 'relative-one-way-average' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'spoiled-tile-prct-total-avg', 'rdp-tile-processing-latency-avg', 'relative-one-way-average' + +=back + +=cut From 039f385c2fa3c35cc7f29f91a5fe0041de70c2d4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 29 Jan 2016 14:44:40 +0100 Subject: [PATCH 18/22] Ref #306 --- centreon/common/cisco/standard/snmp/mode/ipsla.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/ipsla.pm b/centreon/common/cisco/standard/snmp/mode/ipsla.pm index 8bcb53c07..dd2f67ebd 100644 --- a/centreon/common/cisco/standard/snmp/mode/ipsla.pm +++ b/centreon/common/cisco/standard/snmp/mode/ipsla.pm @@ -851,7 +851,7 @@ sub manage_selection { foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) { next if ($oid !~ /^$mapping->{rttMonCtrlAdminTag}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance); my $tag_name = $result->{rttMonCtrlAdminTag}; if (!defined($tag_name) || $tag_name eq '') { $self->{output}->output_add(long_msg => "skipping: please set a tag name"); @@ -867,9 +867,9 @@ sub manage_selection { next; } $self->{tag}->{$tag_name} = { %{$result} }; - $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_rttMonEchoAdminPrecision}, instance => $instance); + $result = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_rttMonEchoAdminPrecision}, instance => $instance); $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} }; - $result = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_rttMonLatestRttOperEntry}, instance => $instance); + $result = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_rttMonLatestRttOperEntry}, instance => $instance); $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} }; # there are two entries with rotation: 1 -> last hour, 2 -> current hour. @@ -878,7 +878,7 @@ sub manage_selection { $self->{tag}->{$tag_name}->{$key . '_2'} = 0; my $i = 1; my $instances = []; - foreach my $oid2 ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonJitterStatsEntry}})) { + foreach my $oid2 ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonJitterStatsEntry}})) { next if ($oid2 !~ /^$oids_jitter_stats->{$key}\.$instance.(\d+)/); push @{$instances}, $1; $self->{tag}->{$tag_name}->{$key . '_' . $i} = $self->{results}->{$oid_rttMonJitterStatsEntry}->{$oid2}; From b68f4b0d00f44d6c2feacbfd7f0b753801020abe Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 29 Jan 2016 15:16:26 +0100 Subject: [PATCH 19/22] + Fix indent --- centreon/plugins/statefile.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/centreon/plugins/statefile.pm b/centreon/plugins/statefile.pm index 8d4b50296..e77be2031 100644 --- a/centreon/plugins/statefile.pm +++ b/centreon/plugins/statefile.pm @@ -82,12 +82,12 @@ sub check_options { } sub error { - my ($self) = shift; + my ($self) = shift; - if (@_) { + if (@_) { $self->{error} = $_[0]; - } - return $self->{error}; + } + return $self->{error}; } sub read { From 5be6fb58f648775d842963b253a3cf4f27d6e813 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 29 Jan 2016 15:48:41 +0100 Subject: [PATCH 20/22] + Fix parent call method --- centreon/common/airespace/snmp/mode/apstatus.pm | 2 +- centreon/common/cisco/standard/snmp/mode/ipsla.pm | 2 +- centreon/plugins/templates/counter.pm | 2 +- docs/en/developer/guide.rst | 2 +- hardware/ups/apc/snmp/mode/batterystatus.pm | 2 +- network/f5/bigip/mode/nodestatus.pm | 2 +- network/f5/bigip/mode/poolstatus.pm | 2 +- network/f5/bigip/mode/virtualserverstatus.pm | 2 +- network/juniper/trapeze/snmp/mode/apstatus.pm | 2 +- storage/emc/DataDomain/mode/replication.pm | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/centreon/common/airespace/snmp/mode/apstatus.pm b/centreon/common/airespace/snmp/mode/apstatus.pm index 109ec3f6f..0034f233a 100644 --- a/centreon/common/airespace/snmp/mode/apstatus.pm +++ b/centreon/common/airespace/snmp/mode/apstatus.pm @@ -140,7 +140,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); diff --git a/centreon/common/cisco/standard/snmp/mode/ipsla.pm b/centreon/common/cisco/standard/snmp/mode/ipsla.pm index dd2f67ebd..ea714dc03 100644 --- a/centreon/common/cisco/standard/snmp/mode/ipsla.pm +++ b/centreon/common/cisco/standard/snmp/mode/ipsla.pm @@ -812,7 +812,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index dff402983..ef7961376 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -116,7 +116,7 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - foreach my $key (keys %{$self->{maps_counters}}) { + foreach my $key (keys %{$self->{maps_counters}}) { foreach (@{$self->{maps_counters}->{$key}}) { $_->{obj}->init(option_results => $self->{option_results}); } diff --git a/docs/en/developer/guide.rst b/docs/en/developer/guide.rst index b52ada7da..edffa0f57 100644 --- a/docs/en/developer/guide.rst +++ b/docs/en/developer/guide.rst @@ -2097,7 +2097,7 @@ The model can also be used to check strings (not only counters). So we want to c sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); # Sometimes, you'll need to have access of the current object in the callback $instance_mode = $self; diff --git a/hardware/ups/apc/snmp/mode/batterystatus.pm b/hardware/ups/apc/snmp/mode/batterystatus.pm index bc506f479..ac8508919 100644 --- a/hardware/ups/apc/snmp/mode/batterystatus.pm +++ b/hardware/ups/apc/snmp/mode/batterystatus.pm @@ -151,7 +151,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); diff --git a/network/f5/bigip/mode/nodestatus.pm b/network/f5/bigip/mode/nodestatus.pm index bacbd7330..7d38da636 100644 --- a/network/f5/bigip/mode/nodestatus.pm +++ b/network/f5/bigip/mode/nodestatus.pm @@ -92,7 +92,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; diff --git a/network/f5/bigip/mode/poolstatus.pm b/network/f5/bigip/mode/poolstatus.pm index 389c57829..0ee40101d 100644 --- a/network/f5/bigip/mode/poolstatus.pm +++ b/network/f5/bigip/mode/poolstatus.pm @@ -92,7 +92,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; diff --git a/network/f5/bigip/mode/virtualserverstatus.pm b/network/f5/bigip/mode/virtualserverstatus.pm index 416f40ed9..b425a2b5f 100644 --- a/network/f5/bigip/mode/virtualserverstatus.pm +++ b/network/f5/bigip/mode/virtualserverstatus.pm @@ -92,7 +92,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; diff --git a/network/juniper/trapeze/snmp/mode/apstatus.pm b/network/juniper/trapeze/snmp/mode/apstatus.pm index b18d1693d..c2684dadd 100644 --- a/network/juniper/trapeze/snmp/mode/apstatus.pm +++ b/network/juniper/trapeze/snmp/mode/apstatus.pm @@ -119,7 +119,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); diff --git a/storage/emc/DataDomain/mode/replication.pm b/storage/emc/DataDomain/mode/replication.pm index ca306b66e..3b69e7eaf 100644 --- a/storage/emc/DataDomain/mode/replication.pm +++ b/storage/emc/DataDomain/mode/replication.pm @@ -118,7 +118,7 @@ sub new { sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); $instance_mode = $self; $self->change_macros(); From 38346e4df782b4f86090c6d7b5bd8a9607b9db58 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 29 Jan 2016 16:00:09 +0100 Subject: [PATCH 21/22] + remove old lync (use new one) --- apps/lync/mode/imsessions.pm | 105 -------------------- apps/lync/mode/lyncusers.pm | 148 ----------------------------- apps/lync/mode/remoteassistance.pm | 105 -------------------- apps/lync/mode/sessionstype.pm | 142 --------------------------- 4 files changed, 500 deletions(-) delete mode 100644 apps/lync/mode/imsessions.pm delete mode 100644 apps/lync/mode/lyncusers.pm delete mode 100644 apps/lync/mode/remoteassistance.pm delete mode 100644 apps/lync/mode/sessionstype.pm diff --git a/apps/lync/mode/imsessions.pm b/apps/lync/mode/imsessions.pm deleted file mode 100644 index fd941d27c..000000000 --- a/apps/lync/mode/imsessions.pm +++ /dev/null @@ -1,105 +0,0 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package apps::lync::mode::imsessions; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -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', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - - $self->{sql}->connect(); - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=1 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - my $im_sessions = $self->{sql}->fetchrow_array(); - - my $exit_code = $self->{perfdata}->threshold_check(value => $im_sessions, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("%i instant messaging sessions running", $im_sessions)); - $self->{output}->perfdata_add(label => 'im_sessions', unit => 'sessions', - value => $im_sessions, - 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(); -} - -1; - -__END__ - -=head1 MODE - -Check Lync number of active instant messaging session during last five minutes - -=over 8 - -=item B<--warning> - -Threshold warning on number of active messaging sessions - -=item B<--critical> - -Threshold critical on number of active messaging sessions - -=back - -=cut diff --git a/apps/lync/mode/lyncusers.pm b/apps/lync/mode/lyncusers.pm deleted file mode 100644 index 55613a909..000000000 --- a/apps/lync/mode/lyncusers.pm +++ /dev/null @@ -1,148 +0,0 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package apps::lync::mode::lyncusers; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -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', }, - "warning-unique:s" => { name => 'warning_unique', }, - "critical-unique:s" => { name => 'critical_unique', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-unique', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-unique', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - - $self->{sql}->connect(); - $self->{sql}->query(query => q{Select - (cast (RE.ClientApp as varchar (100))) as ClientVersion, - R.UserAtHost as UserName, - Reg.Fqdn - From - rtcdyn.dbo.RegistrarEndpoint RE - Inner Join - rtc.dbo.Resource R on R.ResourceId = RE.OwnerId - Inner Join - rtcdyn.dbo.Registrar Reg on Reg.RegistrarId = RE.PrimaryRegistrarClusterId - Order By ClientVersion, UserName } - ); - my $users = $self->{sql}->fetchrow_array(); - - $self->{sql}->query(query => q{Select - count(*) as totalonline, count(distinct UserAtHost) as totalunique - From - rtcdyn.dbo.RegistrarEndpoint RE - Inner Join - rtc.dbo.Resource R on R.ResourceId = RE.OwnerId - Inner Join - rtcdyn.dbo.Registrar Reg on Reg.RegistrarId = RE.PrimaryRegistrarClusterId} - ); - my $unique_users = $self->{sql}->fetchrow_array(); - - my $exit1 = $self->{perfdata}->threshold_check(value => $unique_users, threshold => [ { label => 'critical-unique', 'exit_litteral' => 'critical' }, { label => 'warning-unique', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $users, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - my $exit_code = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("%i lync unique user(s). (%i total users)", $unique_users, $users)); - $self->{output}->perfdata_add(label => 'unique_users', - value => $unique_users, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-unique'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-unique'), - min => 0); - $self->{output}->perfdata_add(label => 'total_users', - value => $users, - 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(); -} - -1; - -__END__ - -=head1 MODE - -Check Lync users and unique users (one user can be connected with several devices) -- use with dyn-mode mssql plugin) - -=over 8 - -=item B<--warning> - -Threshold warning on total users - -=item B<--critical> - -Threshold critical on total users - -=item B<--warning-unique> - -Threshold warning on unique users - -=item B<--critical-unique> - -Threshold critical on unique users - - -=back - -=cut diff --git a/apps/lync/mode/remoteassistance.pm b/apps/lync/mode/remoteassistance.pm deleted file mode 100644 index 8814abca9..000000000 --- a/apps/lync/mode/remoteassistance.pm +++ /dev/null @@ -1,105 +0,0 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package apps::lync::mode::remoteassistance; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -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', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - - $self->{sql}->connect(); - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=4 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - my $remote_assistance_sessions = $self->{sql}->fetchrow_array(); - - my $exit_code = $self->{perfdata}->threshold_check(value => $remote_assistance_sessions, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("%i remote assistance sessions running", $remote_assistance_sessions)); - $self->{output}->perfdata_add(label => 'assistance_sessions', unit => 'sessions', - value => $remote_assistance_sessions, - 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(); -} - -1; - -__END__ - -=head1 MODE - -Check Lync number of active remote assistance sessions during last five minutes -- use with dyn-mode mssql plugin - -=over 8 - -=item B<--warning> - -Threshold warning - -=item B<--critical> - -Threshold critical - -=back - -=cut diff --git a/apps/lync/mode/sessionstype.pm b/apps/lync/mode/sessionstype.pm deleted file mode 100644 index 67f8a5cb0..000000000 --- a/apps/lync/mode/sessionstype.pm +++ /dev/null @@ -1,142 +0,0 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package apps::lync::mode::sessionstype; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -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-audio:s" => { name => 'warning-audio', }, - "critical-audio:s" => { name => 'critical-audio', }, - "warning-video:s" => { name => 'warning_video', }, - "critical-video:s" => { name => 'critical_video', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning-audio', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-audio threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-audio', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-audio threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-video', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-video threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-video', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-video threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - - $self->{sql}->connect(); - - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=16 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - - - my $audio = $self->{sql}->fetchrow_array(); - - $self->{sql}->query(query => q{SELECT count(*) - FROM [LcsCDR].[dbo].[SessionDetails] s - left outer join [LcsCDR].[dbo].[Users] u1 on s.User1Id = u1.UserId left outer join [LcsCDR].[dbo].[Users] u2 on s.User2Id = u2.UserId - WHERE (MediaTypes & 1)=32 - AND s.SessionIdTime>=dateadd(minute,-5,getdate())} - ); - - my $video = $self->{sql}->fetchrow_array(); - - my $exit1 = $self->{perfdata}->threshold_check(value => $audio, threshold => [ { label => 'critical-audio', 'exit_litteral' => 'critical' }, { label => 'warning-audio', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $video, threshold => [ { label => 'critical-video', 'exit_litteral' => 'critical' }, { label => 'warning-video', exit_litteral => 'warning' } ]); - my $exit_code = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); - - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Lync sessions type : %i audio sessions and %i video sessions", $audio, $video)); - $self->{output}->perfdata_add(label => 'video_sessions', - value => $video, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-video'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-video'), - min => 0); - $self->{output}->perfdata_add(label => 'audio_sessions', - value => $audio, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-audio'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-audio'), - min => 0); - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check Lync type of sessions (audio or video) during the last five minutes -- use with dyn-mode and mssql plugin - -=over 8 - -=item B<--warning-audio> - -Threshold warning on number of audio sessions during last five minutes - -=item B<--critical-audio> - -Threshold critical on number of audio sessions during last five minutes - -=item B<--warning-video> - -Threshold critical on number of video sessions during last five minutes - -=item B<--critical-video> - -Threshold critical on number of video sessions during last five minutes - -=back - -=cut From f600935b057cad2e9e32911ee0d1dfdbe81c11fa Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Tue, 2 Feb 2016 15:06:06 +0100 Subject: [PATCH 22/22] Update libgetdata.pm --- apps/apcupsd/local/mode/libgetdata.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/apcupsd/local/mode/libgetdata.pm b/apps/apcupsd/local/mode/libgetdata.pm index 0d9f3d4e1..a3710515f 100644 --- a/apps/apcupsd/local/mode/libgetdata.pm +++ b/apps/apcupsd/local/mode/libgetdata.pm @@ -41,7 +41,7 @@ sub getdata { my ($value); #print $stdout; foreach (split(/\n/, $stdout)) { - if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal|C|F)/i) { + if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C Internal|F Internal|C|F)/i) { $valueok = "1"; $value = $1; #print $value;