summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e56e0ec)
raw | patch | inline | side by side (parent: e56e0ec)
author | usev6 <use_v6@aglaz.de> | |
Mon, 18 Sep 2017 18:50:18 +0000 (20:50 +0200) | ||
committer | usev6 <use_v6@aglaz.de> | |
Mon, 18 Sep 2017 18:50:18 +0000 (20:50 +0200) |
* Avoid negated config options (s/IgnoreV/ReportV/)
* Use _Bool instead of int
* Handle multiple occurences of config option correctly
* Use _Bool instead of int
* Handle multiple occurences of config option correctly
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/nfs.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index dbc5463fd1982fe6e8529e40400c2105a26f5a98..fa6c96c1628d6c1fa8879f5750d5971da7b4415d 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
@LOAD_PLUGIN_NETWORK@</Plugin>
#<Plugin nfs>
-# IgnoreV2 true
-# #IgnoreV3 true
-# #IgnoreV4 true
+# ReportV2 false
+# #ReportV3 false
+# #ReportV4 false
#</Plugin>
#<Plugin nginx>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 298a43b4d2167c843a5e3844de1b65ee01e2ef26..379e083878e905637952dce7450f950c8a997052 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
grouped by version and whether the system runs as server or client.
It is possibly to omit metrics for a specific NFS version by setting one or
-more of the following options to B<true> (all of them default to B<false>).
+more of the following options to B<false> (all of them default to B<true>).
=over 4
-=item B<IgnoreV2> B<false>|B<true>
+=item B<ReportV2> B<true>|B<false>
-=item B<IgnoreV3> B<false>|B<true>
+=item B<ReportV3> B<true>|B<false>
-=item B<IgnoreV4> B<false>|B<true>
+=item B<ReportV4> B<true>|B<false>
=back
diff --git a/src/nfs.c b/src/nfs.c
index 2f628218448381d9290ff5f4126fca0a962253ee..369b764a9f8036d6835deb54a7f2f6c6903da8e0 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
#include <kstat.h>
#endif
-static const char *config_keys[] = {"IgnoreV2", "IgnoreV3", "IgnoreV4"};
+static const char *config_keys[] = {"ReportV2", "ReportV3", "ReportV4"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
-static int ignore_v2 = 0;
-static int ignore_v3 = 0;
-static int ignore_v4 = 0;
+static _Bool report_v2 = 1;
+static _Bool report_v3 = 1;
+static _Bool report_v4 = 1;
/*
see /proc/net/rpc/nfs
#endif
static int nfs_config(const char *key, const char *value) {
- if (strcasecmp(key, "IgnoreV2") == 0 && IS_TRUE(value))
- ignore_v2 = 1;
- else if (strcasecmp(key, "IgnoreV3") == 0 && IS_TRUE(value))
- ignore_v3 = 1;
- else if (strcasecmp(key, "IgnoreV4") == 0 && IS_TRUE(value))
- ignore_v4 = 1;
+ if (strcasecmp(key, "ReportV2") == 0)
+ report_v2 = IS_TRUE(value);
+ else if (strcasecmp(key, "ReportV3") == 0)
+ report_v3 = IS_TRUE(value);
+ else if (strcasecmp(key, "ReportV4") == 0)
+ report_v4 = IS_TRUE(value);
else
return -1;
if (fields_num < 3)
continue;
- if (strcmp(fields[0], "proc2") == 0 && ignore_v2 == 0) {
+ if (strcmp(fields[0], "proc2") == 0 && report_v2) {
nfs_submit_fields_safe(/* version = */ 2, inst, fields + 2,
(size_t)(fields_num - 2), nfs2_procedures_names,
nfs2_procedures_names_num);
- } else if (strncmp(fields[0], "proc3", 5) == 0 && ignore_v3 == 0) {
+ } else if (strncmp(fields[0], "proc3", 5) == 0 && report_v3) {
nfs_submit_fields_safe(/* version = */ 3, inst, fields + 2,
(size_t)(fields_num - 2), nfs3_procedures_names,
nfs3_procedures_names_num);
- } else if (strcmp(fields[0], "proc4ops") == 0 && ignore_v4 == 0) {
+ } else if (strcmp(fields[0], "proc4ops") == 0 && report_v4) {
if (inst[0] == 's')
nfs_submit_nfs4_server(inst, fields + 2, (size_t)(fields_num - 2));
- } else if (strcmp(fields[0], "proc4") == 0 && ignore_v4 == 0) {
+ } else if (strcmp(fields[0], "proc4") == 0 && report_v4) {
if (inst[0] == 'c')
nfs_submit_nfs4_client(inst, fields + 2, (size_t)(fields_num - 2));
}
#elif HAVE_LIBKSTAT
static int nfs_read(void) {
- if (ignore_v2 == 0) {
+ if (report_v2) {
nfs_read_kstat(nfs2_ksp_client, /* version = */ 2, "client",
nfs2_procedures_names, nfs2_procedures_names_num);
nfs_read_kstat(nfs2_ksp_server, /* version = */ 2, "server",
nfs2_procedures_names, nfs2_procedures_names_num);
}
- if (ignore_v3 == 0) {
+ if (report_v3) {
nfs_read_kstat(nfs3_ksp_client, /* version = */ 3, "client",
nfs3_procedures_names, nfs3_procedures_names_num);
nfs_read_kstat(nfs3_ksp_server, /* version = */ 3, "server",
nfs3_procedures_names, nfs3_procedures_names_num);
}
- if (ignore_v2 == 0) {
+ if (report_v2) {
nfs_read_kstat(nfs4_ksp_client, /* version = */ 4, "client",
nfs4_procedures_names, nfs4_procedures_names_num);
nfs_read_kstat(nfs4_ksp_server, /* version = */ 4, "server",