Public/metrics.ps1
|
# Metrics: the list commands that return capacity and performance figures # (CPU, memory, storage, IOPS, and so on) alongside the usual inventory fields. function Get-CSZoneMetric { <# .SYNOPSIS Lists zones with their aggregated capacity metrics. .DESCRIPTION Wraps listZonesMetrics: the same rows as Get-CSZone plus rolled-up CPU, memory, and storage usage and their configured thresholds. .PARAMETER Id Filter by zone ID .PARAMETER Name Filter by zone name .PARAMETER Keyword Filter by keyword .PARAMETER Page Page number of results to return .PARAMETER PageSize Number of results per page .EXAMPLE Get-CSZoneMetric | Select-Object name, cpuused, memoryused, storageused Shows each zone's rolled-up usage. .EXAMPLE Get-CSZoneMetric -Id $zoneId Gets metrics for one zone. #> [CmdletBinding()] param( [Parameter(ValueFromPipelineByPropertyName = $true)] [string]$Id, [string]$Name, [string]$Keyword, [int]$Page, [int]$PageSize ) process { $apiParams = @{} Add-CSOptionalParameter -ApiParameters $apiParams -BoundParameters $PSBoundParameters -Map ([ordered]@{ Id = 'id'; Name = 'name'; Keyword = 'keyword'; Page = 'page'; PageSize = 'pagesize' }) ConvertFrom-CSResponse -Response (Invoke-CSApiRequest -Command 'listZonesMetrics' -Parameters $apiParams) -Command 'listZonesMetrics' } } function Get-CSHostMetric { <# .SYNOPSIS Lists hosts with their performance and capacity metrics. .DESCRIPTION Wraps listHostsMetrics: the same rows as Get-CSHost plus per-host CPU, memory, and network usage, allocation, and threshold figures. Zone objects can be piped in to scope the list. .PARAMETER Id Filter by host ID .PARAMETER Name Filter by host name .PARAMETER ZoneId Filter by zone ID .PARAMETER PodId Filter by pod ID .PARAMETER ClusterId Filter by cluster ID .PARAMETER State Filter by host state (for example Up, Down, Disconnected) .PARAMETER Type Filter by host type (for example Routing) .PARAMETER Keyword Filter by keyword .PARAMETER Page Page number of results to return .PARAMETER PageSize Number of results per page .EXAMPLE Get-CSHostMetric -ZoneId $zoneId | Sort-Object cpuusedpercentage -Descending Finds the busiest hosts in a zone by CPU. .EXAMPLE Get-CSHostMetric -State Up | Where-Object { [double]($_.memoryusedpercentage -replace '%') -gt 90 } Lists hosts running hot on memory. #> [CmdletBinding()] param( [string]$Id, [string]$Name, [Parameter(ValueFromPipelineByPropertyName = $true)] [string]$ZoneId, [string]$PodId, [string]$ClusterId, [string]$State, [string]$Type, [string]$Keyword, [int]$Page, [int]$PageSize ) process { $apiParams = @{} Add-CSOptionalParameter -ApiParameters $apiParams -BoundParameters $PSBoundParameters -Map ([ordered]@{ Id = 'id'; Name = 'name'; ZoneId = 'zoneid'; PodId = 'podid'; ClusterId = 'clusterid'; State = 'state' Type = 'type'; Keyword = 'keyword'; Page = 'page'; PageSize = 'pagesize' }) ConvertFrom-CSResponse -Response (Invoke-CSApiRequest -Command 'listHostsMetrics' -Parameters $apiParams) -Command 'listHostsMetrics' } } function Get-CSVolumeMetric { <# .SYNOPSIS Lists volumes with their size and IOPS metrics. .DESCRIPTION Wraps listVolumesMetrics: the same rows as Get-CSVolume plus physical size and disk IOPS/throughput figures. .PARAMETER Id Filter by volume ID .PARAMETER Ids Filter by several volume IDs .PARAMETER Name Filter by volume name .PARAMETER ZoneId Filter by zone ID .PARAMETER StorageId Filter by primary storage pool ID .PARAMETER Account Filter by account name. Must be used with -DomainId. .PARAMETER DomainId Filter by domain ID .PARAMETER ProjectId Filter by project ID .PARAMETER Keyword Filter by keyword .PARAMETER Page Page number of results to return .PARAMETER PageSize Number of results per page .EXAMPLE Get-CSVolumeMetric -StorageId $poolId | Sort-Object physicalsize -Descending Finds the largest volumes on a storage pool. .EXAMPLE Get-CSVolumeMetric -Id $volumeId Gets metrics for one volume. #> [CmdletBinding()] param( [string]$Id, [string[]]$Ids, [string]$Name, [string]$ZoneId, [string]$StorageId, [string]$Account, [string]$DomainId, [string]$ProjectId, [string]$Keyword, [int]$Page, [int]$PageSize ) $apiParams = @{} Add-CSOptionalParameter -ApiParameters $apiParams -BoundParameters $PSBoundParameters -Map ([ordered]@{ Id = 'id'; Ids = 'ids'; Name = 'name'; ZoneId = 'zoneid'; StorageId = 'storageid'; Account = 'account' DomainId = 'domainid'; ProjectId = 'projectid'; Keyword = 'keyword'; Page = 'page'; PageSize = 'pagesize' }) ConvertFrom-CSResponse -Response (Invoke-CSApiRequest -Command 'listVolumesMetrics' -Parameters $apiParams) -Command 'listVolumesMetrics' } function Get-CSInfrastructure { <# .SYNOPSIS Gets a count of the main infrastructure objects. .DESCRIPTION Wraps listInfrastructure, which returns a single summary of how many zones, pods, clusters, hosts, storage pools, system VMs, routers, and so on the cloud has. .EXAMPLE Get-CSInfrastructure Returns the counts of zones, pods, clusters, hosts, and more. #> [CmdletBinding()] param() ConvertFrom-CSResponse -Response (Invoke-CSApiRequest -Command 'listInfrastructure' -Parameters @{}) -Command 'listInfrastructure' } function Get-CSDbMetric { <# .SYNOPSIS Lists the management database hosts and their statistics. .DESCRIPTION Wraps listDbMetrics, which reports each configured database host along with connection and replication statistics. .EXAMPLE Get-CSDbMetric Shows the database hosts and their current statistics. #> [CmdletBinding()] param() ConvertFrom-CSResponse -Response (Invoke-CSApiRequest -Command 'listDbMetrics' -Parameters @{}) -Command 'listDbMetrics' } function Get-CSUsageServerMetric { <# .SYNOPSIS Lists the usage server hosts and their metrics. .DESCRIPTION Wraps listUsageServerMetrics, which reports each usage server's state and the time of its last successful run. .EXAMPLE Get-CSUsageServerMetric Shows the usage server state and last-run details. #> [CmdletBinding()] param() ConvertFrom-CSResponse -Response (Invoke-CSApiRequest -Command 'listUsageServerMetrics' -Parameters @{}) -Command 'listUsageServerMetrics' } |