0byt3m1n1
Path:
/
data
/
16
/
inventory
/
[
Home
]
File: vuxinv.pl
#!/usr/local/bin/perl $file = $ARGV[0]; chomp($file); $filesection = $file; open LIST, "<${file}"; #$file =~ s/\.txt//; @FILEPARTS = (split /\// ,$file); $file = pop(@FILEPARTS); #The -Domains.txt files contains the results. open OUTPUT, ">/data/16/inventory/done/Inventory/${file}-Domains.txt"; #The -Status.txt files contain lists of those paths already inventoried or in progress open STATUS, ">/data/16/inventory/done/Inventory/${file}-Status.txt"; $voltot = 0; $file_tot = 0; while (<LIST>) { $domsize = 0; $file_cnt = 0; $line = $_; chomp($line); ($dom, $sites, $domroot) = split /\;/ ,$line,3; $vol = (split /\// ,$domroot)[2]; $domsize = cleansize((split /\s+/, (`du -sh $domroot`)) [0]); #$file_cnt = (split /\s+/, (`find ./ | wc -l`))[0]; $file_cnt = ((split /\s+/, (`find $domroot | wc -l`))[0]); #Flag directories with "high" numbers of items print STATUS "HIGH count of $file_cnt in $domroot\n" if ($file_cnt > 25000); chomp($file_cnt); $voltot = $voltot + $domsize; $file_tot = $file_tot + $file_cnt; print OUTPUT "$vol\;$dom\;$sites\;$file_cnt\;$domsize\n"; } print STATUS "Total of ${voltot}MB and $file_tot files found in $filesection\n"; sub cleansize { $size = $_[0]; if ($size =~ /M$/) { $size =~ s/M//; } elsif ($size =~ /K$/) { $size =~ s/K//; $size = sprintf("%.2f", $size/1024); } elsif ($size =~ /G$/) { $size =~ s/G//; $size = $size *1024;} return $size; }