| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This file is part of StorageDisplay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2014-2023 by Vincent Danjean. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # PODNAME: storage2dot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # ABSTRACT: analyse and generate a graphical view of a machine storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 16 | our $VERSION = '2.06'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # delay module loading so that local data collect can be done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # without extra modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # use StorageDisplay; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 16 | ▶ | use StorageDisplay::Collect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 16 | my $cleanup_readmode=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub collect_from_remote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_from_remote: not called CC=17 SCAR=55.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $remote = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $content=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | require Net::OpenSSH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | Net::OpenSSH->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | require Term::ReadKey; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | Term::ReadKey->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } or die "Cannot load required modules (Net::OpenSSH and/or Term::ReadKey) for remote data collect: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 16 | ▶ | END { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 16 | ▶ | if ($cleanup_readmode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # in case of bug, always restore normal mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ReadMode('normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $ssh = Net::OpenSSH->new($remote); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $ssh->error and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | die "Couldn't establish SSH connection: ". $ssh->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my ($in, $out, $pid) = $ssh->open2( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | #'cat', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'perl', '--', '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $fdperlmod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | open($fdperlmod, '<', $INC{'StorageDisplay/Collect.pm'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | or die "Cannot open ".INC{'StorageDisplay/Collect.pm'}.": $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | #use Sys::Syscall; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | #Sys::Syscall::sendfile($in, $fdperlmod); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | while(defined(my $line=<$fdperlmod>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | last if $line =~ m/^__END__\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | print $in $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | close $fdperlmod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | #print $in "StorageDisplay::Collect::dump_collect;\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my @args = (@_, 'LocalBySSH'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $cmd = "StorageDisplay::Collect::dump_collect('".join("','", @args)."');\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | print STDERR 'Running through SSH: ',$cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | print $in $cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | print $in "__END__\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | flush $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 16 | ▶ | use IO::Select; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 16 | ▶ | use POSIX ":sys_wait_h"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $sel = IO::Select->new(\*STDIN, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $timeout = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $cleanup_readmode=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ReadMode('noecho'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my ($in_closed,$out_closed) = (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $!=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my @ready = $sel->can_read($timeout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($!) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | die "Error with select: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if (scalar(@ready)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | foreach my $fd (@ready) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ($fd == $out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $line=<$out>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (defined($line)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $content .= $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $sel->remove($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | close $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $out_closed=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $line=<STDIN>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if (print $in $line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | flush $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $sel->remove(\*STDIN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | close $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $in_closed=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $res = waitpid($pid, WNOHANG); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($res==-1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | die "Some error occurred ".($? >> 8).": $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($res) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (!$in_closed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $sel->remove(\*STDIN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | close $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ReadMode('normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | #print STDERR "timeout for $pid\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if (!$out_closed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | while (defined(my $line=<$out>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $content .= $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $sel->remove($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | close $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ReadMode('normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $cleanup_readmode=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 16 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 16 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 16 | $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 16 | $Data::Dumper::Purity = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | #use Carp::Always; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 16 | my $remote; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | my $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 16 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | my $collect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | my $recordfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | my $replayfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 16 | my $verbose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 16 | my $help; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 16 | my $man; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 16 | ▶ | GetOptions ("d|data=s" => \$data, # string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | "r|remote=s" => \$remote, # string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | "o|output=s" => \$output, # string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | "c|collect-only" => \$collect, # flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | "record-file=s" => \$recordfile, # string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | "replay-file=s" => \$replayfile, # string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | "verbose" => \$verbose, # flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | "h|help" => \$help, # flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | "man" => \$man, # flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ) or pod2usage(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 16 | ▶ | sub main() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
main: called CC=27 SCAR=39.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 16 | ▶ | pod2usage(-exitval => 0, -verbose => 1) if $help; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 15 | ▶ | pod2usage(-exitval => 0, -verbose => 2) if $man; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 14 | ▶ | if (defined($data) && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
defined $data and defined $remote || defined $recordfile || defined $replayfile
defined $remote or defined $recordfile or defined $replayfile
defined $remote or defined $recordfile
MC/DC0%0/4
defined $data and defined $remote || defined $recordfile || defined $replayfile
defined $data
defined $remote
defined $recordfile
defined $replayfile
Truth table40%2/5
A and B or C or D
A= defined $dataB= defined $remoteC= defined $recordfileD= defined $replayfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | defined($remote) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | || defined($recordfile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | || defined($replayfile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | die "E: --data cannot be used with --remote, --record, nor --replay\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 14 | ▶ | if (defined($replayfile) && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $replayfile and defined $remote || defined $recordfile
defined $remote or defined $recordfile
MC/DC0%0/3
defined $replayfile and defined $remote || defined $recordfile
defined $replayfile
defined $remote
defined $recordfile
Truth table50%2/4
A and B or C
A= defined $replayfileB= defined $remoteC= defined $recordfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | defined($remote) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | || defined($recordfile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | die "E: --replay cannot be used with --remote, nor --record\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 14 | ▶ | if (!$collect) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | require StorageDisplay or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | ▶ | die "Cannot load the StorageDisplay module to handle collected data: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 14 | my $infos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 14 | ▶ | if ($replayfile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | require StorageDisplay::Collect::CMD::Replay or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | ▶ | die "Replay requested, but unable to load the StorageDisplay::Collect::CMD::Replay module: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | my $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | ▶ | open($dh, "<", $replayfile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | or die "Cannot open '$replayfile': $!" ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | my $replay=join('', <$dh>); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | my $replaydata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 7 | close($dh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 7 | my $VAR1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | eval($replay); ## no critic (ProhibitStringyEval) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | #print STDERR "c: $content\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | $replaydata = $VAR1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 7 | $infos = StorageDisplay::Collect->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 'Replay', 'replay-data' => $replaydata)->collect(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 14 | my $contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | my @recorder; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 14 | ▶ | if (defined($recordfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | @recorder = ('Proxy::Recorder', 'recorder-reader'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 14 | ▶ | if (defined($data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 7 | my $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 7 | ▶ | open($dh, "<", $data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | or die "Cannot open '$data': $!" ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 7 | $contents=join('', <$dh>); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 7 | close($dh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } elsif (defined($remote)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $contents = collect_from_remote($remote, @recorder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } elsif (not defined($infos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $infos = StorageDisplay::Collect->new(@recorder, 'Local')->collect(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # data are in $contents (if got through Data::Dumper) or directly in $infos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 14 | ▶ | if (defined($contents)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # moving data from $contents to $infos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 7 | my $VAR1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 7 | eval($contents); ## no critic (ProhibitStringyEval) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | #print STDERR "c: $content\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 7 | $infos = $VAR1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 14 | ▶ | if (defined($recordfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if (! exists($infos->{'recorder'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | print STDERR "W: skpping recording: no records!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | open($dh, ">", $recordfile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | or die "Cannot open '$data': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | print $dh Dumper($infos->{'recorder'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | close($dh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 14 | delete($infos->{'recorder'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 14 | my $oldout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 14 | ▶ | if (defined($output)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # dzil do not want Two-argument "open" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # so, commented-out as we do not use it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # if this change, a way to write this would have to be found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # open(my $oldout, ">&STDOUT") or die "Can't dup STDOUT: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 14 | ▶ | open(STDOUT, '>', $output) or die "Can't redirect STDOUT to $output: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 14 | ▶ | if ($collect) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 7 | print Dumper($infos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 7 | my $st=StorageDisplay->new('infos' => $infos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 7 | $st->createElems(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 7 | $st->display; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 16 | main | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||