| 1 | package Backup::Omni::Session::Monitor; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Params::Validate ':all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | use Backup::Omni::Class | ||||||||||||||||||||||||||||
| 8 | 1 | ▶ | version => $VERSION, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | base => 'Backup::Omni::Base', | ||||||||||||||||||||||||||||
| 10 | utils => 'omni2dt trim', | ||||||||||||||||||||||||||||
| 11 | constants => 'OMNISTAT', | ||||||||||||||||||||||||||||
| 12 | constant => { | ||||||||||||||||||||||||||||
| 13 | RUNNING => '%s -session %s -status_only 2> /dev/null', | ||||||||||||||||||||||||||||
| 14 | COMMAND => '%s -session %s -detail 2> /dev/null', | ||||||||||||||||||||||||||||
| 15 | }, | ||||||||||||||||||||||||||||
| 16 | vars => { | ||||||||||||||||||||||||||||
| 17 | PARAMS => { | ||||||||||||||||||||||||||||
| 18 | -session => 1, | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | 1 | ; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | Params::Validate::validation_options( | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | on_fail => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 25 | 0 | my $params = shift; | |||||||||||||||||||||||||||
| 26 | 0 | my $class = __PACKAGE__; | |||||||||||||||||||||||||||
| 27 | 0 | Backup::Omni::Base::validation_exception($params, $class); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 1 | ); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 32 | # Public Methods | ||||||||||||||||||||||||||||
| 33 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub running { | ||||||||||||||||||||||||||
|
Subroutine
running: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $stat = 0; | |||||||||||||||||||||||||||
| 39 | 0 | my $command = sprintf(RUNNING, OMNISTAT, $self->session); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my @result = `$command`; | |||||||||||||||||||||||||||
| 42 | 0 | my $rc = $?; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ((grep(/SessionID/, @result)) && ($rc == 0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
grep /SessionID/, @result and $rc == 0
MC/DC0%0/2
grep /SessionID/, @result and $rc == 0
grep /SessionID/, @result
$rc == 0
Truth table0%0/3
A and B
A= grep /SessionID/, @resultB= $rc == 0
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | $stat = 1; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | return $stat; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub object { | ||||||||||||||||||||||||||
|
Subroutine
object: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my $started = 0; | |||||||||||||||||||||||||||
| 58 | 0 | my $obj = undef; | |||||||||||||||||||||||||||
| 59 | 0 | my $command = sprintf(COMMAND, OMNISTAT, $self->session); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | my @result = `$command`; | |||||||||||||||||||||||||||
| 62 | 0 | my $rc = $?; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ((grep(/Object name/, @result)) && ($rc == 0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
grep /Object name/, @result and $rc == 0
MC/DC0%0/2
grep /Object name/, @result and $rc == 0
grep /Object name/, @result
$rc == 0
Truth table0%0/3
A and B
A= grep /Object name/, @resultB= $rc == 0
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | $obj = Backup::Omni::Session::Monitor::Object->new(); | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | foreach my $line (@result) { | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | chomp($line); | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | next if ($line eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ($line =~ /Object name/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | $started = 1; | |||||||||||||||||||||||||||
| 76 | 0 | $self->_parse_line($obj, $line); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($started) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($line =~ /Device name/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | $started = 0; | |||||||||||||||||||||||||||
| 85 | 0 | last; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | $self->_parse_line($obj, $line); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | return $obj; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub device { | ||||||||||||||||||||||||||
|
Subroutine
device: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | my $started = 0; | |||||||||||||||||||||||||||
| 107 | 0 | my $obj = undef; | |||||||||||||||||||||||||||
| 108 | 0 | my $command = sprintf(COMMAND, OMNISTAT, $self->session); | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | my @result = `$command`; | |||||||||||||||||||||||||||
| 111 | 0 | my $rc = $?; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ((grep(/Object name/, @result)) && ($rc == 0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
grep /Object name/, @result and $rc == 0
MC/DC0%0/2
grep /Object name/, @result and $rc == 0
grep /Object name/, @result
$rc == 0
Truth table0%0/3
A and B
A= grep /Object name/, @resultB= $rc == 0
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | $obj = Backup::Omni::Session::Monitor::Device->new(); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | foreach my $line (@result) { | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | chomp($line); | |||||||||||||||||||||||||||
| 120 | 0 | ▶ | next if ($line eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ($line =~ /Device name/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | $started = 1; | |||||||||||||||||||||||||||
| 125 | 0 | $self->_parse_line($obj, $line); | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ($started) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ($line =~ /Object name/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | $started = 0; | |||||||||||||||||||||||||||
| 134 | 0 | last; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | $self->_parse_line($obj, $line); | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | return $obj; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 153 | # Private Methods | ||||||||||||||||||||||||||||
| 154 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub _parse_line { | ||||||||||||||||||||||||||
|
Subroutine
_parse_line: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 157 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 158 | 0 | my $obj = shift; | |||||||||||||||||||||||||||
| 159 | 0 | my $line = shift; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | $line =~ m/^(.*): (.*)/; | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | my $key = $1; | |||||||||||||||||||||||||||
| 164 | 0 | my $value = $2; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | $key = trim($key); | |||||||||||||||||||||||||||
| 167 | 0 | $key =~ s/ /_/g; | |||||||||||||||||||||||||||
| 168 | 0 | $key = lc($key); | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | $value = trim($value); | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | $value = omni2dt($value) if ($value =~ /\w\w\w \d\d \w\w\w \d\d\d\d/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | # order is important here. Don't change | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | $obj->class->accessors($key); # may cause redefination errors | |||||||||||||||||||||||||||
| 176 | 0 | $obj->{$key} = $value; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | # the following are stubs, they are filled out above in _parse_line(). | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | package Backup::Omni::Session::Monitor::Device; | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | use Backup::Omni::Class | ||||||||||||||||||||||||||||
| 185 | 1 | ▶ | version => '0.01', | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 186 | base => 'Backup::Omni::Base', | ||||||||||||||||||||||||||||
| 187 | 1 | ; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | package Backup::Omni::Session::Monitor::Object; | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | use Backup::Omni::Class | ||||||||||||||||||||||||||||
| 192 | 1 | ▶ | version => '0.01', | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 193 | base => 'Backup::Omni::Base', | ||||||||||||||||||||||||||||
| 194 | 1 | ; | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 1 | 1; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | __END__ | ||||||||||||||||||||||||||||