Success rate script - Now updated for new delete terminology since v1.29.3

The original successrate.ps1 script from @Alexey was having problems on my machine with high memory usage whilst running on larger log files. So I rewrote it slightly to read the log one line at a time, calculate all the variables as it goes and then print out at the end. It’s between 10% and 30% faster to run on my machine using an identical log file.

param(
    $Path = "C:\Program Files\Storj\Storage Node\storagenode - Copy.log"
)

$auditsSuccess=0
$auditsFailed=0
$auditsFailedCritical=0

$dl_success=0
$dl_canceled=0
$dl_failed=0

$put_success=0
$put_rejected=0
$put_canceled=0
$put_failed=0

$get_repair_success=0
$get_repair_canceled=0
$get_repair_failed=0

$put_repair_success=0
$put_repair_canceled=0
$put_repair_failed=0


[System.IO.File]::ReadLines($Path) | ForEach-Object {
if ($_ -match "GET_AUDIT" -And $_ -match "downloaded"){$auditsSuccess+=1}
if ($_ -match "GET_AUDIT" -And $_ -match "failed" -And $_ -notmatch "open"){$auditsFailed+=1}
if ($_ -match "GET_AUDIT" -And $_ -match "failed" -And $_ -match "open"){$auditsFailedCritical+=1}

if ($_ -match '"GET"' -And $_ -match "downloaded"){$dl_success+=1}
if ($_ -match '"GET"' -And $_ -match "canceled"){$dl_canceled+=1}
if ($_ -match '"GET"' -And $_ -match "failed"){$dl_failed+=1}

if ($_ -match '"PUT"' -And $_ -match "uploaded"){$put_success+=1}
if ($_ -match '"PUT"' -And $_ -match "rejected"){$put_rejected+=1}
if ($_ -match '"PUT"' -And $_ -match "canceled"){$put_canceled+=1}
if ($_ -match '"PUT"' -And $_ -match "failed"){$put_failed+=1}

if ($_ -match "GET_REPAIR" -And $_ -match "downloaded"){$get_repair_success+=1}
if ($_ -match "GET_REPAIR" -And $_ -match "canceled"){$get_repair_canceled+=1}
if ($_ -match "GET_REPAIR" -And $_ -match "failed"){$get_repair_failed+=1}

if ($_ -match "PUT_REPAIR" -And $_ -match "uploaded"){$put_repair_success+=1}
if ($_ -match "PUT_REPAIR" -And $_ -match "canceled"){$put_repair_canceled+=1}
if ($_ -match "PUT_REPAIR" -And $_ -match "failed"){$put_repair_failed+=1}
}

Write-Host "========== AUDIT ============="  -ForegroundColor Cyan

if (($auditsSuccess + $auditsFailed + $auditsFailedCritical) -ge 1) {
    $audits_failed_ratio = $auditsFailed / ($auditsSuccess + $auditsFailed + $auditsFailedCritical) * 100
    $audits_critical_ratio = $auditsFailedCritical / ($auditsSuccess + $auditsFailed + $auditsFailedCritical) * 100
    $audits_success_ratio = $auditsSuccess / ($auditsSuccess + $auditsFailed + $auditsFailedCritical) * 100
} else {
    $audits_failed_ratio = 0.00
    $audits_critical_ratio = 0.00
    $audits_success_ratio = 0.00
}

Write-Host ("Critically failed:`t" + $auditsFailedCritical) -ForegroundColor Red
Write-Host ("Critical Fail Rate:`t{0:N}%" -f $audits_critical_ratio)
Write-Host ("Recoverable failed:`t" + $auditsFailed) -ForegroundColor Yellow
Write-Host ("Recoverable Fail Rate:`t{0:N}%" -f $audits_failed_ratio)
Write-Host ("Successful:`t`t" + $auditsSuccess) -ForegroundColor Green
Write-Host ("Success Rate:`t`t{0:N}%" -f $audits_success_ratio)

Write-Host "========== DOWNLOAD =========="  -ForegroundColor Cyan


if (($dl_success + $dl_failed + $dl_canceled) -ge 1) {
    $dl_failed_ratio = $dl_failed / ($dl_success + $dl_failed + $dl_canceled) * 100
    $dl_canceled_ratio = $dl_canceled / ($dl_success + $dl_failed + $dl_canceled) * 100
    $dl_ratio = $dl_success / ($dl_success + $dl_failed + $dl_canceled) * 100
} else {
    $dl_failed_ratio = 0.00
    $dl_canceled_ratio = 0.00
    $dl_ratio = 0.00
}

Write-Host ("Failed:`t`t`t" + $dl_failed) -ForegroundColor Red
Write-Host ("Fail Rate:`t`t{0:N}%" -f $dl_failed_ratio)
Write-Host ("Canceled:`t`t" + $dl_canceled) -ForegroundColor Yellow
Write-Host ("Cancel Rate:`t`t{0:N}%" -f $dl_canceled_ratio)
Write-Host ("Successful:`t`t" + $dl_success) -ForegroundColor Green
Write-Host ("Success Rate:`t`t{0:N}%" -f $dl_ratio)

Write-Host "========== UPLOAD ============"  -ForegroundColor Cyan


if (($put_success + $put_rejected + $put_failed + $put_canceled) -ge 1) {
    $put_failed_ratio = $put_failed / ($put_success + $put_rejected + $put_failed + $put_canceled) * 100
    $put_canceled_ratio = $put_canceled / ($put_success + $put_rejected + $put_failed + $put_canceled) * 100
    $put_accept_ratio = ($put_success + $put_canceled + $put_failed) / ($put_success + $put_rejected + $put_failed + $put_canceled) * 100
    $put_ratio = $put_success / ($put_success + $put_rejected + $put_failed + $put_canceled) * 100
} else {
    $put_failed_ratio = 0.00
    $put_canceled_ratio = 0.00
    $put_accept_ratio = 0.00
    $put_ratio = 0.00
}

Write-Host ("Rejected:`t`t" + $put_rejected)
Write-Host ("Acceptance Rate:`t{0:N}%" -f $put_accept_ratio)
"---------- accepted ----------"
Write-Host ("Failed:`t`t`t" + $put_failed) -ForegroundColor Red
Write-Host ("Fail Rate:`t`t{0:N}%" -f $put_failed_ratio)
Write-Host ("Canceled:`t`t" + $put_canceled) -ForegroundColor Yellow
Write-Host ("Cancel Rate:`t`t{0:N}%" -f $put_canceled_ratio)
Write-Host ("Successful:`t`t" + $put_success) -ForegroundColor Green
Write-Host ("Success Rate:`t`t{0:N}%" -f $put_ratio)

Write-Host "========== REPAIR DOWNLOAD ==="  -ForegroundColor Cyan

if (($get_repair_success + $get_repair_failed + $get_repair_canceled) -ge 1) {
    $get_repair_failed_ratio = $get_repair_failed / ($get_repair_success + $get_repair_failed + $get_repair_canceled) * 100
    $get_repair_canceled_ratio = $get_repair_canceled / ($get_repair_success + $get_repair_failed + $get_repair_canceled) * 100
    $get_repair_ratio = $get_repair_success / ($get_repair_success + $get_repair_failed + $get_repair_canceled) * 100
} else {
    $get_repair_failed_ratio = 0.00
    $get_repair_canceled_ratio = 0.00
    $get_repair_ratio = 0.00
}

Write-Host ("Failed:`t`t`t" + $get_repair_failed) -ForegroundColor Red
Write-Host ("Fail Rate:`t`t{0:N}%" -f $get_repair_failed_ratio)
Write-Host ("Canceled:`t`t" + $get_repair_canceled) -ForegroundColor Yellow
Write-Host ("Cancel Rate:`t`t{0:N}%" -f $get_repair_canceled_ratio)
Write-Host ("Successful:`t`t" + $get_repair_success) -ForegroundColor Green
Write-Host ("Success Rate:`t`t{0:N}%" -f $get_repair_ratio)

Write-Host "========== REPAIR UPLOAD ====="  -ForegroundColor Cyan


if (($put_repair_success + $put_repair_failed + $put_repair_canceled) -ge 1) {
    $put_repair_failed_ratio = $put_repair_failed / ($put_repair_success + $put_repair_failed + $put_repair_canceled) * 100
    $put_repair_canceled_ratio = $put_repair_canceled / ($put_repair_success + $put_repair_failed + $put_repair_canceled) * 100
    $put_repair_ratio = $put_repair_success / ($put_repair_success + $put_repair_failed + $put_repair_canceled) * 100
} else {
    $put_repair_failed_ratio = 0.00
    $put_repair_canceled_ratio = 0.00
    $put_repair_ratio = 0.00
}

Write-Host ("Failed:`t`t`t" + $put_repair_failed) -ForegroundColor Red
Write-Host ("Fail Rate:`t`t{0:N}%" -f $put_repair_failed_ratio)
Write-Host ("Canceled:`t`t" + $put_repair_canceled) -ForegroundColor Yellow
Write-Host ("Cancel Rate:`t`t{0:N}%" -f $put_repair_canceled_ratio)
Write-Host ("Successful:`t`t" + $put_repair_success) -ForegroundColor Green
Write-Host ("Success Rate:`t`t{0:N}%" -f $put_repair_ratio)
4 Likes