@@ -107,7 +107,9 @@ function Get-sqmServerHardwareReport
107107
108108 if (-not $PSBoundParameters.ContainsKey (' ReportPath' ) -or [string ]::IsNullOrWhiteSpace($ReportPath ))
109109 {
110- $ReportPath = Join-Path $env: ProgramData ' sqmSQLTool\HardwareReports'
110+ $configOutput = Get-sqmConfig - Key ' OutputPath'
111+ $ReportPath = if ($configOutput ) { Join-Path $configOutput ' HardwareReports' }
112+ else { Join-Path $env: ProgramData ' sqmSQLTool\HardwareReports' }
111113 }
112114
113115 if (-not (Test-Path $ReportPath ))
@@ -538,31 +540,47 @@ function _Build-sqmHardwareReportHtml
538540 # -------------------------------------------------------------------------
539541 # ABSCHNITT: Logische Laufwerke
540542 # -------------------------------------------------------------------------
543+ $diskThreshold = [int ](Get-sqmConfig - Key ' DiskFreeSpaceThresholdPct' )
544+ $diskThresholdRatio = $diskThreshold / 100.0
545+
541546 $logHtml = " <table class='itbl'><thead><tr>" +
542547 " <th>Laufwerk</th><th>Label</th><th>Dateisystem</th>" +
543- " <th>Gesamt</th><th>Belegt</th><th>Frei</th><th>Auslastung</th>" +
548+ " <th>Gesamt</th><th>Belegt</th><th>Frei</th><th>Auslastung</th><th>Erweiterung</th> " +
544549 " </tr></thead><tbody>"
545550
546551 foreach ($ld in ($d.LogicalDisks | Sort-Object DeviceID))
547552 {
548- $ldTotal = if ($ld.Size ) { _Size ([double ]$ld.Size ) } else { ' n/a' }
549- $ldFree = if ($ld.FreeSpace ) { _Size ([double ]$ld.FreeSpace ) } else { ' n/a' }
550- $ldUsed = if ($ld.Size -and $ld.FreeSpace ) { _Size ([double ]($ld.Size - $ld.FreeSpace )) } else { ' n/a' }
551- $pctUsed = if ($ld.Size -gt 0 ) { [int ](([double ]($ld.Size - $ld.FreeSpace ) / [double ]$ld.Size ) * 100 ) } else { 0 }
553+ $ldTotalBytes = if ($ld.Size ) { [double ]$ld.Size } else { 0 }
554+ $ldFreeBytes = if ($ld.FreeSpace ) { [double ]$ld.FreeSpace } else { 0 }
555+ $ldTotal = if ($ldTotalBytes -gt 0 ) { _Size $ldTotalBytes } else { ' n/a' }
556+ $ldFree = if ($ldFreeBytes -gt 0 ) { _Size $ldFreeBytes } else { ' n/a' }
557+ $ldUsed = if ($ldTotalBytes -gt 0 ) { _Size ($ldTotalBytes - $ldFreeBytes ) } else { ' n/a' }
558+ $pctUsed = if ($ldTotalBytes -gt 0 ) { [int ](($ldTotalBytes - $ldFreeBytes ) / $ldTotalBytes * 100 ) } else { 0 }
552559 $pctFree = 100 - $pctUsed
553- $barColor = if ($pctFree -lt 10 ) { ' #e74c3c' } elseif ($pctUsed -ge 90 ) { ' #e74c3c' } elseif ($pctUsed -ge 75 ) { ' #f39c12' } else { ' #27ae60' }
560+ $isCritical = $pctFree -lt $diskThreshold
561+ $barColor = if ($isCritical ) { ' #e74c3c' } elseif ($pctUsed -ge 90 ) { ' #e74c3c' } elseif ($pctUsed -ge 75 ) { ' #f39c12' } else { ' #27ae60' }
554562 $bar = " <div class='dbar'><div class='dfill' style='width:{0}%;background:{1}'></div></div><span class='dpct'>{0}%</span>" -f $pctUsed , $barColor
555563 $drive = if ($ld.DeviceID ) { " $ ( $ld.DeviceID ) \" } else { ' n/a' }
556564 $fs = if ($ld.FileSystem ) { [string ]$ld.FileSystem } else { ' n/a' }
557565 $volName = if ($ld.VolumeName ) { [string ]$ld.VolumeName } else { ' ' }
558- $warningFlag = if ($pctFree -lt 10 ) { " ⚠️ KRITISCH" } else { ' ' }
566+ $warningFlag = if ($isCritical ) { " ⚠ KRITISCH" } else { ' ' }
567+
568+ # Erweiterungsberechnung: (t*Total - Free) / (1-t) auf naechstes GB aufrunden
569+ $extendCell = if ($isCritical -and $ldTotalBytes -gt 0 ) {
570+ $totalGB = $ldTotalBytes / 1 GB
571+ $freeGB = $ldFreeBytes / 1 GB
572+ $extGB = [math ]::Ceiling(($diskThresholdRatio * $totalGB - $freeGB ) / (1 - $diskThresholdRatio ))
573+ " <span style='color:#e74c3c;font-weight:700'>+${extGB} GB</span>"
574+ } else {
575+ " <span style='color:#27ae60'>✓ OK</span>"
576+ }
559577
560578 $logHtml += " <tr><td><strong>$ ( _H $drive ) </strong></td><td>$ ( _H $volName ) </td><td>$ ( _H $fs ) </td>" +
561- " <td>$ ( _H $ldTotal ) </td><td>$ ( _H $ldUsed ) </td><td>$ ( _H $ldFree ) </td><td>$bar$warningFlag </td></tr>"
579+ " <td>$ ( _H $ldTotal ) </td><td>$ ( _H $ldUsed ) </td><td>$ ( _H $ldFree ) </td><td>$bar$warningFlag </td><td> $extendCell </td>< /tr>"
562580 }
563581 if ($d.LogicalDisks.Count -eq 0 )
564582 {
565- $logHtml += ' <tr><td colspan="7 " class="norow">Keine lokalen Laufwerke gefunden</td></tr>'
583+ $logHtml += ' <tr><td colspan="8 " class="norow">Keine lokalen Laufwerke gefunden</td></tr>'
566584 }
567585 $logHtml += ' </tbody></table>'
568586
@@ -940,19 +958,28 @@ function _Build-sqmHardwareReportTxt
940958 }
941959 }
942960
943- # Detaillierte Logical Disk-Infos mit < 10% Warnung
961+ # Detaillierte Logical Disk-Infos mit Schwellwert-Warnung und Erweiterungsberechnung
962+ $txtThreshold = [int ](Get-sqmConfig - Key ' DiskFreeSpaceThresholdPct' )
963+ $txtThresholdRatio = $txtThreshold / 100.0
944964 if ($Data.LogicalDisks.Count -gt 0 )
945965 {
946966 $lines += " "
947- $lines += " [LOGISCHE LAUFWERKE]"
967+ $lines += " [LOGISCHE LAUFWERKE] (Schwellwert: $txtThreshold % frei) "
948968 foreach ($ld in ($Data.LogicalDisks | Sort-Object DeviceID))
949969 {
950970 $drive = if ($ld.DeviceID ) { " $ ( $ld.DeviceID ) \" } else { ' n/a' }
951- $total = if ($ld.Size ) { ' {0:N0}' -f ([double ]$ld.Size / 1 GB ) + ' GB' } else { ' n/a' }
952- $free = if ($ld.FreeSpace ) { ' {0:N0}' -f ([double ]$ld.FreeSpace / 1 GB ) + ' GB' } else { ' n/a' }
953- $pctFree = if ($ld.Size -gt 0 ) { [int ](([double ]$ld.FreeSpace / [double ]$ld.Size ) * 100 ) } else { 0 }
954- $warning = if ($pctFree -lt 10 ) { " [!!! KRITISCH !!!]" } else { ' ' }
955- $lines += " $drive $total Gesamt, $free Frei ($pctFree % frei)$warning "
971+ $totalGB = if ($ld.Size ) { [double ]$ld.Size / 1 GB } else { 0 }
972+ $freeGB = if ($ld.FreeSpace ) { [double ]$ld.FreeSpace / 1 GB } else { 0 }
973+ $total = ' {0:N0}' -f $totalGB + ' GB'
974+ $free = ' {0:N0}' -f $freeGB + ' GB'
975+ $pctFree = if ($ld.Size -gt 0 ) { [int ](($freeGB / $totalGB ) * 100 ) } else { 0 }
976+ $extMsg = ' '
977+ if ($pctFree -lt $txtThreshold -and $totalGB -gt 0 )
978+ {
979+ $extGB = [math ]::Ceiling(($txtThresholdRatio * $totalGB - $freeGB ) / (1 - $txtThresholdRatio ))
980+ $extMsg = " [!!! KRITISCH !!! Erweiterung um +$extGB GB noetig]"
981+ }
982+ $lines += " $drive $total Gesamt, $free Frei ($pctFree % frei)$extMsg "
956983 }
957984 }
958985
0 commit comments