mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
Disabling UseConsistentIndentation because it is not properly working for multi-line commands with arguments and array/hashtable objects
57 lines
1.7 KiB
PowerShell
57 lines
1.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Will provide a virtual object, containing an array of Performance Counters.
|
|
The object has the following members:
|
|
* Name
|
|
* Value
|
|
.DESCRIPTION
|
|
Will provide a virtual object, containing an array of Performance Counters.
|
|
The object has the following members:
|
|
* Name
|
|
* Value
|
|
.FUNCTIONALITY
|
|
Will provide a virtual object, containing an array of Performance Counters.
|
|
The object has the following members:
|
|
* Name
|
|
* Value
|
|
.EXAMPLE
|
|
PS>New-IcingaPerformanceCounterResult -FullName '\Processor(*)\% processor time' -PerformanceCounters $PerformanceCounters;
|
|
.PARAMETER FullName
|
|
The full path to the Performance Counter
|
|
.PARAMETER PerformanceCounters
|
|
A list of all instances/counters for the given Performance Counter
|
|
.INPUTS
|
|
System.String
|
|
.OUTPUTS
|
|
System.PSObject
|
|
.LINK
|
|
https://github.com/Icinga/icinga-powershell-framework
|
|
#>
|
|
|
|
function New-IcingaPerformanceCounterResult()
|
|
{
|
|
param(
|
|
[string]$FullName = '',
|
|
[array]$PerformanceCounters = @()
|
|
);
|
|
|
|
$pc_instance = New-Object -TypeName PSObject;
|
|
$pc_instance | Add-Member -MemberType NoteProperty -Name 'FullName' -Value $FullName;
|
|
$pc_instance | Add-Member -MemberType NoteProperty -Name 'Counters' -Value $PerformanceCounters;
|
|
|
|
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Name' -Value {
|
|
return $this.FullName;
|
|
}
|
|
|
|
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Value' -Value {
|
|
[hashtable]$CounterResults = @{ };
|
|
|
|
foreach ($counter in $this.Counters) {
|
|
$CounterResults.Add($counter.Name(), $counter.Value());
|
|
}
|
|
|
|
return $CounterResults;
|
|
}
|
|
|
|
return $pc_instance;
|
|
}
|