X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnfs.c;h=97d91259a338fae7973dfc9027cd7dc0e87a4b90;hb=965115a9ec6d4beaea5c6c1483176b80445c5f96;hp=36da8bf39864c81c9a713325a932f977e4773b63;hpb=f1bdf1dbbffdcf3e19b7a471029845299c8d48c6;p=collectd.git diff --git a/src/nfs.c b/src/nfs.c index 36da8bf3..97d91259 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -24,8 +24,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #if HAVE_KSTAT_H #include @@ -33,9 +33,9 @@ static const char *config_keys[] = {"ReportV2", "ReportV3", "ReportV4"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static _Bool report_v2 = 1; -static _Bool report_v3 = 1; -static _Bool report_v4 = 1; +static bool report_v2 = true; +static bool report_v3 = true; +static bool report_v4 = true; /* see /proc/net/rpc/nfs @@ -188,39 +188,25 @@ static size_t nfs4_server40_procedures_names_num = static const char *nfs4_server4x_procedures_names[] = { /* NFS 4.1 */ - "backchannel_ctl", - "bind_conn_to_session", - "exchange_id", - "create_session", - "destroy_session", - "free_stateid", - "get_dir_delegation", - "getdeviceinfo", - "getdevicelist", - "layoutcommit", - "layoutget", - "layoutreturn", - "secinfo_no_name", - "sequence", - "set_ssv", - "test_stateid", - "want_delegation", - "destroy_clientid", - "reclaim_complete", + "backchannel_ctl", "bind_conn_to_session", "exchange_id", "create_session", + "destroy_session", "free_stateid", "get_dir_delegation", "getdeviceinfo", + "getdevicelist", "layoutcommit", "layoutget", "layoutreturn", + "secinfo_no_name", "sequence", "set_ssv", "test_stateid", "want_delegation", + "destroy_clientid", "reclaim_complete", /* NFS 4.2 */ - "allocate", /* 3.18 */ - "copy", /* 3.18 */ - "copy_notify", /* 3.18 */ - "deallocate", /* 3.18 */ - "ioadvise", /* 3.18 */ - "layouterror", /* 3.18 */ - "layoutstats", /* 3.18 */ - "offloadcancel", /* 3.18 */ - "offloadstatus", /* 3.18 */ - "readplus", /* 3.18 */ - "seek", /* 3.18 */ - "write_same", /* 3.18 */ - "clone" /* 4.5 */ + "allocate", /* 3.18 */ + "copy", /* 3.18 */ + "copy_notify", /* 3.18 */ + "deallocate", /* 3.18 */ + "ioadvise", /* 3.18 */ + "layouterror", /* 3.18 */ + "layoutstats", /* 3.18 */ + "offloadcancel", /* 3.18 */ + "offloadstatus", /* 3.18 */ + "readplus", /* 3.18 */ + "seek", /* 3.18 */ + "write_same", /* 3.18 */ + "clone" /* 4.5 */ }; #define NFS4_SERVER40_NUM_PROC \ @@ -292,12 +278,12 @@ static const char *nfs4_client4x_procedures_names[] = { "bind_conn_to_session", /* |53| 3.5 */ "destroy_clientid", /* |53| 3.5 */ /* NFS 4.2 */ - "seek", /* |55| 3.18 */ - "allocate", /* |57| 3.19 */ - "deallocate", /* |57| 3.19 */ - "layoutstats", /* |58| 4.2 */ - "clone", /* |59| 4.4 */ - "copy" /* |60| 4.7 */ + "seek", /* |55| 3.18 */ + "allocate", /* |57| 3.19 */ + "deallocate", /* |57| 3.19 */ + "layoutstats", /* |58| 4.2 */ + "clone", /* |59| 4.4 */ + "copy" /* |60| 4.7 */ }; #define NFS4_CLIENT40_NUM_PROC \ @@ -336,7 +322,7 @@ static int nfs_config(const char *key, const char *value) { #if KERNEL_LINUX static int nfs_init(void) { return 0; } -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT static int nfs_init(void) { @@ -411,7 +397,7 @@ static int nfs_submit_fields_safe(int nfs_version, const char *instance, size_t proc_names_num) { if (fields_num != proc_names_num) { WARNING("nfs plugin: Wrong number of fields for " - "NFSv%i %s statistics. Expected %zu, got %zu.", + "NFSv%i %s statistics. Expected %" PRIsz ", got %" PRIsz ".", nfs_version, instance, proc_names_num, fields_num); return EINVAL; } @@ -423,7 +409,7 @@ static int nfs_submit_fields_safe(int nfs_version, const char *instance, static int nfs_submit_nfs4_server(const char *instance, char **fields, size_t fields_num) { - static int suppress_warning = 0; + static int suppress_warning; size_t proc4x_names_num; switch (fields_num) { @@ -431,11 +417,11 @@ static int nfs_submit_nfs4_server(const char *instance, char **fields, case NFS4_SERVER40_NUM_PROC + 19: /* NFS 4.1 */ case NFS4_SERVER40_NUM_PROC + 31: /* NFS 4.2 */ case NFS4_SERVER40_NUM_PROC + 32: /* NFS 4.2 */ - break; + break; default: if (!suppress_warning) { WARNING("nfs plugin: Unexpected number of fields for " - "NFSv4 %s statistics: %zu. ", + "NFSv4 %s statistics: %" PRIsz ". ", instance, fields_num); } @@ -465,7 +451,7 @@ static int nfs_submit_nfs4_client(const char *instance, char **fields, size_t fields_num) { size_t proc40_names_num, proc4x_names_num; - static int suppress_warning = 0; + static int suppress_warning; switch (fields_num) { case 34: @@ -500,9 +486,8 @@ static int nfs_submit_nfs4_client(const char *instance, char **fields, break; default: if (!suppress_warning) { - WARNING("nfs plugin: Unexpected number of " - "fields for NFSv4 %s " - "statistics: %zu. ", + WARNING("nfs plugin: Unexpected number of fields for NFSv4 %s " + "statistics: %" PRIsz ". ", instance, fields_num); } @@ -534,7 +519,8 @@ static int nfs_submit_nfs4_client(const char *instance, char **fields, static void nfs_read_linux(FILE *fh, const char *inst) { char buffer[1024]; - char *fields[64]; + // The stats line is prefixed with type and number of fields, thus plus 2 + char *fields[MAX(NFS4_SERVER_MAX_PROC, NFS4_CLIENT_MAX_PROC) + 2]; int fields_num = 0; if (fh == NULL) @@ -608,7 +594,7 @@ static int nfs_read(void) { return 0; } -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT static int nfs_read(void) {