# ·Î±× ÆÄÀÏ °æ·Î¸¦ ÀÔ·Â ¹Þ½À´Ï´Ù.
Param (
[String] $Path="C:\inetpub\logs\LogFiles\test_url\W3SVC2\u_ex110729.log"
)
# ÇÊ¿äÇÑ º¯¼öµéÀ» ¹Ì¸® ÁöÁ¤ ÇÕ´Ï´Ù.
[INT]$RECV_TOTAL="0"
[INT]$SEND_TOTAL="0"
[INT]$CS_NUM=0;
[INT]$SC_NUM=0;
$KB=1024
$MB=1024*1024
$GB=1024*1024*1024
get-content $Path | %{
#Pattern Check
if ( $_ | Select-String -Pattern "#Fields" ) {
# Fields °ª¿¡ ´ëÇÑ ¸¶À̳ʽº °ª ó¸®.
[INT]$CNT=-1;
foreach ($element in $_.Split(' '))
{
if ( $element -eq "sc-bytes" ){
$SC_NUM=$CNT;
}elseif ( $element -eq "cs-bytes" ) {
$CS_NUM=$CNT;
}
$CNT+=1;
}
}
elseif ( $_ | Select-String -Pattern "^[^#]" )
{
# ½ÇÁ¦ ¼Û/¼ö½ÅµÈ °ªÀ» Split ¸í·ÉÀ» ÅëÇØ ÀúÀåÇÕ´Ï´Ù.
[int]$SEND_BYTE=$_.Split(' ')[$SC_NUM];
[int]$RECV_BYTE=$_.Split(' ')[$CS_NUM];
[int]$RECV_TOTAL+=$RECV_BYTE;
[int]$SEND_TOTAL+=$SEND_BYTE;
}
}
If ( $RECV_TOTAL -gt $GB ){
$RECV_TOTAL = $RECV_TOTAL / $GB
Write-Host "Total In : $RECV_TOTAL GByte"
} elseif ( $RECV_TOTAL -gt $MB){
$RECV_TOTAL = $RECV_TOTAL / $MB
Write-Host "Total In : $RECV_TOTAL MByte"
}elseif ( $RECV_TOTAL -gt $KB){
$RECV_TOTAL = $RECV_TOTAL / $KB
Write-Host "Total In : $RECV_TOTAL KByte"
}else{
Write-Host "Total In : $RECV_TOTAL Byte"
}
If ( $SEND_TOTAL -gt $GB ){
$SEND_TOTAL = $SEND_TOTAL / $GB
Write-Host "Total Out : $SEND_TOTAL GByte"
} elseif ( $SEND_TOTAL -gt $MB){
$SEND_TOTAL = $SEND_TOTAL / $MB
Write-Host "Total Out : $SEND_TOTAL MByte"
}elseif ( $SEND_TOTAL -gt $KB){
$SEND_TOTAL = $SEND_TOTAL / $KB
Write-Host "Total Out : $SEND_TOTAL KByte"
}else{
Write-Host "Total Out : $SEND_TOTAL Byte"
}