From: Edgar Fuß Date: Thu, 31 Oct 2019 17:26:45 +0000 (+0100) Subject: Implement NFS plugin for NetBSD X-Git-Tag: collectd-5.11.0~43^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=876e6792095f97704f7e0639960d53483ab493cf;p=thirdparty%2Fcollectd.git Implement NFS plugin for NetBSD --- diff --git a/configure.ac b/configure.ac index 59a7f355c..d5daa144b 100644 --- a/configure.ac +++ b/configure.ac @@ -6450,6 +6450,7 @@ if test "x$ac_system" = "xNetBSD"; then plugin_disk="yes" plugin_entropy="yes" plugin_irq="yes" + plugin_nfs="yes" plugin_processes="yes" fi diff --git a/src/nfs.c b/src/nfs.c index 97d91259a..e8ae6408d 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -27,6 +27,15 @@ #include "plugin.h" #include "utils/common/common.h" +#if KERNEL_NETBSD +#include +#include +#include +#include +#include +#include +#endif + #if HAVE_KSTAT_H #include #endif @@ -82,12 +91,14 @@ Number Procedures Procedures 21 commit */ +#if KERNEL_LINUX | HAVE_KSTAT static const char *nfs2_procedures_names[] = { "null", "getattr", "setattr", "root", "lookup", "readlink", "read", "wrcache", "write", "create", "remove", "rename", "link", "symlink", "mkdir", "rmdir", "readdir", "fsstat"}; static size_t nfs2_procedures_names_num = STATIC_ARRAY_SIZE(nfs2_procedures_names); +#endif static const char *nfs3_procedures_names[] = { "null", "getattr", "setattr", "lookup", "access", "readlink", @@ -320,7 +331,7 @@ static int nfs_config(const char *key, const char *value) { return 0; } -#if KERNEL_LINUX +#if KERNEL_LINUX || KERNEL_NETBSD static int nfs_init(void) { return 0; } /* #endif KERNEL_LINUX */ @@ -596,6 +607,28 @@ static int nfs_read(void) { } /* #endif KERNEL_LINUX */ +#elif KERNEL_NETBSD +static int nfs_read(void) { + struct nfsstats ns; + size_t size = sizeof(ns); + int mib[] = { CTL_VFS, 2, NFS_NFSSTATS }; + value_t values[nfs3_procedures_names_num]; + int i; + + /* NetBSD reports v2 statistics mapped to v3 and doen't yet support v4 */ + if (!report_v3) return 0; + if (sysctl(mib, 3, &ns, &size, NULL, 0) != 0) return 1; + + for (i = 0; i < nfs3_procedures_names_num; i++) values[i].counter = (derive_t)ns.rpccnt[i]; + nfs_procedures_submit("v3client", nfs3_procedures_names, values, nfs3_procedures_names_num); + + for (i = 0; i < nfs3_procedures_names_num; i++) values[i].counter = (derive_t)ns.srvrpccnt[i]; + nfs_procedures_submit("v3server", nfs3_procedures_names, values, nfs3_procedures_names_num); + + return 0; +} +/* #endif KERNEL_NETBSD */ + #elif HAVE_LIBKSTAT static int nfs_read(void) { if (report_v2) {