2019-08-20 11:02:58 -04:00
|
|
|
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;
|
|
|
|
|
|
2019-09-25 13:57:19 -04:00
|
|
|
return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);
|
2019-08-20 11:02:58 -04:00
|
|
|
}
|