Add basic NFSv4 support to the NFS collection module. This will need a bit more work.
From b53a8b5ac9f05c9af9434fee466eb76e41055139 Mon Sep 17 00:00:00 2001 From: Seva Epsteyn <[email protected]> Date: Tue, 9 Nov 2010 13:48:05 -0600 Subject: [PATCH] Initial NFSv4 support
--- src/nfs.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 100 insertions(+), 7 deletions(-) diff --git a/src/nfs.c b/src/nfs.c index e4d12e3..2d2e7e9 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -28,6 +28,8 @@ # error "No applicable input method." #endif +#define MAX_PROC_FIELDS 64 + /* see /proc/net/rpc/nfs see http://www.missioncriticallinux.com/orph/NFS-Statistics @@ -71,6 +73,8 @@ Number Procedures Procedures 19 fsinfo 20 pathconf 21 commit + +NFSv4 info via http://exchange.munin-monitoring.org/plugins/nfsv4/version/1 */ static const char *nfs2_procedures_names[] = @@ -125,6 +129,53 @@ static const char *nfs3_procedures_names[] = }; static int nfs3_procedures_names_num = 22; +static const char *nfs4_procedures_names[] = +{ + "unknown", /* no idea what this is */ + "op0-unused", + "op1-unused", + "op2-future", + "access", + "close", + "commit", + "create", + "delegpurge", + "delegreturn", + "getattr", + "getfh", + "link", + "lock", + "lockt", + "locku", + "lookup", + "lookup_root", + "nverify", + "open", + "openattr", + "open_conf", + "open_dgrd", + "putfh", + "putpubfh", + "putrootfh", + "read", + "readdir", + "readlink", + "remove", + "rename", + "renew", + "restorefh", + "savefh", + "secinfo", + "setattr", + "setcltid", + "setcltidconf", + "verify", + "write", + "rellockowner", + NULL +}; +static int nfs4_procedures_names_num = 40; + #if HAVE_LIBKSTAT && 0 extern kstat_ctl_t *kc; static kstat_t *nfs2_ksp_client; @@ -135,8 +186,6 @@ static kstat_t *nfs4_ksp_client; static kstat_t *nfs4_ksp_server; #endif -/* Possibly TODO: NFSv4 statistics */ - #if 0 static int nfs_init (void) { @@ -211,7 +260,7 @@ static void nfs_read_stats_file (FILE *fh, char *inst) char plugin_instance[DATA_MAX_NAME_LEN]; - char *fields[48]; + char *fields[MAX_PROC_FIELDS]; int numfields = 0; if (fh == NULL) @@ -219,12 +268,17 @@ static void nfs_read_stats_file (FILE *fh, char *inst) while (fgets (buffer, BUFSIZE, fh) != NULL) { - numfields = strsplit (buffer, fields, 48); + numfields = strsplit (buffer, fields, MAX_PROC_FIELDS); - if (((numfields - 2) != nfs2_procedures_names_num) - && ((numfields - 2) - != nfs3_procedures_names_num)) +/* TODO FIXME: NFSv4 proc4ops has 42 fields on RHEL 5.5 2.6.18 and 61 on Oracle 2.6.32 */ +/* + if ( ((numfields - 2) != nfs2_procedures_names_num) + && ((numfields - 2) != nfs3_procedures_names_num) + && ((numfields - 2) != nfs4_procedures_names_num) ) + { continue; + } +*/ if (strcmp (fields[0], "proc2") == 0) { @@ -298,6 +352,45 @@ static void nfs_read_stats_file (FILE *fh, char *inst) free (values); } + else if (strncmp (fields[0], "proc4ops", 8) == 0) + { + int i; + unsigned long long *values; + +/* TODO FIXME: NFSv4 proc4ops has 42 fields on RHEL 5.5 2.6.18 and 61 on Oracle 2.6.32 */ +/* + if ((numfields - 2) != nfs4_procedures_names_num) + { + WARNING ("nfs plugin: Wrong " + "number of fields (= %i) " + "for NFSv4 statistics.", + numfields - 2); + continue; + } +*/ + + ssnprintf (plugin_instance, sizeof (plugin_instance), + "v4%s", inst); + + values = (unsigned long long *) malloc (nfs4_procedures_names_num * sizeof (unsigned long long)); + if (values == NULL) + { + char errbuf[1024]; + ERROR ("nfs plugin: malloc " + "failed: %s", + sstrerror (errno, errbuf, sizeof (errbuf))); + continue; + } + + for (i = 0; i < nfs4_procedures_names_num; i++) + values[i] = atoll (fields[i + 2]); + + nfs_procedures_submit (plugin_instance, values, + nfs4_procedures_names, + nfs4_procedures_names_num); + + free (values); + } } /* while (fgets (buffer, BUFSIZE, fh) != NULL) */ } /* void nfs_read_stats_file */ #undef BUFSIZE -- 1.7.3.1
_______________________________________________ collectd mailing list [email protected] http://mailman.verplant.org/listinfo/collectd
