blib/lib/Ereshkigal/App/Command/status.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 8 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 6 / 6 totaltotal 100% 61 / 61 CC 6 SCAR 7.9
CC
6
Cov
100%
validate_args
4.0
execute
3.0
BEGIN
1.0
CRAP 2.2
« blib/lib/Ereshkigal/App/Command/ban.pm ↑ Summary blib/lib/Ereshkigal/App/Command/cidr_ban.pm »
1 package Ereshkigal::App::Command::status;
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 Ereshkigal::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Ereshkigal::App::Command::status - Show status of the manager and kur instances.
11  
12 =head1 VERSION
13  
14 Version 0.0.1
15  
16 =cut
17  
18 2 our $VERSION = '0.0.1';
19  
20 =head1 SYNOPSIS
21  
22 ereshkigal status
23 ereshkigal status --all
24 ereshkigal status sshd
25  
26 =head1 DESCRIPTION
27  
28 Shows what the manager and its kurs are up to. With no args it asks only the
29 manager, so it answers even when a kur is wedged... its PID and uptime, and
30 per kur whether it is running, its PID, and how many times it has been
31 restarted.
32  
33 With C<--all> each running kur is asked for its own status too: ban counts
34 split into timed and permanent, the next expiry, whether CIDR banning is
35 enabled and whether the backend can actually do it, the checkpoint interval,
36 per instance stats, and how many unbans are still owed to the firewall along
37 with how long the longest has been outstanding.
38  
39 With a kur name it is that one instance in full, and naming a fan_out gate
40 gives its member list plus each member's status. A kur that is running but
41 whose socket cannot be reached shows up with an C<error> rather than a
42 C<status> block.
43  
44 =head1 METHODS
45  
46 The App::Cmd hooks this subcommand supplies... abstract, description,
47 usage_desc, opt_spec, validate_args, and execute.
48  
49 =cut
50  
51 1 ▶sub abstract { return 'show status of the manager and kur instances' }
Subroutine abstract: called CC=1 SCAR=0.0
Pod documented
52  
53 4 ▶sub description {
Subroutine description: called CC=1 SCAR=0.0
Pod documented
54 4 return <<'DESCRIPTION';
55 Show what the manager and its kurs are up to.
56  
57 With no args it asks only the manager, so it answers even when a kur is
58 wedged... its PID and uptime, and for each kur whether it is running,
59 its PID, and how many times it has been restarted.
60  
61 With --all each running kur is asked for its own status too: ban counts
62 split into timed and permanent, the next expiry, whether CIDR banning is
63 enabled and whether the backend can actually do it, the checkpoint
64 interval, per instance stats, and how many unbans are still owed to the
65 firewall along with how long the longest has been outstanding.
66  
67 With a kur name it is that one instance in full. Naming a fan_out gate
68 gives its member list plus each member's status.
69  
70 A kur that is running but whose socket cannot be reached shows up with an
71 error rather than a status block, which is the shape to look for when
72 something has gone quiet.
73  
74 ereshkigal status # the cheap overview
75 ereshkigal status --all # everything, asks every kur
76 ereshkigal status sshd # just that one
77 DESCRIPTION
78 } ## end sub description
79  
80 10 ▶sub usage_desc { return '%c status %o [kur]'; }
Subroutine usage_desc: called CC=1 SCAR=0.0
Pod documented
81  
82 10 ▶sub opt_spec {
Subroutine opt_spec: called CC=1 SCAR=0.0
Pod documented
83 10 return ( [ 'all', 'include the full status of every kur instance' ], );
84 }
85  
86 6 ▶sub validate_args {
Subroutine validate_args: called CC=4 SCAR=13.9
Pod documented
87 6 my ( $self, $opt, $args ) = @_;
88  
89 6 ▶ if ( @{$args} > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$args;} > 1) 1 5 6
90 1 $self->usage_error('status takes at most one arg, a kur instance name');
91 }
92 5 ▶ if ( @{$args} && $opt->all ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$args;} and $opt->all) 1 4 5
Condition100%3/3
@{$args;} and $opt->all
!ll&&!rl&&r
311
MC/DC100%2/2
@{$args;} and $opt->all
@{$args;} $opt->all
Truth table100%3/3
A and B
A= @{$args;}B= $opt->all
ABresult
0X0
100
111
93 1 $self->usage_error('--all and a kur instance name may not be used together');
94 }
95  
96 4 return;
97 } ## end sub validate_args
98  
99 4 ▶sub execute {
Subroutine execute: called CC=3 SCAR=11.0
Pod documented
100 4 my ( $self, $opt, $args ) = @_;
101  
102 4 ▶ if ( @{$args} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$args;}) { } 1 3 4
elsif ($opt->all) { } 1 2 3
103 1 $self->run_command( 'status_kur', { 'name' => $args->[0] } );
104 } elsif ( $opt->all ) {
105 1 $self->run_command('status_all');
106 } else {
107 2 $self->run_command('status');
108 }
109  
110 3 return;
111 } ## end sub execute
112  
113 2 1;
« blib/lib/Ereshkigal/App/Command/ban.pm ↑ Summary blib/lib/Ereshkigal/App/Command/cidr_ban.pm »