Debian Codegraph @

src/centreon/common/microsoft/skype/mssql/mode/videoqoe.pm

raw
1 package centreon::common::microsoft::skype::mssql::mode::videoqoe;
2
3 use base qw(centreon::plugins::templates::counter);
4
5 use strict;
6 use warnings;
7
8 sub set_counters {
9 my ($self, %options) = @_;
10
11 $self->{maps_counters_type} = [
12 { name => 'global', type => 0, skipped_code => { -10 => 1 } },
13 { name => 'count', type => 0 },
14 ];
15
16 $self->{maps_counters}->{global} = [
17 { label => 'packet-loss', set => {
18 key_values => [ { name => 'VideoPacketLossRate' } ],
19 output_template => 'Packet Loss Rate: %.2f%%',
20 perfdatas => [
21 { label => 'video_pckt_loss_rate', value => 'VideoPacketLossRate',
22 template => '%.2f', unit => '%', min => 0, max => 100 },
23 ],
24 }
25 },
26 { label => 'post-fecplr', set => {
27 key_values => [ { name => 'VideoPostFECPLR' } ],
28 output_template => 'Packet Loss Rate After Correction: %.2f%%',
29 perfdatas => [
30 { label => 'video_post_fecplr', value => 'VideoPostFECPLR',
31 template => '%.2f', unit => '%', min => 0, max => 100 },
32 ],
33 }
34 },
35 { label => 'local-frame-loss', set => {
36 key_values => [ { name => 'VideoLocalFrameLossPercentageAvg' } ],
37 output_template => 'Video Frame Loss: %.2f%%',
38 perfdatas => [
39 { label => 'video_frame_loss_prct_avg', value => 'VideoLocalFrameLossPercentageAvg',
40 template => '%.2f', unit => '%', min => 0, max => 100 },
41 ],
42 }
43 },
44 { label => 'recv-frame', set => {
45 key_values => [ { name => 'RecvFrameRateAverage' } ],
46 output_template => 'Receiver Frame Rate: %.2f/s',
47 perfdatas => [
48 { label => 'rcv_frame_rate_avg', value => 'RecvFrameRateAverage',
49 template => '%.2f', unit => 'frames/s', min => 0 },
50 ],
51 }
52 },
53 { label => 'inbound-frame', set => {
54 key_values => [ { name => 'InboundVideoFrameRateAvg' } ],
55 output_template => 'Inbound Video Frame Rate: %.2f%%',
56 perfdatas => [
57 { label => 'inbound_video_frame_rate_avg', value => 'InboundVideoFrameRateAvg',
58 template => '%.2f', unit => '%', min => 0, max => 100 },
59 ],
60 }
61 },
62 { label => 'outbound-frame', set => {
63 key_values => [ { name => 'OutboundVideoFrameRateAvg' } ],
64 output_template => 'Outbound Video Frame Rate: %.2f%%',
65 perfdatas => [
66 { label => 'outbound_video_frame_rate_avg', value => 'OutboundVideoFrameRateAvg',
67 template => '%.2f', unit => '%', min => 0, max => 100 },
68 ],
69 }
70 },
71 ];
72 $self->{maps_counters}->{count} = [
73 { label => 'stream-count', set => {
74 key_values => [ { name => 'TotalStreams' } ],
75 output_template => 'Streams Count: %.2f/s',
76 perfdatas => [
77 { label => 'stream_count', value => 'TotalStreams', template => '%.2f',
78 unit => 'streams/s', min => 0 },
79 ],
80 }
81 },
82 ];
83 }
84
85 sub new {
86 my ($class, %options) = @_;
87 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
88 bless $self, $class;
89
90 $options{options}->add_options(arguments =>
91 {
92 "timeframe:s" => { name => 'timeframe', default => '900' },
93 "filter-counters:s" => { name => 'filter_counters', default => '' },
94 });
95 return $self;
96 }
97
98 sub check_options {
99 my ($self, %options) = @_;
100 $self->SUPER::check_options(%options);
101 }
102
103 sub manage_selection {
104 my ($self, %options) = @_;
105
106 $self->{sql} = $options{sql};
107 $self->{sql}->connect();
108
109 my $query = "SELECT AVG(VideoPostFECPLR) AS VideoPostFECPLR,
110 AVG(VideoLocalFrameLossPercentageAvg) AS VideoLocalFrameLossPercentageAvg,
111 AVG(RecvFrameRateAverage) AS RecvFrameRateAverage,
112 AVG(VideoPacketLossRate) AS VideoPacketLossRate,
113 AVG(InboundVideoFrameRateAvg) AS InboundVideoFrameRateAvg,
114 AVG(OutboundVideoFrameRateAvg) AS OutboundVideoFrameRateAvg,
115 COUNT(*) AS TotalStreams
116 FROM [QoEMetrics].[dbo].VideoStream
117 WHERE ConferenceDateTime > (DATEADD(SECOND,-" . $self->{option_results}->{timeframe} . ",SYSUTCDATETIME()))
118 AND ConferenceDateTime < SYSUTCDATETIME()";
119
120 $self->{sql}->query(query => $query);
121
122 my $results = $self->{sql}->fetchrow_hashref;
123
124 $self->{global} = {
125 VideoPostFECPLR => (defined($results->{VideoPostFECPLR})) ? $results->{VideoPostFECPLR} : 0,
126 VideoLocalFrameLossPercentageAvg => (defined($results->{VideoLocalFrameLossPercentageAvg})) ? $results->{VideoLocalFrameLossPercentageAvg} : 0,
127 RecvFrameRateAverage => (defined($results->{RecvFrameRateAverage})) ? $results->{RecvFrameRateAverage} : 0,
128 VideoPacketLossRate => (defined($results->{VideoPacketLossRate})) ? $results->{VideoPacketLossRate} : 0,
129 InboundVideoFrameRateAvg => (defined($results->{InboundVideoFrameRateAvg})) ? $results->{InboundVideoFrameRateAvg} : 0,
130 OutboundVideoFrameRateAvg => (defined($results->{OutboundVideoFrameRateAvg})) ? $results->{OutboundVideoFrameRateAvg} : 0,
131 };
132 $self->{count}->{TotalStreams} = $results->{TotalStreams} / $self->{option_results}->{timeframe};
133 }
134
135 1;
136
137 __END__
138
139 =head1 MODE
140
141 Check video stream QoE from SQL Server (Lync 2013, Skype 2015).
142
143 =over 8
144
145 =item B<--filter-counters>
146
147 Only display some counters (regexp can be used).
148
149 =item B<--timeframe>
150
151 Set the timeframe to query in seconds (default: 900)
152
153 =item B<--warning-*>
154
155 Set warning thresholds.
156 Can be : 'recv-frame', 'local-frame-loss', 'post-fecplr',
157 'packet-loss', 'inboud-frame', 'outbound-frame'
158
159 =item B<--critical-*>
160
161 Set critical thresholds.
162 Can be : 'recv-frame', 'local-frame-loss', 'post-fecplr',
163 packet-loss', 'inboud-frame', 'outbound-frame'
164
165 =back
166
167 =cut