mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
Added Performance Counter Check Command
This commit is contained in:
parent
784dea96a2
commit
337f5e66e5
1 changed files with 36 additions and 0 deletions
36
lib/plugins/Invoke-IcingaCheckPerfcounter.psm1
Normal file
36
lib/plugins/Invoke-IcingaCheckPerfcounter.psm1
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
function Invoke-IcingaCheckPerfcounter()
|
||||
{
|
||||
param(
|
||||
[array]$PerfCounter,
|
||||
$Warning,
|
||||
$Critical,
|
||||
[switch]$NoPerfData,
|
||||
[int]$Verbose
|
||||
);
|
||||
|
||||
$Counters = New-IcingaPerformanceCounterArray -CounterArray $PerfCounter;
|
||||
$CheckPackage = New-IcingaCheckPackage -Name 'Performance Counter' -OperatorAnd -Verbose $Verbose;
|
||||
|
||||
foreach ($counter in $Counters.Keys) {
|
||||
|
||||
$CounterPackage = New-IcingaCheckPackage -Name $counter -OperatorAnd -Verbose $Verbose;
|
||||
|
||||
foreach ($instanceName in $Counters[$counter].Keys) {
|
||||
$instance = $Counters[$counter][$instanceName];
|
||||
if ($instance -isnot [hashtable]) {
|
||||
$IcingaCheck = New-IcingaCheck -Name $counter -Value $Counters[$counter].Value;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$CounterPackage.AddCheck($IcingaCheck);
|
||||
break;
|
||||
}
|
||||
$IcingaCheck = New-IcingaCheck -Name $instanceName -Value $instance.Value;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$CounterPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
$CheckPackage.AddCheck($CounterPackage);
|
||||
}
|
||||
|
||||
return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
Loading…
Reference in a new issue