Skip to content

Commit e7d28a3

Browse files
authored
Merge pull request #615 from mcshooter/updateTimeFormatForUptimeFunc
Ensure time is in Universal Time Zone to properly calculate uptime
2 parents 56c592a + 3344efd commit e7d28a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/healthchecker/health_checker_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func getUptimeFunc(service string) func() (time.Duration, error) {
4444
getTimeCreatedCmd := `$ProcessId = (Get-WMIObject -Class Win32_Service -Filter "Name='` + service + `'" | Select-Object -ExpandProperty ProcessId);` +
4545
`if ([string]::IsNullOrEmpty($ProcessId) -or $ProcessId -eq 0) { (Get-WinEvent -FilterHashtable @{logname='system';id=7036} ` +
4646
`| Where-Object {$_.Message -match '.*(` + service + `).*(running).*'} | Select-Object -Property TimeCreated -First 1 | ` +
47-
`foreach {$_.TimeCreated.ToString('R')} | Out-String).Trim() } else { (Get-Process -Id $ProcessId | Select starttime | ` +
48-
`foreach {$_.starttime.ToString('R')} | Out-String).Trim() }`
47+
`foreach {$_.TimeCreated.ToUniversalTime().ToString('R')} | Out-String).Trim() } else { (Get-Process -Id $ProcessId | Select starttime | ` +
48+
`foreach {$_.starttime.ToUniversalTime().ToString('R')} | Out-String).Trim() }`
4949
out, err := powershell(getTimeCreatedCmd)
5050
if err != nil {
5151
return time.Duration(0), err

0 commit comments

Comments
 (0)