From f694a65d359c78a1d5bf8d304118e18e51ab2a11 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Tue, 9 Feb 2016 15:55:07 +0100 Subject: [PATCH 1/3] + Add poorcalls monitoring for MS Lync 2013 --- apps/lync/2013/mssql/mode/poorcalls.pm | 136 +++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 apps/lync/2013/mssql/mode/poorcalls.pm diff --git a/apps/lync/2013/mssql/mode/poorcalls.pm b/apps/lync/2013/mssql/mode/poorcalls.pm new file mode 100644 index 000000000..96d8a21bf --- /dev/null +++ b/apps/lync/2013/mssql/mode/poorcalls.pm @@ -0,0 +1,136 @@ +# +# 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::poorcalls; + +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 => 'uri', type => 1, cb_prefix_output => 'prefix_uri_output', message_multiple => 'All users are ok' }, + + ]; + + $self->{maps_counters}->{global} = [ + { label => 'global', set => { + key_values => [ { name => 'count' } ], + output_template => '%d Poor calls', + perfdatas => [ + { label => 'poor_calls', value => 'count_absolute', template => '%d', + unit => 'calls', min => 0, label_extra_instance => 0 }, + ], + } + }, + ]; + $self->{maps_counters}->{uri} = [ + { label => 'user', set => { + key_values => [ { name => 'count' }, { name => 'display' } ], + output_template => 'count : %d', + perfdatas => [ + { label => 'poor_calls', value => 'count_absolute', template => '%d', + unit => 'calls', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +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 => '65' }, + 'filter-user:s' => { name => 'filter_user' }, + }); + return $self; +} + +sub prefix_uri_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $self->{sql}->query(query => "SELECT URI, LastPoorCallTime + FROM [QoEMetrics].[dbo].[User] + WHERE LastPoorCallTime>=dateadd(minute,-".$self->{option_results}->{lookback}.",getdate())"); + my $total; + while (my $row = $self->{sql}->fetchrow_hashref()) { + if (defined($self->{option_results}->{filter_user}) && $self->{option_results}->{filter_user} ne '' && + $row->{URI} !~ /$self->{option_results}->{filter_user}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $row->{URI} . "': no matching filter.", debug => 1); + next; + } + $self->{global}->{count}++; + $self->{uri}->{$row->{URI}} = {count => 0, display => $row->{URI}} if (!defined($self->{uri}->{$row->{URI}})); + $self->{uri}->{$row->{URI}}->{count}++; + } + +} + +1; + +__END__ + +=head1 MODE + +Check Lync Poor Calls during last X minutes (Total and per users) + +=over 8 + +=item B<--filter-user> + +Filter user name (can be a regexp) + +=item B<--filter-counters> + +Only display some counters (regexp can be used). + +=item B<--lookback> + +Minutes to lookback (From you to UTC) default: 65 + +=item B<--warning-*> + +Set warning threshold for number of poor calls. Can be : 'total', 'user' + +=item B<--critical-*> + +Set critical threshold for number of poor calls. Can be : 'total', 'user' + +=back + +=cut From 8e257a62f1be7fd8605038d93401ea0ffda3ffa2 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Tue, 9 Feb 2016 15:56:45 +0100 Subject: [PATCH 2/3] + Add mode for unique and total users MS Lync 2013 --- apps/lync/2013/mssql/mode/lyncusers.pm | 118 +++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 apps/lync/2013/mssql/mode/lyncusers.pm diff --git a/apps/lync/2013/mssql/mode/lyncusers.pm b/apps/lync/2013/mssql/mode/lyncusers.pm new file mode 100644 index 000000000..487c96657 --- /dev/null +++ b/apps/lync/2013/mssql/mode/lyncusers.pm @@ -0,0 +1,118 @@ +# +# 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::lyncusers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'User counts are OK' }, + ]; + + $self->{maps_counters}->{users} = [ + { label => 'total', set => { + key_values => [ { name => 'total' } ], + output_template => '%d Total users', + perfdatas => [ + { label => 'total_users', value => 'total_absolute', template => '%d', + unit => 'users', min => 0, label_extra_instance => 0 }, + ], + } + }, + { label => 'unique', set => { + key_values => [ { name => 'unique' } ], + output_template => '%d Unique users', + perfdatas => [ + { label => 'total_users', value => 'unique_absolute', template => '%d', + unit => 'users', 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 prefix_user_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + $self->{sql}->connect(); + + $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 ($total_online, $total_unique) = $self->{sql}->fetchrow_array(); + $self->{users}{total} = { total => $total_online, unique => $total_unique, display => 'Frontend' }; + +} + +1; + +__END__ + +=head1 MODE + +Check Lync Users Total and Unique. Query your RTCLocal Lync Frontend Dabatase (Get instance port in SQL Server configuration if dynamic mode) + +=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 : 'total', 'unique' + +=item B<--critical-*> + +Set critical threshold for number of user. Can be : 'total', 'unique' + +=back + +=cut From 002741bc82dc1a9dbe3af19529538d791de43285 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Tue, 9 Feb 2016 16:13:01 +0100 Subject: [PATCH 3/3] + fix error in perfdata label Thanks Quentin ;) --- apps/lync/2013/mssql/mode/lyncusers.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/lync/2013/mssql/mode/lyncusers.pm b/apps/lync/2013/mssql/mode/lyncusers.pm index 487c96657..9e04aaff5 100644 --- a/apps/lync/2013/mssql/mode/lyncusers.pm +++ b/apps/lync/2013/mssql/mode/lyncusers.pm @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'unique' } ], output_template => '%d Unique users', perfdatas => [ - { label => 'total_users', value => 'unique_absolute', template => '%d', + { label => 'unique_users', value => 'unique_absolute', template => '%d', unit => 'users', min => 0, label_extra_instance => 0 }, ], }