Skip to content

Commit

Permalink
ensure time is in Universal Time Zone to properly calculate uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
mcshooter committed Sep 2, 2021
1 parent 56c592a commit 3344efd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/healthchecker/health_checker_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func getUptimeFunc(service string) func() (time.Duration, error) {
getTimeCreatedCmd := `$ProcessId = (Get-WMIObject -Class Win32_Service -Filter "Name='` + service + `'" | Select-Object -ExpandProperty ProcessId);` +
`if ([string]::IsNullOrEmpty($ProcessId) -or $ProcessId -eq 0) { (Get-WinEvent -FilterHashtable @{logname='system';id=7036} ` +
`| Where-Object {$_.Message -match '.*(` + service + `).*(running).*'} | Select-Object -Property TimeCreated -First 1 | ` +
`foreach {$_.TimeCreated.ToString('R')} | Out-String).Trim() } else { (Get-Process -Id $ProcessId | Select starttime | ` +
`foreach {$_.starttime.ToString('R')} | Out-String).Trim() }`
`foreach {$_.TimeCreated.ToUniversalTime().ToString('R')} | Out-String).Trim() } else { (Get-Process -Id $ProcessId | Select starttime | ` +
`foreach {$_.starttime.ToUniversalTime().ToString('R')} | Out-String).Trim() }`
out, err := powershell(getTimeCreatedCmd)
if err != nil {
return time.Duration(0), err
Expand Down

0 comments on commit 3344efd

Please sign in to comment.