Windows
banshee/windows-collection/windows/ssh/
memory
The physical memory of a Windows, available and used, by SSH and PowerShell
par banshee1 installation2 versions
v2Dernière
Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.
// The physical memory of a Windows, by SSH: the memory Windows says is available, which counts the standby
// cache it gives back on demand; used memory is the rest, as Task Manager shows it. The paging file is the
// collector windows/ssh/pagefile.
// Runs one PowerShell command that only reads Win32_OperatingSystem: TotalVisibleMemorySize and
// FreePhysicalMemory, in KiB.
need('protocol:ssh');
output('total', 'number', array('label' => 'Physical memory', 'unit' => 'MiB'));
output('used', 'number', array('label' => 'Used memory', 'unit' => 'MiB'));
output('available', 'number', array('label' => 'Available memory', 'unit' => 'MiB'));
output('used-percent', 'number', array('label' => 'Used memory', 'unit' => '%'));
watch.above('memory-high', 'Memory saturated', 'used-percent', array('warning' => 90, 'critical' => 95, 'for' => '3 runs'));
watch.below('available', 'Little memory available', 'available', array('critical' => 512, 'enabled' => false));
$read = ssh.run("powershell -NoProfile -NonInteractive -Command \""
. "Get-CimInstance Win32_OperatingSystem | Select-Object TotalVisibleMemorySize, FreePhysicalMemory"
. " | ConvertTo-Json -Compress\"");
$answer = text.trim($read['output']);
if (list.count(text.match($answer, '^\{')) == 0) {
fail('misconfigured', 'PowerShell did not return Win32_OperatingSystem', $answer . $read['errors']);
}
$os = json.read($answer);
if ($os['TotalVisibleMemorySize'] <= 0) {
fail('misconfigured', 'Win32_OperatingSystem gives no physical memory', $answer);
}
$total = $os['TotalVisibleMemorySize'] / 1024;
$available = $os['FreePhysicalMemory'] / 1024;
value('total', number.round($total));
value('available', number.round($available));
value('used', number.round($total - $available));
value('used-percent', number.round(100 * ($total - $available) / $total, 1));