Skip to content

Commit 8abe85a

Browse files
authored
Merge pull request #442 from Icinga:fix/uptime_check_reports_human_readable_uptime
Fix: Invoke-IcingaCheckUptime to report a more human readable output for the current uptime in the package name Fixes `Invoke-IcingaCheckUptime` to report a more human readable output for the current uptime in the package name
2 parents d53b64e + 00680fb commit 8abe85a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

doc/31-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2020
### Bugfixes
2121

2222
* [#377](https://github.com/Icinga/icinga-powershell-plugins/issues/377) Fixes `Invoke-IcingaCheckPerfCounter` to write correct performance data in case only certain instances are checked to ensure perf data are assigned to checks accordingly
23+
* [#420](https://github.com/Icinga/icinga-powershell-plugins/issues/420) Fixes `Invoke-IcingaCheckUptime` to report a more human readable output for the current uptime in the package name
2324
* [#436](https://github.com/Icinga/icinga-powershell-plugins/issues/436) Fixes performance data for ScheduledTask plugin for Last and Next RunTime
2425

2526
### Enhancements

plugins/Invoke-IcingaCheckUptime.psm1

+11-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
1414
* Root\Cimv2
1515
.EXAMPLE
16-
PS> Invoke-IcingaCheckUptime -Warning 18d -Critical 20d
17-
[WARNING]: Check package "Windows Uptime: Days: 19 Hours: 13 Minutes: 48 Seconds: 29" is [WARNING]
18-
| 'Windows Uptime'=1691309,539176s;1555200;1728000
16+
PS> Invoke-IcingaCheckUptime -Warning '10m'
17+
[WARNING] System Uptime: 0d 1h 25m 50s [WARNING] System Uptime
18+
\_ [WARNING] System Uptime: Value 1.43h is greater than threshold 10m
19+
| windows::ifw_uptime::uptime=5149.979s;600;;;
1920
.EXAMPLE
20-
PS> Invoke-IcingaCheckUptime -Warning 25d:
21-
[WARNING] Check package "System Uptime: 22d 16h 42m 35s" - [WARNING] System Uptime
22-
\_ [WARNING] System Uptime: Value "1960955.28s" is lower than threshold "2160000s"
23-
| 'system_uptime'=1960955.28s;2160000:;
24-
1
21+
PS> Invoke-IcingaCheckUptime -Warning '2h:'
22+
[WARNING] System Uptime: 0d 1h 28m 40s [WARNING] System Uptime
23+
\_ [WARNING] System Uptime: Value 1.48h is lower than threshold 2h
24+
| windows::ifw_uptime::uptime=5319.563s;7200:;;;
2525
.PARAMETER Warning
2626
Used to specify a Warning threshold. In this case a string.
2727
Allowed units include: ms, s, m, h, d, w, M, y
@@ -54,7 +54,9 @@ function Invoke-IcingaCheckUptime()
5454
);
5555

5656
$WindowsData = Get-IcingaWindows;
57-
$Name = ([string]::Format('System Uptime: {0}', (ConvertFrom-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value).Replace(',', '.')));
57+
$TimeSpan = New-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value;
58+
$UptimeHR = [string]::Format('{0}d {1}h {2}m {3}s', $TimeSpan.Days, $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds);
59+
$Name = [string]::Format('System Uptime: {0}', $UptimeHR);
5860

5961
$CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Verbose $Verbosity;
6062

0 commit comments

Comments
 (0)