Simple local check - subdirectory size logger

Hope it is the right place to let this here…
If you like to draw size summary graphs for subfolders of a folder in Windows
Powershell to place in C:\ProgramData\checkmk\agent\local - and change it accordingly :wink:

$targetfolder='----yourfolder----'
#For Plugin
#Write-Host "<<<localcheck_win_dirsize>>>"
$dataColl = @()
gci -force $targetfolder -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
#name with path
#$foldername = $_.fullname
#shortname
$foldername = $_.name
$foldersize= '{0:N2}' -f ($len / 1Mb)
$dataObject = New-Object PSObject
Add-Member -inputObject $dataObject -memberType NoteProperty -name “foldername” -value $foldername
Add-Member -inputObject $dataObject -memberType NoteProperty -name “foldersizeMb” -value $foldersize
$dataColl += $dataObject
$metric += "$foldername=$foldersize|"
#Write-Host $metric
}
#$dataColl | Out-GridView -Title “Size of subdirectories”
#$dataColl
Write-Host "0" """----yourfolder----""" $metric.Substring(0,$metric.Length-1) "Sizes of Subfolders"