diff --git a/src/centreon/plugins/values.pm b/src/centreon/plugins/values.pm index de10b25788..45de33cb9e 100644 --- a/src/centreon/plugins/values.pm +++ b/src/centreon/plugins/values.pm @@ -54,6 +54,7 @@ sub new { $self->{threshold_crit} = undef; $self->{per_second} = 0; + $self->{per_minute} = 0; $self->{manual_keys} = 0; $self->{last_timestamp} = undef; @@ -96,14 +97,15 @@ sub calc { # manage only one value ;) foreach my $value (@{$self->{key_values}}) { - if (defined($value->{diff}) && $value->{diff} == 1) { - $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}; - } elsif (defined($value->{per_second}) && $value->{per_second} == 1) { - $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time}; - } elsif (defined($value->{per_minute}) && $value->{per_minute} == 1) { - $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / ($options{delta_time} / 60); + my $instance_name = $self->{instance} . '_' . $value->{name}; + if ($value->{diff}) { + $self->{result_values}->{$value->{name}} = $options{new_datas}->{$instance_name} - $options{old_datas}->{$instance_name}; + } elsif ($value->{per_second}) { + $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$instance_name} - $options{old_datas}->{$instance_name}) / $options{delta_time}; + } elsif ($value->{per_minute}) { + $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$instance_name} - $options{old_datas}->{$instance_name}) / ($options{delta_time} / 60); } else { - $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}}; + $self->{result_values}->{$value->{name}} = $options{new_datas}->{$instance_name}; } } diff --git a/src/database/mssql/mode/deadlocks.pm b/src/database/mssql/mode/deadlocks.pm index 91f08a3286..a4202c6cd6 100644 --- a/src/database/mssql/mode/deadlocks.pm +++ b/src/database/mssql/mode/deadlocks.pm @@ -1,5 +1,5 @@ # -# Copyright 2024 Centreon (http://www.centreon.com/) +# Copyright 2026-Present Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,34 +23,58 @@ package database::mssql::mode::deadlocks; use strict; use warnings; use base qw(centreon::plugins::templates::counter); +use centreon::plugins::constants qw(:counters); +use centreon::plugins::misc qw(is_excluded); +use Digest::SHA qw(sha256_hex); + +sub prefix_by_instance_output { + my ($self, %options) = @_; + + return "instance '" . $options{instance_value}->{display} . "' "; +} sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'deadlocks', type => 0 }, + { name => 'total', type => COUNTER_TYPE_GLOBAL }, + { name => 'by_instance', type => COUNTER_TYPE_INSTANCE} ]; - $self->{maps_counters}->{deadlocks} = [ - { label => 'deadlocks', nlabel => 'mssql.deadlocks.count', set => { - key_values => [ { name => 'value' } ], - output_template => '%.2f dead locks/s', + $self->{maps_counters}->{total} = [ + { label => 'deadlocks', type => COUNTER_KIND_METRIC, nlabel => 'total#mssql.deadlocks.perminute', set => { + key_values => [ { name => 'total', per_minute => 1 } ], + output_template => '%.2f total dead locks/min', perfdatas => [ { template => '%.2f', min => 0 }, ], } }, ]; -} + $self->{maps_counters}->{by_instance} = [ + { + label => 'deadlocks-by-instance', type => COUNTER_KIND_METRIC, nlabel => 'mssql.deadlocks.perminute', + set => { + key_values => [ { name => 'value', per_minute => 1 }, { name => 'display' } ], + output_template => '%.2f dead locks/min', + perfdatas => [ + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, + ], + } + }, + ]; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => { - "filter-database:s" => { name => 'filter_database' }, + $options{options}->add_options(arguments => { + "filter-database:s" => { redirect => 'include_instance' }, + "include-instance:s" => { name => 'include_instance', default => '' }, + "exclude-instance:s" => { name => 'exclude_instance', default => '' }, }); return $self; @@ -72,13 +96,24 @@ sub manage_selection { }); my $query_result = $options{sql}->fetchall_arrayref(); - $self->{deadlocks}->{value} = 0; + $self->{total}->{total} = 0; foreach my $row (@{$query_result}) { - next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' - && $$row[0] !~ /$self->{option_results}->{filter_database}/); - $self->{deadlocks}->{value} += $$row[1]; + my ($instance, $value) = @$row; + next if $instance eq '_Total'; + next if is_excluded($instance, $self->{option_results}->{include_instance}, $self->{option_results}->{exclude_instance}, output => $self->{output}); + $self->{by_instance}->{$instance} = { + display => $instance, + value => $value + }; + $self->{total}->{total} += $value; } + $self->{output}->option_exit(short_msg => "No locks counter found with given filters") + unless $self->{by_instance} && keys %{$self->{by_instance}}; + + $self->{cache_name} = 'mssql_' . $self->{mode} . '_' . $options{sql}->get_unique_id4save() . '_' . + sha256_hex($self->{option_results}->{include_instance}) . '_' . + sha256_hex($self->{option_results}->{exclude_instance}); } 1; @@ -87,21 +122,37 @@ __END__ =head1 MODE -Check MSSQL dead locks per second +Check MSSQL dead locks per minute =over 8 -=item B<--warning-deadlocks> +=item B<--include-instance> -Warning threshold number of dead locks per second. +Filter to include instances (types of locks) to monitor with a regular expression. -=item B<--critical-deadlocks> +=item B<--exclude-instance> -Critical threshold number of dead locks per second. +Filter to exclude instances (types of locks) to monitor with a regular expression. =item B<--filter-database> -Filter the databases to monitor with a regular expression. +Deprecated option: use C<--include-instance> instead. + +=item B<--warning-deadlocks-by-instance> + +Threshold that applies to each type (instance) of deadlock individually. + +=item B<--critical-deadlocks-by-instance> + +Threshold that applies to each type (instance) of deadlock individually. + +=item B<--warning-deadlocks> + +Threshold that applies to the total amount of deadlocks once the filters have been applied. + +=item B<--critical-deadlocks> + +Threshold that applies to the total amount of deadlocks once the filters have been applied. =back diff --git a/src/database/mssql/mode/lockswaits.pm b/src/database/mssql/mode/lockswaits.pm index 2ad9b2d04b..5f55714a88 100644 --- a/src/database/mssql/mode/lockswaits.pm +++ b/src/database/mssql/mode/lockswaits.pm @@ -1,5 +1,5 @@ # -# Copyright 2025 Centreon (http://www.centreon.com/) +# Copyright 2026-Present Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -23,34 +23,60 @@ package database::mssql::mode::lockswaits; use strict; use warnings; use base qw(centreon::plugins::templates::counter); +use centreon::plugins::constants qw(:counters); +use centreon::plugins::misc qw(is_excluded); +use Digest::SHA qw(sha256_hex); + +sub prefix_by_instance_output { + my ($self, %options) = @_; + + return "instance '" . $options{instance_value}->{display} . "' "; +} sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'lockswaits', type => 0 } + { name => 'total', type => COUNTER_TYPE_GLOBAL }, + { name => 'by_instance', type => COUNTER_TYPE_INSTANCE} ]; - $self->{maps_counters}->{lockswaits} = [ - { label => 'lockswaits', nlabel => 'mssql.lockswaits.count', set => { - key_values => [ { name => 'value' } ], - output_template => '%.2f locks waits/s', - perfdatas => [ - { template => '%.2f', min => 0 } - ] + $self->{maps_counters}->{total} = [ + { + label => 'lockswaits', type => COUNTER_KIND_METRIC, nlabel => 'total#mssql.lockswaits.perminute', + set => { + key_values => [ { name => 'total', per_minute => 1 } ], + output_template => '%.2f total locks waits/min', + perfdatas => [ + { template => '%.2f', min => 0 }, + ], } - } + }, ]; -} + $self->{maps_counters}->{by_instance} = [ + { + label => 'lockswaits-by-instance', type => COUNTER_KIND_METRIC, nlabel => 'mssql.lockswaits.perminute', + set => { + key_values => [ { name => 'value', per_minute => 1 }, { name => 'display' } ], + output_template => '%.2f locks waits/min', + perfdatas => [ + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, + ], + } + }, + ]; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { - 'filter-database:s' => { name => 'filter_database' } + "filter-database:s" => { redirect => 'include_instance' }, + "include-instance:s" => { name => 'include_instance', default => '' }, + "exclude-instance:s" => { name => 'exclude_instance', default => '' }, }); return $self; @@ -72,13 +98,25 @@ sub manage_selection { }); my $query_result = $options{sql}->fetchall_arrayref(); - $self->{lockswaits}->{value} = 0; + $self->{total}->{total} = 0; foreach my $row (@{$query_result}) { - next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' - && $$row[0] !~ /$self->{option_results}->{filter_database}/); - $self->{lockswaits}->{value} += $$row[1]; + my ($instance, $value) = @$row; + next if $instance eq '_Total'; + next if is_excluded($instance, $self->{option_results}->{include_instance}, $self->{option_results}->{exclude_instance}, output => $self->{output}); + $self->{by_instance}->{$instance} = { + display => $instance, + value => $value + }; + $self->{total}->{total} += $value; } + + $self->{output}->option_exit(short_msg => "No locks waits counter found with given filters") + unless $self->{by_instance} && keys %{$self->{by_instance}}; + + $self->{cache_name} = 'mssql_' . $self->{mode} . '_' . $options{sql}->get_unique_id4save() . '_' . + sha256_hex($self->{option_results}->{include_instance}) . '_' . + sha256_hex($self->{option_results}->{exclude_instance}); } 1; @@ -87,21 +125,37 @@ __END__ =head1 MODE -Check MSSQL locks-waits per second +Check MSSQL locks-waits per minute =over 8 +=item B<--include-instance> + +Filter to include instances (types of locks) to monitor with a regular expression. + +=item B<--exclude-instance> + +Filter to exclude instances (types of locks) to monitor with a regular expression. + +=item B<--filter-database> + +Deprecated option: use C<--include-instance> instead. + =item B<--warning-lockswaits> -Warning threshold number of lock-waits per second. +Threshold. =item B<--critical-lockswaits> -Critical threshold number of lock-waits per second. +Threshold. -=item B<--filter-database> +=item B<--warning-lockswaits-by-instance> + +Threshold. + +=item B<--critical-lockswaits-by-instance> -Filter the databases to monitor with a regular expression. +Threshold. =back diff --git a/tests/database/mssql/DBD/Sybase.pm b/tests/database/mssql/DBD/Sybase.pm new file mode 100644 index 0000000000..503983d012 --- /dev/null +++ b/tests/database/mssql/DBD/Sybase.pm @@ -0,0 +1,24 @@ +# Copyright 2026-Present 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 DBD::Sybase; +use strict; +use warnings; +1; + + diff --git a/tests/database/mssql/DBI.pm b/tests/database/mssql/DBI.pm new file mode 100644 index 0000000000..86d1385605 --- /dev/null +++ b/tests/database/mssql/DBI.pm @@ -0,0 +1,67 @@ +# Copyright 2026-Present 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 DBI; +use strict; +use warnings; + +our $errstr = ''; + +sub connect { + my ($class, $dsn, $user, $pass, $opts) = @_; + return bless {}, 'DBI::db'; +} + +package DBI::db; +use strict; +use warnings; + +sub get_info { return '15.00.2000'; } + +sub disconnect { return 1; } + +sub errstr { return ''; } + +sub prepare { + my ($self, $query) = @_; + return bless { query => $query }, 'DBI::st'; +} + +package DBI::st; +use strict; +use warnings; + +sub execute { return 1; } + +sub errstr { return ''; } + +sub fetchall_arrayref { + my ($self) = @_; + my $file = $ENV{MOCK_DBI_DATA_FILE}; + return [] unless defined $file && -f $file; + my $data = do $file; + return defined $data ? $data : []; +} + +sub fetchrow_array { return (); } + +sub fetchrow_hashref { + return { product_version => '15.00.2000' }; +} + +1; diff --git a/tests/database/mssql/dead-locks-mock-data.pl b/tests/database/mssql/dead-locks-mock-data.pl new file mode 100644 index 0000000000..a0cd12f1ba --- /dev/null +++ b/tests/database/mssql/dead-locks-mock-data.pl @@ -0,0 +1,37 @@ +# +# Copyright 2026-Present 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. +# + +[ + [ '_Total', 317 ], + [ 'Xact', 18 ], + [ 'RowGroup', 5 ], + [ 'OIB', 56 ], + [ 'AllocUnit', 19 ], + [ 'HoBT', 39 ], + [ 'Metadata', 38 ], + [ 'Application', 512 ], + [ 'RID', 24 ], + [ 'Extent', 7 ], + [ 'Key', 101 ], + [ 'Page', 41 ], + [ 'Object', 54 ], + [ 'File', 562 ], + [ 'Database', 45 ], +] diff --git a/tests/database/mssql/dead-locks.robot b/tests/database/mssql/dead-locks.robot new file mode 100644 index 0000000000..8d58861a8a --- /dev/null +++ b/tests/database/mssql/dead-locks.robot @@ -0,0 +1,78 @@ +*** Settings *** +Documentation In this robot file, before each test case, we restore the statefile to an initial state and age, and +... we fix the time so that the age of the data is always 1 minute. Every value, calculated as a per_minute +... average is consequently predictible. + +Resource ${CURDIR}${/}..${/}..${/}resources/import.resource + +Suite Setup Ctn Generic Suite Setup +Suite Teardown Ctn Generic Suite Teardown +Test Timeout 120s + + +*** Variables *** +${INJECT_PERL} -MDBD::Sybase -Mfixed_date -I${CURDIR} +${CMD} ${CENTREON_PLUGINS} +... --plugin=database::mssql::plugin +... --mode=dead-locks +... --hostname=${HOSTNAME} +... --port=${APIPORT} +... --username=1 +... --password=1 + + +*** Test Cases *** +Dead-locks ${tc} + [Tags] database mssql + [Setup] Ctn Dead Locks Test Setup + + ${OLD_PERL5OPT}= Get Environment Variable PERL5OPT default= + Set Environment Variable PERL5OPT ${INJECT_PERL} ${OLD_PERL5OPT} + Set Environment Variable MOCK_DBI_DATA_FILE ${CURDIR}${/}dead-locks-mock-data.pl + + ${command}= Catenate + ... ${CMD} + ... ${extra_options} + + Ctn Run Command Without Connector And Check Result As Strings ${command} ${expected_result} + + Examples: + ... tc + ... extra_options + ... expected_result + ... -- + ... 1 + ... ${EMPTY} + ... OK: 124.00 total dead locks/min | 'total#mssql.deadlocks.perminute'=124.00;;;0; 'AllocUnit#mssql.deadlocks.perminute'=8.00;;;0; 'Application#mssql.deadlocks.perminute'=1.00;;;0; 'Database#mssql.deadlocks.perminute'=5.00;;;0; 'Extent#mssql.deadlocks.perminute'=3.00;;;0; 'File#mssql.deadlocks.perminute'=30.00;;;0; 'HoBT#mssql.deadlocks.perminute'=2.00;;;0; 'Key#mssql.deadlocks.perminute'=51.00;;;0; 'Metadata#mssql.deadlocks.perminute'=7.00;;;0; 'OIB#mssql.deadlocks.perminute'=4.00;;;0; 'Object#mssql.deadlocks.perminute'=1.00;;;0; 'Page#mssql.deadlocks.perminute'=1.00;;;0; 'RID#mssql.deadlocks.perminute'=4.00;;;0; 'RowGroup#mssql.deadlocks.perminute'=4.00;;;0; 'Xact#mssql.deadlocks.perminute'=3.00;;;0; + ... 2 + ... --filter-database=Database + ... OK: 45.00 total dead locks/min - 5.00 dead locks/min | 'total#mssql.deadlocks.perminute'=45.00;;;0; 'Database#mssql.deadlocks.perminute'=5.00;;;0; + ... 3 + ... --include-instance=Database + ... OK: 45.00 total dead locks/min - 5.00 dead locks/min | 'total#mssql.deadlocks.perminute'=45.00;;;0; 'Database#mssql.deadlocks.perminute'=5.00;;;0; + ... 4 + ... --exclude-instance=Database + ... OK: 79.00 total dead locks/min | 'total#mssql.deadlocks.perminute'=79.00;;;0; 'AllocUnit#mssql.deadlocks.perminute'=8.00;;;0; 'Application#mssql.deadlocks.perminute'=1.00;;;0; 'Extent#mssql.deadlocks.perminute'=3.00;;;0; 'File#mssql.deadlocks.perminute'=30.00;;;0; 'HoBT#mssql.deadlocks.perminute'=2.00;;;0; 'Key#mssql.deadlocks.perminute'=51.00;;;0; 'Metadata#mssql.deadlocks.perminute'=7.00;;;0; 'OIB#mssql.deadlocks.perminute'=4.00;;;0; 'Object#mssql.deadlocks.perminute'=1.00;;;0; 'Page#mssql.deadlocks.perminute'=1.00;;;0; 'RID#mssql.deadlocks.perminute'=4.00;;;0; 'RowGroup#mssql.deadlocks.perminute'=4.00;;;0; 'Xact#mssql.deadlocks.perminute'=3.00;;;0; + ... 5 + ... --include-instance=Database --warning-deadlocks-by-instance=1 + ... WARNING: 5.00 dead locks/min | 'total#mssql.deadlocks.perminute'=45.00;;;0; 'Database#mssql.deadlocks.perminute'=5.00;0:1;;0; + ... 6 + ... --include-instance=Database --critical-deadlocks-by-instance=1 + ... CRITICAL: 5.00 dead locks/min | 'total#mssql.deadlocks.perminute'=45.00;;;0; 'Database#mssql.deadlocks.perminute'=5.00;;0:1;0; + ... 7 + ... --include-instance=unexisting + ... UNKNOWN: No locks counter found with given filters + ... 8 + ... --include-instance=Database --warning-deadlocks=40 + ... WARNING: 45.00 total dead locks/min | 'total#mssql.deadlocks.perminute'=45.00;0:40;;0; 'Database#mssql.deadlocks.perminute'=5.00;;;0; + ... 9 + ... --include-instance=Database --critical-deadlocks=40 + ... CRITICAL: 45.00 total dead locks/min | 'total#mssql.deadlocks.perminute'=45.00;;0:40;0; 'Database#mssql.deadlocks.perminute'=5.00;;;0; + + +*** Keywords *** +Ctn Dead Locks Test Setup + @{statefiles}= List Files In Directory ${CURDIR}${/}statefiles mssql_dead-locks_* + FOR ${statefile} IN @{statefiles} + Copy File ${CURDIR}${/}statefiles${/}${statefile} ${/}var${/}lib${/}centreon${/}centplugins${/} + END diff --git a/tests/database/mssql/fixed_date.pm b/tests/database/mssql/fixed_date.pm new file mode 100644 index 0000000000..bc7965f542 --- /dev/null +++ b/tests/database/mssql/fixed_date.pm @@ -0,0 +1,10 @@ +package fixed_date; + +# Copyright 2025-Present Centreon +# Always use the same fixed date to test certificate validity + +BEGIN { + *CORE::GLOBAL::time = sub { 1781177760 }; +} + +1 diff --git a/tests/database/mssql/locks-waits.robot b/tests/database/mssql/locks-waits.robot new file mode 100644 index 0000000000..c7eb29dfcc --- /dev/null +++ b/tests/database/mssql/locks-waits.robot @@ -0,0 +1,78 @@ +*** Settings *** +Documentation In this robot file, before each test case, we restore the statefile to an initial state and age, and +... we fix the time so that the age of the data is always 1 minute. Every value, calculated as a per_minute +... average is consequently predictible. + +Resource ${CURDIR}${/}..${/}..${/}resources/import.resource + +Suite Setup Ctn Generic Suite Setup +Suite Teardown Ctn Generic Suite Teardown +Test Timeout 120s + + +*** Variables *** +${INJECT_PERL} -MDBD::Sybase -Mfixed_date -I${CURDIR} +${CMD} ${CENTREON_PLUGINS} +... --plugin=database::mssql::plugin +... --mode=locks-waits +... --hostname=${HOSTNAME} +... --port=${APIPORT} +... --username=1 +... --password=1 + + +*** Test Cases *** +Locks-waits ${tc} + [Tags] database mssql + [Setup] Ctn Locks Waits Test Setup + + ${OLD_PERL5OPT}= Get Environment Variable PERL5OPT default= + Set Environment Variable PERL5OPT ${INJECT_PERL} ${OLD_PERL5OPT} + Set Environment Variable MOCK_DBI_DATA_FILE ${CURDIR}${/}dead-locks-mock-data.pl + + ${command}= Catenate + ... ${CMD} + ... ${extra_options} + + Ctn Run Command Without Connector And Check Result As Strings ${command} ${expected_result} + + Examples: + ... tc + ... extra_options + ... expected_result + ... -- + ... 1 + ... ${EMPTY} + ... OK: 124.00 total locks waits/min | 'total#mssql.lockswaits.perminute'=124.00;;;0; 'AllocUnit#mssql.lockswaits.perminute'=8.00;;;0; 'Application#mssql.lockswaits.perminute'=1.00;;;0; 'Database#mssql.lockswaits.perminute'=5.00;;;0; 'Extent#mssql.lockswaits.perminute'=3.00;;;0; 'File#mssql.lockswaits.perminute'=30.00;;;0; 'HoBT#mssql.lockswaits.perminute'=2.00;;;0; 'Key#mssql.lockswaits.perminute'=51.00;;;0; 'Metadata#mssql.lockswaits.perminute'=7.00;;;0; 'OIB#mssql.lockswaits.perminute'=4.00;;;0; 'Object#mssql.lockswaits.perminute'=1.00;;;0; 'Page#mssql.lockswaits.perminute'=1.00;;;0; 'RID#mssql.lockswaits.perminute'=4.00;;;0; 'RowGroup#mssql.lockswaits.perminute'=4.00;;;0; 'Xact#mssql.lockswaits.perminute'=3.00;;;0; + ... 2 + ... --filter-database=Database + ... OK: 45.00 total locks waits/min - 5.00 locks waits/min | 'total#mssql.lockswaits.perminute'=45.00;;;0; 'Database#mssql.lockswaits.perminute'=5.00;;;0; + ... 3 + ... --include-instance=Database + ... OK: 45.00 total locks waits/min - 5.00 locks waits/min | 'total#mssql.lockswaits.perminute'=45.00;;;0; 'Database#mssql.lockswaits.perminute'=5.00;;;0; + ... 4 + ... --exclude-instance=Database + ... OK: 79.00 total locks waits/min | 'total#mssql.lockswaits.perminute'=79.00;;;0; 'AllocUnit#mssql.lockswaits.perminute'=8.00;;;0; 'Application#mssql.lockswaits.perminute'=1.00;;;0; 'Extent#mssql.lockswaits.perminute'=3.00;;;0; 'File#mssql.lockswaits.perminute'=30.00;;;0; 'HoBT#mssql.lockswaits.perminute'=2.00;;;0; 'Key#mssql.lockswaits.perminute'=51.00;;;0; 'Metadata#mssql.lockswaits.perminute'=7.00;;;0; 'OIB#mssql.lockswaits.perminute'=4.00;;;0; 'Object#mssql.lockswaits.perminute'=1.00;;;0; 'Page#mssql.lockswaits.perminute'=1.00;;;0; 'RID#mssql.lockswaits.perminute'=4.00;;;0; 'RowGroup#mssql.lockswaits.perminute'=4.00;;;0; 'Xact#mssql.lockswaits.perminute'=3.00;;;0; + ... 5 + ... --include-instance=Database --warning-lockswaits-by-instance=1 + ... WARNING: 5.00 locks waits/min | 'total#mssql.lockswaits.perminute'=45.00;;;0; 'Database#mssql.lockswaits.perminute'=5.00;0:1;;0; + ... 6 + ... --include-instance=Database --critical-lockswaits-by-instance=1 + ... CRITICAL: 5.00 locks waits/min | 'total#mssql.lockswaits.perminute'=45.00;;;0; 'Database#mssql.lockswaits.perminute'=5.00;;0:1;0; + ... 7 + ... --include-instance=unexisting + ... UNKNOWN: No locks waits counter found with given filters + ... 8 + ... --include-instance=Database --warning-lockswaits=40 + ... WARNING: 45.00 total locks waits/min | 'total#mssql.lockswaits.perminute'=45.00;0:40;;0; 'Database#mssql.lockswaits.perminute'=5.00;;;0; + ... 9 + ... --include-instance=Database --critical-lockswaits=40 + ... CRITICAL: 45.00 total locks waits/min | 'total#mssql.lockswaits.perminute'=45.00;;0:40;0; 'Database#mssql.lockswaits.perminute'=5.00;;;0; + + +*** Keywords *** +Ctn Locks Waits Test Setup + @{statefiles}= List Files In Directory ${CURDIR}${/}statefiles mssql_locks-waits_* + FOR ${statefile} IN @{statefiles} + Copy File ${CURDIR}${/}statefiles${/}${statefile} ${/}var${/}lib${/}centreon${/}centplugins${/} + END diff --git a/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000..03f9076f67 --- /dev/null +++ b/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 @@ -0,0 +1,32 @@ +{ + "AllocUnit_value": 11, + "Application_display": "Application", + "RowGroup_display": "RowGroup", + "Application_value": 511, + "Database_display": "Database", + "Page_value": 40, + "Extent_value": 4, + "HoBT_value": 37, + "Object_value": 53, + "OIB_display": "OIB", + "File_value": 532, + "Key_value": 50, + "Metadata_value": 31, + "Xact_display": "Xact", + "RID_display": "RID", + "RID_value": 20, + "Key_display": "Key", + "HoBT_display": "HoBT", + "Metadata_display": "Metadata", + "total_total": 1397, + "Extent_display": "Extent", + "OIB_value": 52, + "Page_display": "Page", + "Object_display": "Object", + "RowGroup_value": 1, + "last_timestamp": 1781177700, + "AllocUnit_display": "AllocUnit", + "Xact_value": 15, + "File_display": "File", + "Database_value": 40 +} diff --git a/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b b/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b new file mode 100644 index 0000000000..03f9076f67 --- /dev/null +++ b/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b @@ -0,0 +1,32 @@ +{ + "AllocUnit_value": 11, + "Application_display": "Application", + "RowGroup_display": "RowGroup", + "Application_value": 511, + "Database_display": "Database", + "Page_value": 40, + "Extent_value": 4, + "HoBT_value": 37, + "Object_value": 53, + "OIB_display": "OIB", + "File_value": 532, + "Key_value": 50, + "Metadata_value": 31, + "Xact_display": "Xact", + "RID_display": "RID", + "RID_value": 20, + "Key_display": "Key", + "HoBT_display": "HoBT", + "Metadata_display": "Metadata", + "total_total": 1397, + "Extent_display": "Extent", + "OIB_value": 52, + "Page_display": "Page", + "Object_display": "Object", + "RowGroup_value": 1, + "last_timestamp": 1781177700, + "AllocUnit_display": "AllocUnit", + "Xact_value": 15, + "File_display": "File", + "Database_value": 40 +} diff --git a/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000..03f9076f67 --- /dev/null +++ b/tests/database/mssql/statefiles/mssql_dead-locks_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 @@ -0,0 +1,32 @@ +{ + "AllocUnit_value": 11, + "Application_display": "Application", + "RowGroup_display": "RowGroup", + "Application_value": 511, + "Database_display": "Database", + "Page_value": 40, + "Extent_value": 4, + "HoBT_value": 37, + "Object_value": 53, + "OIB_display": "OIB", + "File_value": 532, + "Key_value": 50, + "Metadata_value": 31, + "Xact_display": "Xact", + "RID_display": "RID", + "RID_value": 20, + "Key_display": "Key", + "HoBT_display": "HoBT", + "Metadata_display": "Metadata", + "total_total": 1397, + "Extent_display": "Extent", + "OIB_value": 52, + "Page_display": "Page", + "Object_display": "Object", + "RowGroup_value": 1, + "last_timestamp": 1781177700, + "AllocUnit_display": "AllocUnit", + "Xact_value": 15, + "File_display": "File", + "Database_value": 40 +} diff --git a/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000..03f9076f67 --- /dev/null +++ b/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 @@ -0,0 +1,32 @@ +{ + "AllocUnit_value": 11, + "Application_display": "Application", + "RowGroup_display": "RowGroup", + "Application_value": 511, + "Database_display": "Database", + "Page_value": 40, + "Extent_value": 4, + "HoBT_value": 37, + "Object_value": 53, + "OIB_display": "OIB", + "File_value": 532, + "Key_value": 50, + "Metadata_value": 31, + "Xact_display": "Xact", + "RID_display": "RID", + "RID_value": 20, + "Key_display": "Key", + "HoBT_display": "HoBT", + "Metadata_display": "Metadata", + "total_total": 1397, + "Extent_display": "Extent", + "OIB_value": 52, + "Page_display": "Page", + "Object_display": "Object", + "RowGroup_value": 1, + "last_timestamp": 1781177700, + "AllocUnit_display": "AllocUnit", + "Xact_value": 15, + "File_display": "File", + "Database_value": 40 +} diff --git a/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b b/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b new file mode 100644 index 0000000000..03f9076f67 --- /dev/null +++ b/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b @@ -0,0 +1,32 @@ +{ + "AllocUnit_value": 11, + "Application_display": "Application", + "RowGroup_display": "RowGroup", + "Application_value": 511, + "Database_display": "Database", + "Page_value": 40, + "Extent_value": 4, + "HoBT_value": 37, + "Object_value": 53, + "OIB_display": "OIB", + "File_value": 532, + "Key_value": 50, + "Metadata_value": 31, + "Xact_display": "Xact", + "RID_display": "RID", + "RID_value": 20, + "Key_display": "Key", + "HoBT_display": "HoBT", + "Metadata_display": "Metadata", + "total_total": 1397, + "Extent_display": "Extent", + "OIB_value": 52, + "Page_display": "Page", + "Object_display": "Object", + "RowGroup_value": 1, + "last_timestamp": 1781177700, + "AllocUnit_display": "AllocUnit", + "Xact_value": 15, + "File_display": "File", + "Database_value": 40 +} diff --git a/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000..03f9076f67 --- /dev/null +++ b/tests/database/mssql/statefiles/mssql_locks-waits_6163085770a5bd8b5de2f59f3552e42657f650d44a68f187a815acb05182623e_fa7fe67124e94375d97e50896e0c32f44b03bb7ed5e9fb026341b55da724126b_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 @@ -0,0 +1,32 @@ +{ + "AllocUnit_value": 11, + "Application_display": "Application", + "RowGroup_display": "RowGroup", + "Application_value": 511, + "Database_display": "Database", + "Page_value": 40, + "Extent_value": 4, + "HoBT_value": 37, + "Object_value": 53, + "OIB_display": "OIB", + "File_value": 532, + "Key_value": 50, + "Metadata_value": 31, + "Xact_display": "Xact", + "RID_display": "RID", + "RID_value": 20, + "Key_display": "Key", + "HoBT_display": "HoBT", + "Metadata_display": "Metadata", + "total_total": 1397, + "Extent_display": "Extent", + "OIB_value": 52, + "Page_display": "Page", + "Object_display": "Object", + "RowGroup_value": 1, + "last_timestamp": 1781177700, + "AllocUnit_display": "AllocUnit", + "Xact_value": 15, + "File_display": "File", + "Database_value": 40 +}