8000 nfs plugin: Add config options to ignore versions by usev6 · Pull Request #2430 · collectd/collectd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nfs plugin: Add config options to ignore versions #2430

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

Merged
merged 3 commits into from
Sep 19, 2017

Conversation

usev6
Copy link
Contributor
@usev6 usev6 commented Sep 15, 2017

No description provided.

@usev6
Copy link
Contributor Author
usev6 commented Sep 15, 2017

At my day job I was looking for a way to avoid metrics for NFSv2 hitting a loaded graphite server, today. Looking at src/nfs.c, I thought, I might as well open a PR for this functionality.

This is my first PR for collectd, so please have patience and review carefully ;-)

Copy link
Member
@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @usev6,

thank you very much for opening this PR! Code-wise your change looks good (some nit-picky comments are inline), but in order to have a consistent user-experience I'd like to you rename the IgnoreV _x_ option (details inline).

Best regards,
—octo


=over 4

=item B<IgnoreV2> B<false>|B<true>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We avoid using negated config options, because the resulting double-negations ("ignore: false!") are unnecessarily hard to read. The typical naming for such options is "Report…", i.e. in your case ReportV2, etc.

src/nfs.c Outdated
@@ -31,6 +31,12 @@
#include <kstat.h>
#endif

static const char *config_keys[] = {"IgnoreV2", "IgnoreV3", "IgnoreV4"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static int ignore_v2 = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables should be of type _Bool.

src/nfs.c Outdated
@@ -295,6 +301,19 @@ static kstat_t *nfs4_ksp_client;
static kstat_t *nfs4_ksp_server;
#endif

static int nfs_config(const char *key, const char *value) {
if (strcasecmp(key, "IgnoreV2") == 0 && IS_TRUE(value))
ignore_v2 = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8000

Please just assign the valur of IS_TRUE(), i.e. ignore_v2 = IS_TRUE(value). This allows (convoluted but correct) configs such as

<Plugin nfs>
  IgnoreV2 true
  IgnoreV2 false
</Plugin>

src/nfs.c Outdated
@@ -495,18 +514,18 @@ static void nfs_read_linux(FILE *fh, const char *inst) {
if (fields_num < 3)
continue;

if (strcmp(fields[0], "proc2") == 0) {
if (strcmp(fields[0], "proc2") == 0 && ignore_v2 == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With boolean variables (_Bool), please use !ignore_v2 instead. Here and below.

@octo octo added the Feature label Sep 18, 2017
* Avoid negated config options (s/IgnoreV/ReportV/)
* Use _Bool instead of int
* Handle multiple occurences of config option correctly
@usev6
Copy link
Contributor Author
usev6 commented Sep 18, 2017

Hi @octo ,

thanks a lot for your comments! I changed my PR accordingly and I fully agree that the resulting code is clearer.

Best regards,
usev6

Copy link
Member
@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks awesome, thanks @usev6!

@octo octo merged commit 507d219 into collectd:master Sep 19, 2017
@usev6 usev6 deleted the nfs_ignore_versions branch September 19, 2017 17:57
@octo octo added this to the 5.8 milestone Oct 11, 2017
@maryamtahhan maryamtahhan mentioned this pull request Oct 12, 2017
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0