public/Get-UnraidMetrics.ps1
|
function Get-UnraidMetrics { <# .SYNOPSIS Gets current CPU, RAM, and swap metrics. .PARAMETER Session Unraid session (defaults to current session). .EXAMPLE Get-UnraidMetrics #> [CmdletBinding()] [OutputType("UnraidMetrics")] param( [Parameter()] [UnraidSession]$Session = $script:DefaultUnraidSession ) process { $gqlQuery = @" query SystemMetrics { metrics { cpu { percentTotal } memory { total used free buffcache active available percentTotal swapTotal swapUsed swapFree percentSwapTotal } } } "@ $result = Invoke-UnraidQuery -Query $gqlQuery -Session $Session if ($result.metrics) { return [UnraidMetrics]::new($result) } } } |