-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Pr/fix uptime plugin boottime #2034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This breaks on Solaris:
|
56ee8be
to
41d4647
Compare
rubenk, I've changed last commit to depend on KERNEL_LINUX and avoid conflict with Solaris sys/sysinfo.h. Could you confirm this solves the problem you mentioned? |
d2a98fb
to
b5ce223
Compare
Please consider merging this commit. It's been waiting for almost a year. Since then, the source code was reformatted twice forcing me to update patch (I use this in a couple of production instances). As for now, the PR is up-to-date with master branch. |
b5ce223
to
af01dd6
Compare
Uptime plugin fails to adjust for system time changes after boot. As Openwrt/LEDE routers usually do not have a RTC, the system time gets adjusted with NTP possibly after collectd has already started. But collectd continues to use the initial time set by 'sysfixtime', which can lead to incorrect uptime calculations. Apply a proposed fix from upstream that uses /proc/uptime Reference to collectd/collectd#2034 Fixes openwrt#4819 Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
I'm just a couple-times contributor here without write permissions 🤷 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @marcin1j,
thank you very much for your patch. I'm sorry that it didn't get attention earlier; there's too much to do and too little time and we're all volunteers.
The code LGTM. Please fix the merge conflict, preferably by re-basing on master, then this is good to go.
Best regards,
—octo
@octo |
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.
af01dd6
to
4943510
Compare
@marcin1j Certainly, just let me know when you're ready. |
I've tested it. Everything seems OK. |
Thanks @marcin1j! |
Uptime plugin fails to adjust for system time changes after boot. As Openwrt/LEDE routers usually do not have a RTC, the system time gets adjusted with NTP possibly after collectd has already started. But collectd continues to use the initial time set by 'sysfixtime', which can lead to incorrect uptime calculations. Apply a proposed fix from upstream that uses /proc/uptime Reference to collectd/collectd#2034 Fixes openwrt#4819 Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
Original uptime plugin implementation is susceptible to system date changes, which is likely to happen on embedded system without RTC.
The cause of the problem is a combination of two factors:
This set of commits changes the implementation in the following way: