Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-1504

Uptime resolver fact for Windows uses unreliable metric for uptime

    Details

    • Template:
    • Acceptance Criteria:
      Hide
      • Facter should not measure uptime using local datetime
        Test:
        Run Facter and note uptime
        Change local time to a few days in the past
        Run Facter and note uptime. The uptime should not change.
      Show
      Facter should not measure uptime using local datetime Test: Run Facter and note uptime Change local time to a few days in the past Run Facter and note uptime. The uptime should not change.
    • Team:
      Platform OS
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Windows uptime fact now uses GetTickCount64 which is more reliable, minimizes clock skews, and offers better resolution than the earlier method of computing using WMI BootUptime which has proved to be error prone.

      Description

      The Windows Uptime fact uses the WMI properties of LastBootupTime and LocalDateTime from the Win32_OperatingSystem class

      https://github.com/puppetlabs/facter/blob/master/lib/src/facts/windows/uptime_resolver.cc#L40-L47

      However these measurements are prone to large clock skews causing miscalculation or, worse, negative uptime values. e.g.

      • BootUptime is 1pm
      • After Bootup clock synchronisation rolls back time to 11am (wrong timezone)

      Therefore the current time is 11am but bootup time is in the future, 1pm.

      The windows uptime fact should instead use the GetTickCount64 function exported from kernel32.dll. This has been available since Windows Vista and Server 2008

      https://msdn.microsoft.com/en-us/library/ms724411%28v=VS.85%29.aspx?f=255&MSPPError=-2147217396

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jayant.sane Jayant Sane
                Reporter:
                glenn.sarti Glenn Sarti
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support