Debian Codegraph @

src/blockchain/parity/ethpoller/mode/disk.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 blockchain::parity::ethpoller::mode::disk;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use bigint;
28 use Digest::MD5 qw(md5_hex);
29
30 sub set_counters {
31 my ($self, %options) = @_;
32
33 $self->{maps_counters_type} = [
34 { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 },
35 ];
36
37 $self->{maps_counters}->{global} = [
38 { label => 'disk-free', nlabel => 'eth.poller.disk.free', set => {
39 key_values => [ { name => 'disk_free' } ],
40 output_template => "Disk free: %d ",
41 perfdatas => [
42 { label => 'disk_free', value => 'disk_free', unit => 'B', template => '%d', min => 0 }
43 ],
44 }
45 },
46 { label => 'disk-available', nlabel => 'eth.poller.disk.available', set => {
47 key_values => [ { name => 'disk_available' } ],
48 output_template => "Disk available: %d ",
49 perfdatas => [
50 { label => 'disk_available', value => 'disk_available', unit => 'B', template => '%d', min => 0 }
51 ],
52 }
53 },
54 { label => 'disk-size', nlabel => 'eth.poller.disk.size', set => {
55 key_values => [ { name => 'disk_size' } ],
56 output_template => "Disk size: %d ",
57 perfdatas => [
58 { label => 'disk_size', value => 'disk_size', template => '%d', unit => 'B', min => 0 }
59 ],
60 }
61 },
62 { label => 'disk-used', nlabel => 'eth.poller.disk.used', set => {
63 key_values => [ { name => 'disk_used' } ],
64 output_template => "Disk used: %d ",
65 perfdatas => [
66 { label => 'disk_used', value => 'disk_used', template => '%d', unit => 'B', min => 0 }
67 ],
68 }
69 },
70 { label => 'disk-usage', nlabel => 'eth.poller.disk.usage', set => {
71 key_values => [ { name => 'disk_usage' } ],
72 output_template => "Disk usage: %d %%",
73 perfdatas => [
74 { label => 'disk_usage', value => 'disk_usage', template => '%.2f', unit => '%', min => 0 }
75 ],
76 }
77 },
78 { label => 'blockchain-dir', nlabel => 'eth.poller.blockchain.directory', set => {
79 key_values => [ { name => 'blockchain_dir' } ],
80 output_template => "Blockchain directory: %d",
81 perfdatas => [
82 { label => 'blockchain_dir', value => 'blockchain_dir', unit => 'B', template => '%d', min => 0 }
83 ],
84 }
85 }
86 ];
87
88 }
89
90 sub prefix_output {
91 my ($self, %options) = @_;
92
93 return "Disk '";
94 }
95
96 sub new {
97 my ($class, %options) = @_;
98 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
99 bless $self, $class;
100
101 $options{options}->add_options(arguments => {
102 "filter-name:s" => { name => 'filter_name' },
103 });
104
105 return $self;
106 }
107
108 sub manage_selection {
109 my ($self, %options) = @_;
110
111 my $result = $options{custom}->request_api(url_path => '/disk');
112
113 $self->{global} = { disk_free => $result->{free},
114 disk_available => $result->{available},
115 disk_size => $result->{size},
116 disk_used => $result->{used},
117 disk_usage => $result->{usage},
118 blockchain_dir => $result->{dir}
119 };
120
121 $self->{output}->output_add(severity => 'OK', long_msg => 'Ledger: ' . $result->{dir} . ' (' . $result->{usage} . '%)');
122 }
123
124 1;
125
126 __END__
127
128 =head1 MODE
129
130 Check Parity eth-poller for disk monitoring
131
132 =cut