Debian Codegraph @

src/apps/mq/rabbitmq/restapi/mode/systemusage.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::mq::rabbitmq::restapi::mode::systemusage;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28
29 sub set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'global', type => 0, skipped_code => { -10 => 1 } },
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'queue-msg', nlabel => 'system.queue.messages.count', set => {
38 key_values => [ { name => 'queue_messages' } ],
39 output_template => 'current queue messages : %s',
40 perfdatas => [
41 { template => '%d', min => 0 }
42 ]
43 }
44 },
45 { label => 'queue-msg-ready', nlabel => 'system.queue.messages.ready.count', set => {
46 key_values => [ { name => 'queue_messages_ready' } ],
47 output_template => 'current queue messages ready : %s',
48 perfdatas => [
49 { template => '%d', min => 0 }
50 ]
51 }
52 },
53 { label => 'db-event-queue', nlabel => 'system.db.event.queue.count', set => {
54 key_values => [ { name => 'db_event_queue' } ],
55 output_template => 'db event queue : %s',
56 perfdatas => [
57 { template => '%d', min => 0 }
58 ]
59 }
60 },
61 { label => 'disk-read-iops', nlabel => 'system.disk.read.usage.iops', set => {
62 key_values => [ { name => 'disk_reads', per_second => 1 } ],
63 output_template => 'disk reads iops : %s',
64 perfdatas => [
65 { template => '%d', unit => 'iops', min => 0 }
66 ]
67 }
68 },
69 { label => 'disk-write-iops', nlabel => 'system.disk.write.usage.iops', set => {
70 key_values => [ { name => 'disk_writes', per_second => 1 } ],
71 output_template => 'disk writes iops : %s',
72 perfdatas => [
73 { template => '%d', unit => 'iops', min => 0 }
74 ]
75 }
76 }
77 ];
78 }
79
80 sub new {
81 my ($class, %options) = @_;
82 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
83 bless $self, $class;
84
85 $options{options}->add_options(arguments => {
86 });
87
88 return $self;
89 }
90
91 sub manage_selection {
92 my ($self, %options) = @_;
93
94 my $result = $options{custom}->query(url_path => '/api/overview');
95 $self->{global} = {
96 disk_reads => $result->{message_stats}->{disk_reads},
97 disk_writes => $result->{message_stats}->{disk_writes},
98 queue_messages_ready => $result->{queue_totals}->{messages_ready},
99 queue_messages => $result->{queue_totals}->{messages},
100 db_event_queue => $result->{statistics_db_event_queue},
101 };
102
103 $self->{cache_name} = "rabbitmq_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
104 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
105 }
106
107 1;
108
109 __END__
110
111 =head1 MODE
112
113 Check global system statistics
114
115 =over 8
116
117 =item B<--warning-*> B<--critical-*>
118
119 Thresholds.
120 Can be: 'disk-read-iops', 'disk-write-iops',
121 'queue-msg-ready', 'queue-msg', 'db-event-queue'.
122
123 =back
124
125 =cut