| 1 | package HPUX::FS; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | #use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # This allows declaration use HPUX::FS ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # will save memory. | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | our $VERSION = '1.03'; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ### start | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use Storable; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=51 SCAR=71.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my $debug=0; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | my $debug2=0; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my ($class, @subargs) = @_ ; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my %arglist = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | target_type => "local" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | persistance => "new" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | datafile => "/tmp/fsinfo.dat", | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | access_prog => "ssh -1" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | access_system => "localhost" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | access_user => "root" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | remote_command1 => 'cat /etc/fstab', | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | remote_command2 => '/usr/sbin/mount -p', | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | remote_command3 => 'bdf', | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | @subargs, | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | if ($debug) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | print "target_type : $arglist{target_type}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | print "persistance : $arglist{persistance}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | print "datafile : $arglist{datafile}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | print "access_prog : $arglist{access_prog}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | print "access_system: $arglist{access_system}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | print "access_user : $arglist{access_user}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | print "remote_command1: $arglist{remote_command1}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | print "remote_command2: $arglist{remote_command2}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | print "remote_command3: $arglist{remote_command3}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my $source_access =$arglist{target_type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | my $new_or_saved =$arglist{persistance}; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $datafile =$arglist{datafile}; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my $remote_access =$arglist{access_prog}; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my $remote_system =$arglist{access_system}; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $remote_user =$arglist{access_user}; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | my $remote_command1 =$arglist{remote_command1}; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my $remote_command2 =$arglist{remote_command2}; | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my $remote_command3 =$arglist{remote_command3}; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my $line; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | my $fsinfo_ref; | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | my @commands_out; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my @first_command; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my @second_command; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | my @third_command; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | my $first_command=""; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | my $second_command=""; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my $third_command=""; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my %filesys_hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | my $filesys_hash = \%filesys_hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | my $fstab_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | my @split_fstab_line; | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my $fstab_line_mnt; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my @split_fstab_line_mnt; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | my @infstab; #filesystems in fstab | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | my %seen; #Used when comparing arrays of fstab and mounted fs's | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | my @notfstab; #see above | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | my $item; #foreach variable in comparison | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my @mounted_fs; #figure it out | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my $remote_fs; # this block used in bdf parsing | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | my @remote_fs_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | my $fixflag="no"; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | my $remote_fs_save; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | my $filesys; | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | my $kilo_used; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | my $kilo_total; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | my $kilo_avail; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my $percent_full; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my $mountpoint; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # Check for persistance request | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | print "checking persistance now\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | if ($arglist{persistance} eq "old") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | print "retrieving a copy from prosperity...\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | $filesys_hash = Storable::retrieve $datafile | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | or die "unable to retrieve hash data in /tmp\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | return bless($filesys_hash, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | print "Executing remote command now\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # do all 3 commands and parse them out on this side to minimize net connect overhead | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | @commands_out=`$remote_access $remote_system -l $remote_user -n "echo My$remote_command1;$remote_command1;echo My$remote_command2;$remote_command2;echo My$remote_command3;$remote_command3"` | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | or die "Unable to execute remote commands: $@\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | print "got past remote command\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | foreach $line (@commands_out) { | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( $line =~ /My$remote_command1/ ){$first_command="yes"}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( $line =~ /My$remote_command2/ ){$first_command="no";$second_command="yes"}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ( $line =~ /My$remote_command3/ ){$first_command="no" ; $second_command="no"; $third_command="yes"}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ($first_command eq "yes") { push @first_command, $line }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ($second_command eq "yes") { push @second_command, $line }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($third_command eq "yes") { push @third_command, $line }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | print "First_command : @first_command\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | print "Second_command: @second_command\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | print "Third_command : @third_command\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # check fs's in fstab | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | FSTAB_LOOP: foreach $fstab_line (@first_command) { | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($fstab_line =~ /^#/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | next FSTAB_LOOP; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ($fstab_line !~ /^\/dev/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | next FSTAB_LOOP; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | @split_fstab_line = split /\s+/, $fstab_line; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $filesys_hash{$split_fstab_line[0]} = { | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | directory => $split_fstab_line[1], | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | type => $split_fstab_line[2], | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | options => $split_fstab_line[3], | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | backup_freq => $split_fstab_line[4-5], | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | kbytes => "NA", | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | kbytes_used => "NA", | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | kbytes_avail => "NA", | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | percent_used => "NA", | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | mounted => "yes", | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | fstab => "yes", | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | capture_date => scalar(localtime) | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Check mounted fs's | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | MOUNT_LOOP: foreach $fstab_line_mnt (@second_command) { | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ($fstab_line_mnt =~ /^#/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | next MOUNT_LOOP; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ($fstab_line_mnt !~ /^\/dev/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | next MOUNT_LOOP; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | @split_fstab_line_mnt = split /\s+/, $fstab_line_mnt; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | push @mounted_fs, $split_fstab_line_mnt[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Compare mounted to not mounted but in fstab | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # Array compare starts | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | %seen = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | @notfstab = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | @infstab = ( sort keys %{ $filesys_hash } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | print "infstab: @infstab\<\<\-End\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | print "mounted: @mounted_fs\<\<\-End\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | foreach $item ( @infstab ) { print "item: $item\n" if $debug ; $seen{$item} = 1 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | foreach $item ( @mounted_fs ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | push(@notfstab, $item) unless exists $seen{$item}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | foreach $item (@notfstab) { | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | print "Filesystem not mounted: $item\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $filesys_hash{mounted}="no"; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Check bdf stats | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | foreach $remote_fs ( @third_command ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | @remote_fs_line = split /\s+/, $remote_fs; | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | print "remote_fs_line has $#remote_fs_line entries\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | print "filesys1: $remote_fs_line[0]\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( $remote_fs =~ /^\// || $#remote_fs_line == 5 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$remote_fs =~ m[^/] or $#remote_fs_line == 5
MC/DC0%0/2
$remote_fs =~ m[^/] or $#remote_fs_line == 5
$remote_fs =~ m[^/]
$#remote_fs_line == 5
Truth table0%0/3
A or B
A= $remote_fs =~ m[^/]B= $#remote_fs_line == 5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | print length($remote_fs_line[0]),"\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($fixflag eq "yes") { shift @remote_fs_line ; unshift @remote_fs_line, $remote_fs_save ; $fixflag="no"; print "Fixflag found\n" if $debug} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( length($remote_fs_line[0]) > 18 and $fixflag eq "no" and $#remote_fs_line !=5 ) { $remote_fs_save = $remote_fs_line[0]; $fixflag="yes"; print "Marked fixflag" if $debug; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
length $remote_fs_line[0] > 18 and $fixflag eq "no" and $#remote_fs_line != 5
length $remote_fs_line[0] > 18 and $fixflag eq "no"
MC/DC0%0/3
length $remote_fs_line[0] > 18 and $fixflag eq "no" and $#remote_fs_line != 5
length $remote_fs_line[0] > 18
$fixflag eq "no"
$#remote_fs_line != 5
Truth table0%0/4
A and B and C
A= length $remote_fs_line[0] > 18B= $fixflag eq "no"C= $#remote_fs_line != 5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $filesys = $remote_fs_line[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | chop $remote_fs_line[4]; | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | print "filesys: $filesys\<\<\-\-\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $kilo_total = $remote_fs_line[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $kilo_used = $remote_fs_line[2]; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $kilo_avail = $remote_fs_line[3]; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $percent_full = $remote_fs_line[4]; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $mountpoint = $remote_fs_line[5]; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | print "$remote_fs $kilo_total $kilo_used $kilo_avail $percent_full $mountpoint\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $filesys_hash{$filesys}->{kbytes}=$kilo_total; | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $filesys_hash{$filesys}->{kbytes_used}=$kilo_used; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $filesys_hash{$filesys}->{kbytes_avail}=$kilo_avail; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $filesys_hash{$filesys}->{percent_used}=$percent_full; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | print "skipping $remote_fs due to non match\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ( $new_or_saved eq "new" ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | print "saving a copy for prosperity...\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | Storable::nstore \%filesys_hash, $datafile | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | or die "unable to store hash data in /tmp\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | return bless($filesys_hash, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | # now hash it all and preserve it if requested | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub traverse { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
traverse: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $debug=1; | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | print "I am self: $self\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $item; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | my $mainkey; | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $subkey; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | foreach $item ( sort keys %{ $self } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | print "Main Key: $item\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | foreach $subkey ( keys %{ $self->{$item} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | print "subkey: $subkey Value: $self->{$item}->{$subkey}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | sub get_all_filesystems { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_filesystems: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # returns an array ref of all the keys (filesystems) | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | my $debug=0; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | my $item; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | my @filesystems; | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | foreach $item ( sort keys %{ $self } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | push @filesystems, $item; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | return \@filesystems; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | ▶ | sub get_filesystem_attr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_filesystem_attr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 5 | my ($self, @subargs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | my %arglist = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | filesystem => "" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | attribute => "" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | @subargs, | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | my $debug=0; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 5 | my $attribute; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | my $attr =$arglist{attribute}; | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | my $item =$arglist{filesystem}; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | 5 | $attribute = $self->{$item}->{$attr}; | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | return $attribute; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ### end | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||