Debian Codegraph @

src/apps/lync/2013/mssql/mode/lyncusers.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package apps::lync::2013::mssql::mode::lyncusers;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub prefix_user_output {
29 my ($self, %options) = @_;
30
31 return "'Frontend' ";
32 }
33
34 sub set_counters {
35 my ($self, %options) = @_;
36
37 $self->{maps_counters_type} = [
38 { name => 'users', type => 0, cb_prefix_output => 'prefix_user_output' }
39 ];
40
41 $self->{maps_counters}->{users} = [
42 { label => 'total', nlabel => 'users.total.count', set => {
43 key_values => [ { name => 'total' } ],
44 output_template => '%d total users',
45 perfdatas => [
46 { label => 'total_users', template => '%d',
47 unit => 'users', min => 0 }
48 ]
49 }
50 },
51 { label => 'unique', nlabel => 'users.unique.count', set => {
52 key_values => [ { name => 'unique' } ],
53 output_template => '%d unique users',
54 perfdatas => [
55 { label => 'unique_users', template => '%d',
56 unit => 'users', min => 0 }
57 ]
58 }
59 }
60 ];
61 }
62
63 sub new {
64 my ($class, %options) = @_;
65 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
66 bless $self, $class;
67
68 $options{options}->add_options(arguments => {
69 });
70
71 return $self;
72 }
73
74 sub manage_selection {
75 my ($self, %options) = @_;
76
77 $options{sql}->connect();
78 $options{sql}->query(query => q{
79 Select
80 count(*) as totalonline,
81 count(distinct UserAtHost) as totalunique
82 From rtcdyn.dbo.RegistrarEndpoint RE
83 Inner Join
84 rtc.dbo.Resource R on R.ResourceId = RE.OwnerId
85 Inner Join
86 rtcdyn.dbo.Registrar Reg on Reg.RegistrarId = RE.PrimaryRegistrarClusterId
87 });
88
89 my ($total_online, $total_unique) = $options{sql}->fetchrow_array();
90 $self->{users} = { total => $total_online, unique => $total_unique };
91
92 }
93
94 1;
95
96 __END__
97
98 =head1 MODE
99
100 Check Lync Users Total and Unique. Query your RTCLocal Lync Frontend Dabatase (Get instance port in SQL Server configuration if dynamic mode)
101
102 =over 8
103
104 =item B<--filter-counters>
105
106 Only display some counters (regexp can be used).
107
108 =item B<--warning-*>
109
110 Set warning threshold for number of user. Can be : 'total', 'unique'
111
112 =item B<--critical-*>
113
114 Set critical threshold for number of user. Can be : 'total', 'unique'
115
116 =back
117
118 =cut