X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnfs.c;h=f3c636ecce9cd14aead260b9cfdd3149750b5c31;hb=aff80830f1154a5b6c4da16a0b1033aafde14e24;hp=299d63b9e4b98e56363770eb7003850ea3621f87;hpb=c493010e9f1a6537dca21be2290bc28051ad0efc;p=collectd.git diff --git a/src/nfs.c b/src/nfs.c index 299d63b9..f3c636ec 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -24,11 +24,8 @@ #include "common.h" #include "plugin.h" -/* #if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) */ -#if KERNEL_LINUX -# define NFS_HAVE_READ 1 -#else -# define NFS_HAVE_READ 0 +#if !KERNEL_LINUX +# error "No applicable input method." #endif /* @@ -76,7 +73,6 @@ Number Procedures Procedures 21 commit */ -#if NFS_HAVE_READ static const char *nfs2_procedures_names[] = { "null", @@ -191,25 +187,24 @@ static void nfs_procedures_submit (const char *plugin_instance, vl.values = values; vl.values_len = 1; - vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "nfs"); - strncpy (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)); for (i = 0; i < len; i++) { - values[0].counter = val[i]; - strncpy (vl.type_instance, names[i], + values[0].derive = val[i]; + sstrncpy (vl.type_instance, names[i], sizeof (vl.type_instance)); DEBUG ("%s-%s/nfs_procedure-%s = %llu", vl.plugin, vl.plugin_instance, vl.type_instance, val[i]); - plugin_dispatch_values ("nfs_procedure", &vl); + plugin_dispatch_values (&vl); } } /* void nfs_procedures_submit */ -#if KERNEL_LINUX static void nfs_read_stats_file (FILE *fh, char *inst) { char buffer[BUFSIZE]; @@ -245,9 +240,8 @@ static void nfs_read_stats_file (FILE *fh, char *inst) continue; } - snprintf (plugin_instance, sizeof (plugin_instance), + ssnprintf (plugin_instance, sizeof (plugin_instance), "v2%s", inst); - plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0'; values = (unsigned long long *) malloc (nfs2_procedures_names_num * sizeof (unsigned long long)); if (values == NULL) @@ -282,9 +276,8 @@ static void nfs_read_stats_file (FILE *fh, char *inst) continue; } - snprintf (plugin_instance, sizeof (plugin_instance), + ssnprintf (plugin_instance, sizeof (plugin_instance), "v3%s", inst); - plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0'; values = (unsigned long long *) malloc (nfs3_procedures_names_num * sizeof (unsigned long long)); if (values == NULL) @@ -307,7 +300,6 @@ static void nfs_read_stats_file (FILE *fh, char *inst) } } /* while (fgets (buffer, BUFSIZE, fh) != NULL) */ } /* void nfs_read_stats_file */ -#endif /* defined(KERNEL_LINUX) */ #undef BUFSIZE #if HAVE_LIBKSTAT && 0 @@ -340,7 +332,6 @@ static void nfs2_read_kstat (kstat_t *ksp, char *inst) static int nfs_read (void) { -#if KERNEL_LINUX FILE *fh; if ((fh = fopen ("/proc/net/rpc/nfs", "r")) != NULL) @@ -355,9 +346,7 @@ static int nfs_read (void) fclose (fh); } -/* #endif defined(KERNEL_LINUX) */ - -#elif HAVE_LIBKSTAT && 0 +#if HAVE_LIBKSTAT && 0 if (nfs2_ksp_client != NULL) nfs2_read_kstat (nfs2_ksp_client, "client"); if (nfs2_ksp_server != NULL) @@ -366,11 +355,8 @@ static int nfs_read (void) return (0); } -#endif /* NFS_HAVE_READ */ void module_register (void) { -#if NFS_HAVE_READ plugin_register_read ("nfs", nfs_read); -#endif } /* void module_register */