azure-sdk-for-cpp/eng/common/scripts/Write-FileSystemMetrics.ps1
Azure SDK Bot 2520b2b359
Sync eng/common directory with azure-sdk-tools for PR 2381 (#3162)
* Add disk metrics script and template

* Support linux disk matrics

* Add continueOnError to write-filesystemmetrics.yml

Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
2021-12-07 12:52:30 -08:00

31 lines
1019 B
PowerShell

$drives = [IO.DriveInfo]::GetDrives() | Where-Object { $_.TotalSize -gt 0 -and $_.DriveType -eq 'Fixed' -and $null -ne $_.Name }
foreach($drive in $drives) {
$entry = [ordered]@{
"name"= "agent_driveinfo_size_bytes";
"value"= $drive.TotalSize;
"timestamp"= [DateTimeOffset]::UtcNow;
"labels"= [ordered]@{
"name"= $drive.Name;
"volumeLabel"= $drive.VolumeLabel;
"driveType"= $drive.DriveType.ToString();
"driveFormat"= $drive.DriveFormat;
}
}
Write-Output "logmetric: $($entry | ConvertTo-Json -Compress)"
$entry = [ordered]@{
"name"= "agent_driveinfo_available_bytes";
"value"= $drive.AvailableFreeSpace;
"timestamp"= [DateTimeOffset]::UtcNow;
"labels"= [ordered]@{
"name"= $drive.Name;
"volumeLabel"= $drive.VolumeLabel;
"driveType"= $drive.DriveType.ToString();
"driveFormat"= $drive.DriveFormat;
}
}
Write-Output "logmetric: $($entry | ConvertTo-Json -Compress)"
}