Skip to content

Commit 131bab2

Browse files
authored
Merge pull request #139 from Icinga:feature/add_last_boot_time_as_string_to_uptime_check
Feature: Adds last boot time to uptime check as notice Adds check note for the last boot time which is being displayed by using `-Verbosity 2` on the check configuration. ``` [OK] Check package "System Uptime: 8d 1h 28m 50s" (Match All) \_ [OK] Last Boot: 02/16/2021 08:50:45 \_ [OK] System Uptime: 696530.888485s ```
2 parents 8fce187 + b784cce commit 131bab2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ If you are going to install this plugin release, please have a look on the [upgr
2020
* [#134](https://github.com/Icinga/icinga-powershell-plugins/pull/134) Adds autoloading for plugin information to standardize the development and projects and fixes plenty of spelling/code styling errors
2121
* [#135](https://github.com/Icinga/icinga-powershell-plugins/pull/135) Adds new check plugin `Invoke-IcingaCheckTCP`
2222
* [#137](https://github.com/Icinga/icinga-powershell-plugins/pull/137) Adds new configuration for Icinga for Windows v1.4.0 to make future configuration changes unnecessary. Please read the [upgrading docs](30-Upgrading-Plugins.md) before upgrading!
23+
* [#139](https://github.com/Icinga/icinga-powershell-plugins/pull/139) Adds check note for the last boot time for `Invoke-IcingaCheckUptime` which is being displayed by using `-Verbosity 2` on the check configuration
2324

2425
### Bugfixes
2526

plugins/Invoke-IcingaCheckUptime.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ function Invoke-IcingaCheckUptime()
5050
$WindowsData = Get-IcingaWindows;
5151
$Name = ([string]::Format('System Uptime: {0}', (ConvertFrom-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value)));
5252

53+
$CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Verbose $Verbosity;
54+
5355
$IcingaCheck = New-IcingaCheck -Name 'System Uptime' -Value $WindowsData.windows.metadata.uptime.value -Unit 's';
5456
$IcingaCheck.WarnOutOfRange(
5557
(ConvertTo-SecondsFromIcingaThresholds -Threshold $Warning)
5658
).CritOutOfRange(
5759
(ConvertTo-SecondsFromIcingaThresholds -Threshold $Critical)
5860
) | Out-Null;
5961

60-
$CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Checks $IcingaCheck -Verbose $Verbosity;
62+
$BootTime = New-IcingaCheck -Name 'Last Boot' -Value ([string]$WindowsData.windows.metadata.uptime.raw) -NoPerfData;
63+
64+
$CheckPackage.AddCheck($IcingaCheck);
65+
$CheckPackage.AddCheck($BootTime);
6166

6267
return (New-IcingaCheckResult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);
6368
}

0 commit comments

Comments
 (0)