Check/supervisorctl.pm

filter: Statementstmt 88.7% 158 / 178 Branchbran 76.3% 58 / 76 Conditioncond 61.1% 11 / 18 MC/DCmcdc 40.0% 4 / 10 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 82.6% 243 / 294 CC 53 SCAR 31.4
CC
53
Cov
83%
new
33.9
run
23.9
parse_mappings
8.0
CRAP 23.2
« Monitoring/Sneck/Checks/supervisorctl.pm ↑ Summary
1 package Check::supervisorctl;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use File::Slurp qw(read_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Check::supervisorctl - Check the status of supervisorctl to see if it is okay.
11  
12 =head1 VERSION
13  
14 Version 0.1.0
15  
16 =cut
17  
18 2 our $VERSION = '0.1.0';
19  
20 # the statuses supervisorctl knows of
21 2 my @STATUSES = ( 'stopped', 'starting', 'running', 'backoff', 'stopping', 'exited', 'fatal', 'unknown' );
22  
23 # the values that are not a status mapping, without the _val, that parse_mappings knows of
24 2 my @OTHER_VALS = ( 'not_running', 'config_missing', 'config_dir_missing', 'config_dir_nonreadable', 'status_error' );
25  
26 =head1 SYNOPSIS
27  
28 use Check::supervisorctl;
29  
30 my $check_supervisorctl = Check::supervisorctl->new();
31 my $results = $check_supervisorctl->run;
32 print join( "\n", @{ $results->{results} } ) . "\n";
33 exit( $results->{exit} );
34  
35 =head1 SUBROUTINES/METHODS
36  
37 =head2 new
38  
39 Initiates the object.
40  
41 - status_mapping :: A hash of status mapping values.
42 default :: {
43 stopped => 2,
44 starting => 0,
45 running => 0,
46 backoff => 2,
47 stopping => 2,
48 exited => 2,
49 fatal => 2,
50 unknown => 2,
51 }
52  
53 - not_running_val :: Value for if it a config is not running.
54 default :: 2
55  
56 - config_missing_val :: Value for if it a config is missing for a running item.
57 default :: 2
58  
59 - config_dir_missing_val :: Value for if it the config dir is not present.
60 default :: 3
61  
62 - config_dir_nonreadable_val :: Value for if it the config dir is not readable.
63 default :: 3
64  
65 - status_error_val :: Value for if supervisorctl status could not be run or
66 returned a line that is not a item and status, such as when it can not
67 talk to supervisord.
68 default :: 3
69  
70 - config_check :: Boolean for if it should check the configs or not.
71 default :: 0
72  
73 - ignore :: A array of running items to ignore.
74 default :: []
75  
76 - config_ignore :: A array of configs to ignore.
77 default :: []
78  
79 - config_dir :: Config dir path.
80 default :: /usr/local/etc/supervisor/conf.d
81 default Linux :: /etc/supervisor/conf.d
82  
83 =cut
84  
85 10 ▶sub new {
Subroutine new: called CC=24 SCAR=35.2
Pod documented
86 10 my ( $blank, %opts ) = @_;
87  
88 10 my $self = {
89 status_mapping => {
90 stopped => 2,
91 starting => 0,
92 running => 0,
93 backoff => 2,
94 stopping => 2,
95 exited => 2,
96 fatal => 2,
97 unknown => 2,
98 },
99 val_to_string => {
100 0 => 'OK',
101 1 => 'WARNING',
102 2 => 'ALERT',
103 3 => 'UNKNOWN'
104 },
105 not_running_val => 2,
106 config_missing_val => 2,
107 config_dir_missing_val => 3,
108 config_dir_nonreadable_val => 3,
109 status_error_val => 3,
110 config_check => 0,
111 ignore => {},
112 config_ignore => {},
113 config_dir => '/usr/local/etc/supervisor/conf.d',
114 };
115 10 bless $self;
116  
117 10 ▶ if ( $^O eq 'linux' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "linux") 10 0 10
118 10 $self->{config_dir} = '/etc/supervisor/conf.d';
119 }
120  
121 # read in ignore settings
122 10 ▶ if ( defined( $opts{ignore} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"ignore"}) 2 8 10
123 2 ▶ if ( ref( $opts{ignore} ) ne 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"ignore"} ne "ARRAY") 0 2 2
124 0 die( '$opts{ignore} not a ref type of ARRAY but "' . ref( $opts{ignore} ) . '"' );
125 }
126 2 foreach my $to_ignore ( @{ $opts{ignore} } ) {
127 2 ▶ if ( ref($to_ignore) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $to_ignore ne "") 0 2 2
128 0 die( 'array $opts{ignore} contains a item that is not of ref type "" but ' . ref($to_ignore) );
129 }
130 2 $self->{ignore}{$to_ignore} = 1;
131 }
132 } ## end if ( defined( $opts{ignore} ) )
133  
134 # read in config ignore settings
135 10 ▶ if ( defined( $opts{config_ignore} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"config_ignore"}) 2 8 10
136 2 ▶ if ( ref( $opts{config_ignore} ) ne 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"config_ignore"} ne "ARRAY") 0 2 2
137 0 die( '$opts{config_ignore} not a ref type of ARRAY but "' . ref( $opts{config_ignore} ) . '"' );
138 }
139 2 foreach my $to_ignore ( @{ $opts{config_ignore} } ) {
140 4 ▶ if ( ref($to_ignore) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $to_ignore ne "") 0 4 4
141 0 die( 'array $opts{config_ignore} contains a item that is not of ref type "" but ' . ref($to_ignore) );
142 }
143 4 $self->{config_ignore}{$to_ignore} = 1;
144 }
145 } ## end if ( defined( $opts{config_ignore} ) )
146  
147 # read in other status settings
148 10 foreach my $to_read_in ( map { $_ . '_val' } @OTHER_VALS ) {
149 50 ▶ if ( defined( $opts{$to_read_in} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{$to_read_in}) 3 47 50
150 3 ▶ if ( ref( $opts{$to_read_in} ) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{$to_read_in} ne "") 0 3 3
151 0 die( '$opts{' . $to_read_in . '} not a ref type of "" not "' . ref( $opts{$to_read_in} ) . '"' );
152 }
153 3 ▶ if ( $opts{$to_read_in} !~ /^[0123]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{$to_read_in} =~ /^[0123]$/) 1 2 3
154 1 die( '$opts{' . $to_read_in . '} is not 0, 1, 2, or 3, but "' . $opts{$to_read_in} . '"' );
155 }
156 2 $self->{$to_read_in} = $opts{$to_read_in};
157 }
158 } ## end foreach my $to_read_in ( map { $_ . '_val' } @OTHER_VALS)
159  
160 # read in any specified status mappings and
161 9 ▶ if ( defined( $opts{status_mapping} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"status_mapping"}) 1 8 9
162 1 ▶ if ( ref( $opts{status_mapping} ) ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"status_mapping"} ne "HASH") 0 1 1
163 0 die( '$opts{status_mapping} not a ref type of HASH but "' . ref( $opts{status_mapping} ) . '"' );
164 }
165 1 foreach my $status ( keys( %{ $opts{status_mapping} } ) ) {
166 1 my $lc_status = lc($status);
167 1 ▶ if ( ref( $opts{status_mapping}{$status} ) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"status_mapping"}{$status} ne "") 0 1 1
168 die( '$opts{status_mapping}{'
169 . $status
170 . '} is not of ref type "" but "'
171 0 . ref( $opts{status_mapping}{$status} )
172 . '"' );
173 }
174 1 ▶ if ( !defined( $self->{status_mapping}{$lc_status} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"status_mapping"}{$lc_status}) 0 1 1
175 0 die( "'" . $status . "' is not a known status type... expected " . join( ', ', @STATUSES ) );
176 }
177 1 ▶ if ( $opts{status_mapping}{$status} !~ /^[0123]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"status_mapping"}{$status} =~ /^[0123]$/) 0 1 1
178 die( '$opts{status_mapping}{'
179 . $status
180 . '} is not 0, 1, 2, or 3, but "'
181 0 . $opts{status_mapping}{$status}
182 . '"' );
183 }
184 1 $self->{status_mapping}{$lc_status} = $opts{status_mapping}{$status};
185 } ## end foreach my $status ( keys( %{ $opts{status_mapping...}}))
186 } ## end if ( defined( $opts{status_mapping} ) )
187  
188 9 ▶ if ( defined( $opts{config_check} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"config_check"}) 3 6 9
189 3 ▶ if ( ref( $opts{config_check} ) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"config_check"} ne "") 0 3 3
190 0 die( '$opts{config_check} is not of ref type "" but "' . ref( $opts{config_check} ) . '"' );
191 }
192 3 $self->{config_check} = $opts{config_check};
193 }
194  
195 9 ▶ if ( defined( $opts{config_dir} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"config_dir"}) 3 6 9
196 3 ▶ if ( ref( $opts{config_dir} ) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"config_dir"} ne "") 0 3 3
197 0 die( '$opts{config_dir} is not of ref type "" but "' . ref( $opts{config_dir} ) . '"' );
198 }
199 3 $self->{config_dir} = $opts{config_dir};
200 }
201  
202 9 return $self;
203 } ## end sub new
204  
205 =head2 parse_mappings
206  
207 Parses a list of status=value strings, as taken by -s for check_supervisorctl,
208 into a hash of options for L</new>. Whitespace is removed.
209  
210 The names may be any of the statuses for status_mapping, or not_running,
211 config_missing, config_dir_missing, config_dir_nonreadable, or status_error
212 for the matching *_val options.
213  
214 Dies if one is not in the form of name=value or the name is not known. The values
215 are checked by L</new>.
216  
217 my %mapping_opts = Check::supervisorctl->parse_mappings( 'stopped=1', 'config_missing=1' );
218 my $checker = Check::supervisorctl->new( config_check => 1, %mapping_opts );
219  
220 =cut
221  
222 3 ▶sub parse_mappings {
Subroutine parse_mappings: called CC=8 SCAR=20.8
Pod documented
223 3 my ( $blank, @to_parse ) = @_;
224  
225 3 my %other_vals = map { $_ => 1 } @OTHER_VALS;
226 3 my %statuses = map { $_ => 1 } @STATUSES;
227  
228 3 my %status_mapping;
229 my %to_return;
230 3 foreach my $mapping (@to_parse) {
231 5 my $cleaned = $mapping;
232 5 $cleaned =~ s/\s+//g;
233 5 my ( $name, $value ) = split( /\=/, $cleaned, 2 );
234 5 ▶ if ( !defined($name) || !defined($value) || $name eq '' || $value eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name && defined $value or $name eq "" or $value eq "") 1 4 5
Condition66%6/9
not defined $name && defined $value or $name eq "" or $value eq ""
l!l&&r!l&&!r
104
not defined $name && defined $value or $name eq ""
l!l&&r!l&&!r
104
defined $name && defined $value
!ll&&!rl&&r
014
MC/DC25%1/4
not defined $name && defined $value or $name eq "" or $value eq ""
defined $name defined $value $name eq "" $value eq ""
Truth table40%2/5
not(A && B) or C or D
A= defined $nameB= defined $valueC= $name eq ""D= $value eq ""
ABCDresult
0XXX1
10XX1
111X1
11011
11000
235 1 die( 'status mapping "' . $mapping . '" is not in the form of name=value' );
236 }
237 4 $name = lc($name);
238 4 ▶ if ( $other_vals{$name} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($other_vals{$name}) { } 2 2 4
elsif ($statuses{$name}) { } 1 1 2
239 2 $to_return{ $name . '_val' } = $value;
240 } elsif ( $statuses{$name} ) {
241 1 $status_mapping{$name} = $value;
242 } else {
243 1 die( 'status mapping "'
244 . $mapping
245 . '" is not for a known name... expected '
246 . join( ', ', @STATUSES, @OTHER_VALS ) );
247 }
248 } ## end foreach my $mapping (@to_parse)
249 1 $to_return{status_mapping} = \%status_mapping;
250  
251 1 return %to_return;
252 } ## end sub parse_mappings
253  
254 =head2 run
255  
256 This runs it.
257  
258 my $results=$check_supervisorctl->run;
259  
260 use Data::Dumper;
261 print Dumper($results);
262 exit($results->{exit});
263  
264 It optionally takes the output of 'supervisorctl status', for when it has already
265 been ran by something else. If not given, 'supervisorctl status' is ran.
266  
267 - status_output :: The output of 'supervisorctl status'.
268  
269 my $results=$check_supervisorctl->run( status_output => $output );
270  
271 The returned data is as below.
272  
273 - .configs[] :: A array of configs found.
274  
275 - .config_not_running[] :: A array of configs present but not running.
276  
277 - .config_missing[] :: A array of running items was found, but no matchingly named config was found.
278  
279 - .config_check :: If it was told to check the configs or not for matching names.
280  
281 - .config_dir :: The config dir to check.
282  
283 - .config_ignored[] :: Array of configs ignored.
284  
285 - .config_ignore :: Configs asked to be ignored.
286  
287 - .exit :: Nagios style exit value.
288  
289 - .status.$name :: Status of each item.
290  
291 - .total :: Number of items found in the status output, not counting ignored ones.
292  
293 - .ignored[] :: A array of ignored items.
294  
295 - .ignore :: A array of items asked to be ignored.
296  
297 - .config_dir_missing :: If the config dir is missing.
298  
299 - .config_dir_readable :: If the config dir is readable.
300  
301 - .status_list.$status :: A hash of the various statuses with keys being arrays of items for that status.
302  
303 - .status_errors[] :: Lines from 'supervisorctl status' that were not a item and status,
304 such as when it can not talk to supervisord.
305  
306 - .results[] :: A descriptive a array of the results of the check.
307  
308 =cut
309  
310 9 ▶sub run {
Subroutine run: called CC=22 SCAR=31.7
Pod documented
311 9 my ( $self, %opts ) = @_;
312  
313 my $to_return = {
314 configs => [],
315 config_not_running => [],
316 config_missing => [],
317 config_check => $self->{config_check},
318 config_dir => $self->{config_dir},
319 config_ignored => [],
320 9 config_ignore => [ sort( keys( %{ $self->{config_ignore} } ) ) ],
321 exit => 0,
322 status => {},
323 total => 0,
324 ignored => [],
325 9 ignore => [ sort( keys( %{ $self->{ignore} } ) ) ],
326 config_dir_missing => 0,
327 config_dir_readable => 1,
328 9 status_list => { map { $_ => [] } @STATUSES },
329 status_errors => [],
330 results => []
331 };
332  
333 9 my $output = $opts{status_output};
334 9 ▶ if ( !defined($output) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output) 0 9 9
335 0 $output = `supervisorctl status 2> /dev/null`;
336 # -1 is it could not be ran at all and 127 is the shell not finding it
337 0 ▶ if ( $? == -1 || ( $? >> 8 ) == 127 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? == -1 or $? >> 8 == 127) 0 0 0
Condition0%0/3
$? == -1 or $? >> 8 == 127
l!l&&r!l&&!r
000
MC/DC0%0/2
$? == -1 or $? >> 8 == 127
$? == -1 $? >> 8 == 127
Truth table0%0/3
A or B
A= $? == -1B= $? >> 8 == 127
ABresult
1X1
011
000
338 0 $self->_status_error( $to_return, 'could not run "supervisorctl status"' );
339 0 $output = '';
340 }
341 }
342  
343 9 foreach my $line ( split( /\n/, $output ) ) {
344 # blank lines are not a problem
345 27 ▶ if ( $line =~ /^\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*$/) 0 27 27
346 0 next;
347 }
348 27 my ( $name, $status ) = split( /\s+/, $line );
349 27 ▶ if ( defined($status) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $status) 26 1 27
350 26 $status = lc($status);
351 }
352 # anything not a item followed by a known status is a problem, such as
353 # "unix:///var/run/supervisor.sock no such file" for when supervisord is down
354 27 ▶ if ( !defined($status) || !defined( $self->{status_mapping}{$status} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status and defined $self->{"status_mapping"}{$status}) 2 25 27
Condition100%3/3
defined $status and defined $self->{"status_mapping"}{$status}
!ll&&!rl&&r
1125
MC/DC100%2/2
defined $status and defined $self->{"status_mapping"}{$status}
defined $status defined $self->{"status_mapping"}{$status}
Truth table100%3/3
A and B
A= defined $statusB= defined $self->{"status_mapping"}{$status}
ABresult
0X0
100
111
355 2 $self->_status_error( $to_return, 'supervisorctl status returned "' . $line . '"' );
356 2 next;
357 }
358 25 ▶ if ( $self->{ignore}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ignore"}{$name}) 2 23 25
359 2 push( @{ $to_return->{ignored} }, $name );
360 2 push( @{ $to_return->{results} }, 'IGNORED - ' . $name . ', ' . $status );
361 2 next;
362 }
363 23 $self->_raise_exit( $to_return, $self->{status_mapping}{$status} );
364 23 $to_return->{status}{$name} = $status;
365 23 $to_return->{total}++;
366 23 push( @{ $to_return->{status_list}{$status} }, $name );
367 push(
368 23 @{ $to_return->{results} },
369 23 $self->{val_to_string}{ $self->{status_mapping}{$status} } . ' - ' . $name . ', ' . $status
370 );
371 } ## end foreach my $line ( split( /\n/, $output ) )
372  
373 # check the config dir only if asked to
374 9 ▶ if ( $self->{config_check} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"config_check"}) 3 6 9
375 # handling for if it does not exist
376 3 ▶ if ( -d $self->{config_dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $self->{'config_dir'}) { } 2 1 3
377 2 my @dir_entries;
378 2 eval { @dir_entries = read_dir( $self->{config_dir} ); };
379 2 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 2 2
380 0 $to_return->{config_dir_readable} = 0;
381 0 $self->_raise_exit( $to_return, $self->{config_dir_nonreadable_val} );
382 push(
383 0 @{ $to_return->{results} },
384 $self->{val_to_string}{ $self->{config_dir_nonreadable_val} }
385 . ' - config dir, "'
386 . $self->{config_dir}
387 0 . '", not readable'
388 );
389 } ## end if ($@)
390 # if it was readable, process it
391 2 ▶ if ( $to_return->{config_dir_readable} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_return->{"config_dir_readable"}) 2 0 2
392 # a lookup hash of found configs, including ignored ones
393 2 my %configs;
394 2 my %ignored = map { $_ => 1 } @{ $to_return->{ignored} };
395 # process each dir entry
396 2 foreach my $entry ( sort(@dir_entries) ) {
397 # only process items ending in .conf and that are a file.
398 12 ▶ if ( $entry =~ /\.conf$/ && -f $self->{config_dir} . '/' . $entry ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ /\.conf$/ and -f $self->{"config_dir"} . '/' . $entry) 10 2 12
Condition66%2/3
$entry =~ /\.conf$/ and -f $self->{"config_dir"} . '/' . $entry
!ll&&!rl&&r
2010
MC/DC50%1/2
$entry =~ /\.conf$/ and -f $self->{"config_dir"} . '/' . $entry
$entry =~ /\.conf$/ -f $self->{"config_dir"} . '/' . $entry
Truth table66%2/3
A and B
A= $entry =~ /\.conf$/B= -f $self->{"config_dir"} . '/' . $entry
ABresult
0X0
100
111
399 10 $entry =~ s/\.conf$//;
400 10 $configs{$entry} = 1;
401 10 ▶ if ( $self->{config_ignore}{$entry} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'config_ignore'}{$entry}) { } 4 6 10
elsif ($ignored{$entry}) { } 1 5 6
402 4 push( @{ $to_return->{config_ignored} }, $entry );
403 4 push( @{ $to_return->{results} }, 'IGNORED - config ' . $entry );
404 } elsif ( $ignored{$entry} ) {
405 # the item is ignored, so if it is running or not does not matter
406 1 push( @{ $to_return->{configs} }, $entry );
407 } else {
408 5 push( @{ $to_return->{configs} }, $entry );
409 5 ▶ if ( !defined( $to_return->{status}{$entry} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $to_return->{'status'}{$entry}) { } 1 4 5
410 1 push( @{ $to_return->{config_not_running} }, $entry );
411 push(
412 1 @{ $to_return->{results} },
413 $self->{val_to_string}{ $self->{not_running_val} }
414 1 . ' - non-running config "'
415 . $entry . '"'
416 );
417 1 $self->_raise_exit( $to_return, $self->{not_running_val} );
418 } else {
419 4 push( @{ $to_return->{results} }, 'OK - config present for ' . $entry );
420 }
421 } ## end else [ if ( $self->{config_ignore}{$entry} ) ]
422 } ## end if ( $entry =~ /\.conf$/ && -f $self->{config_dir...})
423 } ## end foreach my $entry ( sort(@dir_entries) )
424 2 foreach my $running ( sort( keys( %{ $to_return->{status} } ) ) ) {
425 # only check if it is missing as we already check if a running item exists for a config previously
426 6 ▶ if ( !$configs{$running} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($configs{$running}) 2 4 6
427 2 push( @{ $to_return->{config_missing} }, $running );
428 push(
429 2 @{ $to_return->{results} },
430 2 $self->{val_to_string}{ $self->{config_missing_val} } . ' - missing config ' . $running
431 );
432 2 $self->_raise_exit( $to_return, $self->{config_missing_val} );
433 }
434 } ## end foreach my $running ( sort( keys( %{ $to_return...})))
435 } ## end if ( $to_return->{config_dir_readable} )
436 } else {
437 1 $to_return->{config_dir_missing} = 1;
438 1 $self->_raise_exit( $to_return, $self->{config_dir_missing_val} );
439 push(
440 1 @{ $to_return->{results} },
441 $self->{val_to_string}{ $self->{config_dir_missing_val} }
442 . ' - config dir, "'
443 . $self->{config_dir}
444 1 . '", missing'
445 );
446 } ## end else [ if ( -d $self->{config_dir} ) ]
447 } ## end if ( $self->{config_check} )
448  
449 9 return $to_return;
450 } ## end sub run
451  
452 # raises the exit value in the passed results hash if the new one is higher
453 29 ▶sub _raise_exit {
Subroutine _raise_exit: called CC=2 SCAR=6.9
454 29 my ( $self, $to_return, $value ) = @_;
455  
456 29 ▶ if ( $to_return->{exit} < $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_return->{"exit"} < $value) 7 22 29
457 7 $to_return->{exit} = $value;
458 }
459  
460 29 return;
461 }
462  
463 # records a problem with supervisorctl status in the passed results hash
464 2 ▶sub _status_error {
Subroutine _status_error: called CC=1 SCAR=0.0
465 2 my ( $self, $to_return, $error ) = @_;
466  
467 2 push( @{ $to_return->{status_errors} }, $error );
468 2 push( @{ $to_return->{results} }, $self->{val_to_string}{ $self->{status_error_val} } . ' - ' . $error );
469 2 $self->_raise_exit( $to_return, $self->{status_error_val} );
470  
471 2 return;
472 }
473  
474 =pod
475  
476 =head1 AUTHOR
477  
478 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
479  
480 =head1 BUGS
481  
482 Please report any bugs or feature requests to C<bug-check-supervisorctl at rt.cpan.org>, or through
483 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Check-supervisorctl>. I will be notified, and then you'll
484 automatically be notified of progress on your bug as I make changes.
485  
486  
487  
488  
489 =head1 SUPPORT
490  
491 You can find documentation for this module with the perldoc command.
492  
493 perldoc Check::supervisorctl
494  
495  
496 You can also look for information at:
497  
498 =over 4
499  
500 =item * RT: CPAN's request tracker (report bugs here)
501  
502 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Check-supervisorctl>
503  
504 =item * Github issue tracker (report bugs here)
505  
506 L<https://github.com/VVelox/Check-supervisorctl/issues>
507  
508 =item * CPAN Ratings
509  
510 L<https://cpanratings.perl.org/d/Check-supervisorctl>
511  
512 =item * Search CPAN
513  
514 L<https://metacpan.org/release/Check-supervisorctl>
515  
516 =back
517  
518  
519 =head1 ACKNOWLEDGEMENTS
520  
521  
522 =head1 LICENSE AND COPYRIGHT
523  
524 This software is Copyright (c) 2025 by Zane C. Bowers-Hadley.
525  
526 This is free software, licensed under:
527  
528 The GNU General Public License, Version 3, June 2007
529  
530  
531 =cut
532  
533 2 1; # End of Check::supervisorctl
« Monitoring/Sneck/Checks/supervisorctl.pm ↑ Summary