-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
timex: this plugin enables timex plugin for non-linux systems #12489
Conversation
If the timex plugin becomes available across all of linux, freebsd and macos, we should:
|
12f3504
to
2e3e34b
Compare
#if defined(__FreeBSD__) || defined(__APPLE__) | ||
sync_state = ntp_adjtime(&timex_buf); | ||
#else | ||
sync_state = adjtimex(&timex_buf); | ||
#endif |
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.
Please, move this code under a new function in libnetdata/os.c
(something like adjust_time()
or something similar).
We want to reduce the amount of OS-specific macros outside of libnetdata
.
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.
good point..I'll make changes
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.
I think aliasing something like below in os.h should be ok in this use case.
#include <sys/timex.h>
#if defined(__FreeBSD__) || defined(__APPLE__)
#define ADJUST_TIMEX(x) ntp_adjtime(x)
#else
#define ADJUST_TIMEX(x) adjtimex(x)
#endif
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.
Better to make this a function (you can pass it around, error messages match the real name, etc.). Either way it's fine by me, but make sure we use a lower-case name.
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.
In my opinion, it's better to use CAPS with macros so as to distinguish them with regular variables/functions
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.
In my opinion, it's better to use CAPS with macros so as to distinguish them with regular variables/functions
Agreed, but the rest of the code already uses lowercase.
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.
Agreed, but the rest of the code already uses lowercase.
Not everywhere. Even in this file, we use uppercase.
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.
this is partly true, I have seen both lowercase and uppercase macros in our code. But if you see the os.h itself where I've made changes, other macros are in uppercase. I still think, it's better to go with uppercase macros.
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.
Agreed, but the rest of the code already uses lowercase.
Not everywhere. Even in this file, we use uppercase.
...for function-like macros.
We are debating a trivial thing here. For the time being, this will be used only by timex. Let's pick the approach you prefer and merge the PR.
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.
yeah, this is really trivial thing. lets merge this PR for now.
@surajnpn thanks for the changes, this LGTM. There's one last change before merging this, see comment inline. |
@surajnpn one more minor thing we need to change (not Linux specific after this PR)
|
https://build.opensuse.org/request/show/977544 by user mia + dimstar_suse - Update to 1.34.1 (go.d.plugin 0.32.3) Collectors * New collectors + Add CPU throttling charts (cgroups.plugin) (gh#netdata/netdata#12591) + Add clock status chart (timex.plugin) (gh#netdata/netdata#12501) + Add Asterisk configuration file with synthetic charts (statsd.plugin) (gh#netdata/netdata#12381) + Add new chart for process states metrics (apps.plugin) (gh#netdata/netdata#12305) + Add thermal zone metrics collection (go.d/wmi) (gh#netdata/netdata#667) + Add SNMP data collector (go.d/snmp) (gh#netdata/netdata#644) * Improvements + Add 'locust' to apps_groups.conf (gh#netdata/netdata#12498) + Enable timex plugin for non-linux systems (timex.plugin) (gh#netdata/netdata#12489) + Prefer 'blkio.*
timex.plugin has only been available to Linux systems. This commit enables timex plugin to FreeBSD and MacOS.
Summary
Test Plan
Tested in FreeBSD and Linux as follows:
Built with:
./netdata-installer.sh --install /tmp
Verified with the following apis:
Need some volunteer to test in MacOS
Additional Information