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>
This commit is contained in:
Azure SDK Bot 2021-12-07 12:52:30 -08:00 committed by GitHub
parent 68c7e28523
commit 2520b2b359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,7 @@
steps:
- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Write-FileSystemMetrics.ps1
pwsh: true
displayName: Write filesystem metrics
continueOnError: true

View File

@ -0,0 +1,31 @@
$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)"
}