banshee est en développement actif : les collecteurs vont encore changer, et une version que vous publiez demandera sans doute des ajustements. Pour un usage stable, attendez la version 1.0.0.

Windows

banshee/windows-collection/windows/winrm/

volumes

The space of each local volume of a Windows, and when it will be full, by WinRM and PowerShell

  • windows
  • winrm
  • powershell
  • volumes
  • disk

par banshee1 installation2 versions

v2Dernière

Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.

Keen 1.0.0 · 51 lignes
// The space of each local volume of a Windows, by WinRM: those with a drive letter and those mounted in a
// folder. Network, removable and optical drives are not among them. An expected volume that disappears
// shows through the watch "Volume missing".
// Runs one PowerShell script that only reads Win32_Volume, the volumes of the type "local disk"
// (DriveType 3) that are formatted (a Capacity): Name ("C:\", or the folder of a mount point), Capacity and
// FreeSpace in bytes. The activity of the disks is the collector windows/winrm/diskio.
// The script is the one of windows/ssh/volumes, without the powershell -Command "..." that cmd.exe needs
// there.
need('protocol:winrm');

per('volume', 'Volumes');
output('used-percent', 'number', array('label' => 'Used space', 'unit' => '%', 'per' => 'volume'));
output('used', 'number', array('label' => 'Used space', 'unit' => 'GiB', 'per' => 'volume'));
output('free', 'number', array('label' => 'Free space', 'unit' => 'GiB', 'per' => 'volume'));
output('size', 'number', array('label' => 'Size', 'unit' => 'GiB', 'per' => 'volume'));

watch.above('used', 'Used space', 'used-percent', array('warning' => 80, 'critical' => 90));
watch.above('full-soon', 'Full within a week', 'used-percent', array('warning' => 99, 'ahead' => '7 d'));
watch.below('free', 'Little free space', 'free', array('critical' => 5, 'enabled' => false));
watch.missing('missing', 'Volume missing', 'used-percent', array('enabled' => false));

// A mount point may hold a name outside ASCII: the output is written in UTF-8, without the byte order mark
// that the default UTF-8 encoding of .NET would put first.
$read = winrm.run("[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding; "
    . "ConvertTo-Json -Compress -InputObject @(Get-CimInstance Win32_Volume -Filter 'DriveType=3'"
    . " | Where-Object Capacity | Select-Object Name, Capacity, FreeSpace)");
$answer = text.trim($read['output']);
if (list.count(text.match($answer, '^\[')) == 0) {
    fail('misconfigured', 'PowerShell did not return the volumes', $answer . $read['errors']);
}

$volumes = 0;
foreach (json.read($answer) as $volume) {
    // A volume without a letter or a folder is named "\\?\Volume{...}\": a recovery or system partition,
    // which no one fills.
    if (text.like($volume['Name'], '\\\\?\\*')) {
        continue;
    }
    $volumes = $volumes + 1;
    $total = $volume['Capacity'] / 1073741824;
    $free = $volume['FreeSpace'] / 1073741824;
    value('size', number.round($total, 1), $volume['Name']);
    value('used', number.round($total - $free, 1), $volume['Name']);
    value('free', number.round($free, 1), $volume['Name']);
    value('used-percent', number.round(100 * ($total - $free) / $total, 1), $volume['Name']);
}

// A Windows always has at least its system volume: returning none would be a green light on nothing.
if ($volumes == 0) {
    fail('misconfigured', 'No local volume found in Win32_Volume', $answer);
}