mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added check for Windows Uptime
This commit is contained in:
parent
f300348c6f
commit
f865a3d663
1 changed files with 27 additions and 0 deletions
27
lib/plugins/Invoke-IcingaCheckUptime.psm1
Normal file
27
lib/plugins/Invoke-IcingaCheckUptime.psm1
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
Import-IcingaLib provider\windows;
|
||||
Import-IcingaLib core\tools;
|
||||
|
||||
function Invoke-IcingaCheckUptime()
|
||||
{
|
||||
param(
|
||||
$Warning,
|
||||
$Critical,
|
||||
[switch]$NoPerfData,
|
||||
[int]$Verbose
|
||||
);
|
||||
|
||||
$WindowsData = Get-IcingaWindows;
|
||||
$Name = ([string]::Format('Windows Uptime: {0}', (ConvertFrom-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value)));
|
||||
|
||||
$IcingaCheck = New-IcingaCheck -Name 'Windows Uptime' -Value $WindowsData.windows.metadata.uptime.value -Unit 's';
|
||||
$IcingaCheck.WarnOutOfRange(
|
||||
(ConvertTo-SecondsFromIcingaThresholds -Threshold $Warning)
|
||||
).CritOutOfRange(
|
||||
(ConvertTo-SecondsFromIcingaThresholds -Threshold $Critical)
|
||||
) | Out-Null;
|
||||
|
||||
$CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Checks $IcingaCheck -Verbose $Verbose;
|
||||
|
||||
exit (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
Loading…
Reference in a new issue