author | Marcin Jurkowski <marcin1j@gmail.com> | |
Tue, 11 Jul 2017 13:00:25 +0000 (15:00 +0200) | ||
committer | Marcin Jurkowski <marcin1j@gmail.com> | |
Mon, 25 Sep 2017 10:18:51 +0000 (12:18 +0200) | ||
commit | 4943510c1db22b5cf6342411271eb10255680211 | |
tree | 15ec0d99a726bc33dceb6a775b7dd997fc13dbd1 | tree | snapshot |
parent | d6584e82a88127642f04eb8fec0cbb90dc01fab0 | commit | diff |
uptime plugin: don't cache boot time and simplify Linux code
Caching boottime on startup yields incorrect uptime values if system
date changes after the daemon is started.
This is almost certain to happen on embedded systems without RTC, where
clock is set from NTP server at some point after boot process.
On Linux, we can retrieve uptime directly by either reading /proc/uptime
(it's sufficient to read a few bytes) or calling sysinfo() function.
Use the latter since it's the most efficient way in speed, memory
requirements and code simplicity terms.
Caching boottime on startup yields incorrect uptime values if system
date changes after the daemon is started.
This is almost certain to happen on embedded systems without RTC, where
clock is set from NTP server at some point after boot process.
On Linux, we can retrieve uptime directly by either reading /proc/uptime
(it's sufficient to read a few bytes) or calling sysinfo() function.
Use the latter since it's the most efficient way in speed, memory
requirements and code simplicity terms.
src/uptime.c | diff | blob | history |