mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
46 lines
1.4 KiB
PowerShell
46 lines
1.4 KiB
PowerShell
|
|
function Get-IcingaPerformanceCounterDetails()
|
||
|
|
{
|
||
|
|
param (
|
||
|
|
[string]$Counter = $null
|
||
|
|
);
|
||
|
|
|
||
|
|
[hashtable]$RetValue = @{
|
||
|
|
'RawCounter' = $Counter;
|
||
|
|
'HasValue' = $TRUE;
|
||
|
|
'HasInstance' = $FALSE;
|
||
|
|
'Category' = '';
|
||
|
|
'Instance' = '';
|
||
|
|
'Counter' = '';
|
||
|
|
'CounterInstance' = '';
|
||
|
|
}
|
||
|
|
|
||
|
|
if ([string]::IsNullOrEmpty($Counter)) {
|
||
|
|
$RetValue.HasValue = $FALSE;
|
||
|
|
|
||
|
|
return $RetValue;
|
||
|
|
}
|
||
|
|
|
||
|
|
[array]$CounterElements = $Counter.Split('\');
|
||
|
|
[string]$Instance = '';
|
||
|
|
[string]$Category = '';
|
||
|
|
[bool]$HasInstance = $FALSE;
|
||
|
|
|
||
|
|
if ($CounterElements[1].Contains('(') -And $CounterElements[1].Contains(')')) {
|
||
|
|
$HasInstance = $TRUE;
|
||
|
|
[int]$StartIndex = $CounterElements[1].IndexOf('(') + 1;
|
||
|
|
[int]$EndIndex = $CounterElements[1].Length - $StartIndex - 1;
|
||
|
|
$Instance = $CounterElements[1].Substring($StartIndex, $EndIndex);
|
||
|
|
$RetValue.HasInstance = $HasInstance;
|
||
|
|
$Category = $CounterElements[1].Substring(0, $CounterElements[1].IndexOf('('));
|
||
|
|
$RetValue.CounterInstance = [string]::Format('{0}_{1}', $Instance, $CounterElements[2]);
|
||
|
|
} else {
|
||
|
|
$Category = $CounterElements[1];
|
||
|
|
}
|
||
|
|
|
||
|
|
$RetValue.Category = $Category;
|
||
|
|
$RetValue.Instance = $Instance;
|
||
|
|
$RetValue.Counter = $CounterElements[2];
|
||
|
|
|
||
|
|
return $RetValue;
|
||
|
|
}
|