#!/usr/local/bin/perl # # (C)2002 Hiroshi FJT # 2002.8.17 ver.1.0 # # 各種設定はここ # ディレクトリを指定 # 絶対ディレクトリか、CGIのあるディレクトリを起点にした相対ディレクトリで指定 $workdir = '..'; # ディスクの容量をKBで指定(1K=1024) $tdisksize = 125000; # ブロックサイズの指定 $blocksize = 1024; # ディレクトリ名を表示させたくない場合はコメントを外してリストを追加 # $workdirが絶対ならここも絶対、相対ならここも相対で #push(@inhdir,"."); $dirlist[0] = $workdir; $tfcount = 0; # total file count $tdcount = 0; # total dir count $tfsize = 0; # total file size $tdsize = 0; # total dir size $tfblock = 0; # total file block $tdblock = 0; # total dir block $i = 0; while($dirlist[$i]){ # kokode init splice(@tmplist, 0); $fcount = 0; # file count $dcount = 0; # dir count $fsize = 0; # file size $dsize = 0; # dir size $fblock = 0; # file block $dblock = 0; # dir block # opendir(DIR, $dirlist[$i]) or die "NG : $!"; if(opendir(DIR, $dirlist[$i])){ push(@tmplist, readdir(DIR)); # @tmplist = reverse(@tmplist); # @tmplist = sort(@tmplist); $n = 0; while($tmplist[$n]){ if(($tmplist[$n] ne '.') and ($tmplist[$n] ne '..')){ $tmpname = $dirlist[$i] . '/' . $tmplist[$n]; if(-d $tmpname and not -l $tmpname){ $dirname = $dirlist[$i] . '/' . $tmplist[$n]; splice(@dirlist, ($i+1), 0, $dirname); $dcount = $dcount + 1; $dsize = $dsize + (-s $tmpname); $dblock = $dblock + int((-s $tmpname)/$blocksize+0.99999); $tdcount = $tdcount +1; $tdsize = $tdsize + (-s $tmpname); $tdblock = $tdblock + int((-s $tmpname)/$blocksize+0.99999); }else{ $fcount = $fcount + 1; $fsize = $fsize + (-s $tmpname); $fblock = $fblock + int((-s $tmpname)/$blocksize+0.99999); $tfcount = $tfcount + 1; $tfsize = $tfsize + (-s $tmpname); $tfblock = $tfblock + int((-s $tmpname)/$blocksize+0.99999); } } $n = $n + 1; } $dfsize=$dsize+$fsize; $dfblock=$dblock+$fblock; if( $dfsize > 0 ){ $busage=int(($dfsize)/(($dfblock)*$blocksize)*1000+0.5)/10; $busage=sprintf("%3.1f",$busage); }else{ $busage="0.0"; } if( $tdisksize > 0 ){ $dusage=int(($dfblock)/($tdisksize)*1000+0.5)/10; $dusage=sprintf("%3.1f",$dusage); } push(@outlist,"$dirlist[$i] ". "
ディレクトリ名 | |||||||||
ディレクトリ数 | ". "ファイル数 | ". "ディレクトリ 使用量 | ".
"ファイル 使用量 | ".
"使用量 合計 | ".
"ディレクトリ ブロック数 | ".
"ファイル ブロック数 | ".
"ブロック 合計 | ".
"ブロック 有効率(\%) | ".
"ディスク 使用率(\%) |
$outlist[$i]\n"; $i = $i + 1; } print " | |||||||||
ディレクトリ名 | |||||||||
ディレクトリ数 | ". "ファイル数 | ". "ディレクトリ 使用量 | ".
"ファイル 使用量 | ".
"使用量 合計 | ".
"ディレクトリ ブロック数 | ".
"ファイル ブロック数 | ".
"ブロック 合計 | ".
"ブロック 有効率(\%) | ".
"ディスク 使用率(\%) |
total | |||||||||
$tdcount | ". "$tfcount | ". "$tdsize | ". "$tfsize | ". "$dfsize | ". "$tdblock | ". "$tfblock | ". "$dfblock | ". "$busage | ". "$dusage | ". "
free | |||||||||
". " | ". " | ". " | ". " | $dfree | ". "". " | ". " | $bfree | ". "". " | $usgfree |