Fleet’s built-in queries for collecting and storing important device information.
Apple
Linux
Windows
ChromeOS
Disk space
Retrieves total amount of free disk space on a Windows host.
SELECT
ROUND((sum(free_space) * 100 * 10e-10) / (sum(size) * 10e-10)) AS percent_disk_space_available,
ROUND(sum(free_space) * 10e-10) AS gigs_disk_space_available,
ROUND(sum(size) * 10e-10) AS gigs_total_disk_space
FROM logical_drives
WHERE file_system = 'NTFS' LIMIT 1
$drives = Get-CimInstance Win32_LogicalDisk | Where-Object { $_.FileSystem -eq 'NTFS' }
if (!$drives) {
Write-Output "No NTFS drives found."
exit
}
$totalFreeSpace = ($drives | Measure-Object -Property FreeSpace -Sum).Sum
$totalSize = ($drives | Measure-Object -Property Size -Sum).Sum
$percentDiskAvailable = [math]::Round(($totalFreeSpace / $totalSize) * 100, 0)
$gigsDiskAvailable = [math]::Round($totalFreeSpace * 1e-9, 0)
$gigsTotal = [math]::Round($totalSize * 1e-9, 0)
Write-Output "percent_disk_space_available: $percentDiskAvailable"
Write-Output "gigs_disk_space_available: $gigsDiskAvailable"
Write-Output "gigs_total_disk_space: $gigsTotal"
PowerShell commands are currently work in progress, contributions welcome.
Vitals