X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fnfs.c;h=1a4ed7487b0566378092edb3f6d8b3b84d49adab;hb=1e74bb66c61d965c4aa261adfaf058f3356cff09;hp=cd1a5239cf44081a3a9e6342a0afcdb586108ca3;hpb=7d5dc149bbc2524aff485fbabbe954cb07ab0584;p=collectd.git diff --git a/src/nfs.c b/src/nfs.c index cd1a5239..1a4ed748 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -1,6 +1,7 @@ /** * collectd - src/nfs.c * Copyright (C) 2005,2006 Jason Pepas + * Copyright (C) 2012,2013 Florian Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,7 +18,8 @@ * * Authors: * Jason Pepas - * Florian octo Forster + * Florian octo Forster + * Cosmin Ioiart **/ #include "collectd.h" @@ -234,11 +236,11 @@ static void nfs_procedures_submit (const char *plugin_instance, size_t i; vl.values_len = 1; - sstrncpy(vl.host, hostname_g, sizeof (vl.host)); - sstrncpy(vl.plugin, "nfs", sizeof (vl.plugin)); - sstrncpy(vl.plugin_instance, plugin_instance, + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "nfs", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - sstrncpy(vl.type, "nfs_procedure", sizeof (vl.type)); + sstrncpy (vl.type, "nfs_procedure", sizeof (vl.type)); for (i = 0; i < values_num; i++) { @@ -317,7 +319,7 @@ static void nfs_read_linux (FILE *fh, char *inst) #if HAVE_LIBKSTAT static int nfs_read_kstat (kstat_t *ksp, int nfs_version, char *inst, - const char **proc_names, size_t proc_names_num) + char const **proc_names, size_t proc_names_num) { char plugin_instance[DATA_MAX_NAME_LEN]; value_t values[proc_names_num]; @@ -331,10 +333,18 @@ static int nfs_read_kstat (kstat_t *ksp, int nfs_version, char *inst, kstat_read(kc, ksp, NULL); for (i = 0; i < proc_names_num; i++) - values[i] = (derive_t) get_kstat_value (ksp, proc_names[i]); + { + /* The name passed to kstat_data_lookup() doesn't have the + * "const" modifier, so we need to copy the name here. */ + char name[32]; + sstrncpy (name, proc_names[i], sizeof (name)); + + values[i].counter = (derive_t) get_kstat_value (ksp, name); + } nfs_procedures_submit (plugin_instance, proc_names, values, proc_names_num); + return (0); } #endif