projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
contrib/php-collection: Add a PHP frontend for graph generation.
[collectd.git]
/
src
/
nfs.c
diff --git
a/src/nfs.c
b/src/nfs.c
index
efe1e02
..
91e6788
100644
(file)
--- a/
src/nfs.c
+++ b/
src/nfs.c
@@
-23,15
+23,9
@@
#include "collectd.h"
#include "common.h"
#include "plugin.h"
#include "collectd.h"
#include "common.h"
#include "plugin.h"
-#include "utils_debug.h"
-#define MODULE_NAME "nfs"
-
-/* #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
/*
#endif
/*
@@
-79,16
+73,6
@@
Number Procedures Procedures
21 commit
*/
21 commit
*/
-static data_source_t procedure_dsrc[1] =
-{
- {"value", DS_TYPE_COUNTER, 0, 4294967295.0}
-};
-
-static data_set_t procedure_ds =
-{
- "nfs_procedure", 1, procedure_dsrc
-};
-
static const char *nfs2_procedures_names[] =
{
"null",
static const char *nfs2_procedures_names[] =
{
"null",
@@
-194,25
+178,18
@@
static int nfs_init (void)
#endif
#define BUFSIZE 1024
#endif
#define BUFSIZE 1024
-#if NFS_HAVE_READ
static void nfs_procedures_submit (const char *plugin_instance,
unsigned long long *val, const char **names, int len)
{
value_t values[1];
static void nfs_procedures_submit (const char *plugin_instance,
unsigned long long *val, const char **names, int len)
{
value_t values[1];
- value_list_t vl;
+ value_list_t vl
= VALUE_LIST_INIT
;
int i;
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
int i;
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- /* FIXME: do this globally */
- if (gethostname (vl.host, sizeof (vl.host)) != 0)
- {
- syslog (LOG_ERR, "load plugin: gethostname failed: %s",
- strerror (errno));
- return;
- }
- strcpy (vl.plugin, "nfs");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "nfs", sizeof (vl.plugin));
strncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
strncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
@@
-221,15
+198,13
@@
static void nfs_procedures_submit (const char *plugin_instance,
values[0].counter = val[i];
strncpy (vl.type_instance, names[i],
sizeof (vl.type_instance));
values[0].counter = val[i];
strncpy (vl.type_instance, names[i],
sizeof (vl.type_instance));
- D
B
G ("%s-%s/nfs_procedure-%s = %llu",
+ D
EBU
G ("%s-%s/nfs_procedure-%s = %llu",
vl.plugin, vl.plugin_instance,
vl.type_instance, val[i]);
plugin_dispatch_values ("nfs_procedure", &vl);
}
} /* void nfs_procedures_submit */
vl.plugin, vl.plugin_instance,
vl.type_instance, val[i]);
plugin_dispatch_values ("nfs_procedure", &vl);
}
} /* void nfs_procedures_submit */
-#endif /* NFS_HAVE_READ */
-#if KERNEL_LINUX
static void nfs_read_stats_file (FILE *fh, char *inst)
{
char buffer[BUFSIZE];
static void nfs_read_stats_file (FILE *fh, char *inst)
{
char buffer[BUFSIZE];
@@
-258,7
+233,7
@@
static void nfs_read_stats_file (FILE *fh, char *inst)
if ((numfields - 2) != nfs2_procedures_names_num)
{
if ((numfields - 2) != nfs2_procedures_names_num)
{
-
syslog (LOG_WARNING,
"nfs plugin: Wrong "
+
WARNING (
"nfs plugin: Wrong "
"number of fields (= %i) "
"for NFSv2 statistics.",
numfields - 2);
"number of fields (= %i) "
"for NFSv2 statistics.",
numfields - 2);
@@
-272,9
+247,10
@@
static void nfs_read_stats_file (FILE *fh, char *inst)
values = (unsigned long long *) malloc (nfs2_procedures_names_num * sizeof (unsigned long long));
if (values == NULL)
{
values = (unsigned long long *) malloc (nfs2_procedures_names_num * sizeof (unsigned long long));
if (values == NULL)
{
- syslog (LOG_ERR, "nfs plugin: malloc "
+ char errbuf[1024];
+ ERROR ("nfs plugin: malloc "
"failed: %s",
"failed: %s",
- s
trerror (errno
));
+ s
strerror (errno, errbuf, sizeof (errbuf)
));
continue;
}
continue;
}
@@
-294,7
+270,7
@@
static void nfs_read_stats_file (FILE *fh, char *inst)
if ((numfields - 2) != nfs3_procedures_names_num)
{
if ((numfields - 2) != nfs3_procedures_names_num)
{
-
syslog (LOG_WARNING,
"nfs plugin: Wrong "
+
WARNING (
"nfs plugin: Wrong "
"number of fields (= %i) "
"for NFSv3 statistics.",
numfields - 2);
"number of fields (= %i) "
"for NFSv3 statistics.",
numfields - 2);
@@
-308,9
+284,10
@@
static void nfs_read_stats_file (FILE *fh, char *inst)
values = (unsigned long long *) malloc (nfs3_procedures_names_num * sizeof (unsigned long long));
if (values == NULL)
{
values = (unsigned long long *) malloc (nfs3_procedures_names_num * sizeof (unsigned long long));
if (values == NULL)
{
- syslog (LOG_ERR, "nfs plugin: malloc "
+ char errbuf[1024];
+ ERROR ("nfs plugin: malloc "
"failed: %s",
"failed: %s",
- s
trerror (errno
));
+ s
strerror (errno, errbuf, sizeof (errbuf)
));
continue;
}
continue;
}
@@
-325,7
+302,6
@@
static void nfs_read_stats_file (FILE *fh, char *inst)
}
} /* while (fgets (buffer, BUFSIZE, fh) != NULL) */
} /* void nfs_read_stats_file */
}
} /* while (fgets (buffer, BUFSIZE, fh) != NULL) */
} /* void nfs_read_stats_file */
-#endif /* defined(KERNEL_LINUX) */
#undef BUFSIZE
#if HAVE_LIBKSTAT && 0
#undef BUFSIZE
#if HAVE_LIBKSTAT && 0
@@
-356,10
+332,8
@@
static void nfs2_read_kstat (kstat_t *ksp, char *inst)
}
#endif
}
#endif
-#if NFS_HAVE_READ
static int nfs_read (void)
{
static int nfs_read (void)
{
-#if KERNEL_LINUX
FILE *fh;
if ((fh = fopen ("/proc/net/rpc/nfs", "r")) != NULL)
FILE *fh;
if ((fh = fopen ("/proc/net/rpc/nfs", "r")) != NULL)
@@
-374,9
+348,7
@@
static int nfs_read (void)
fclose (fh);
}
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)
if (nfs2_ksp_client != NULL)
nfs2_read_kstat (nfs2_ksp_client, "client");
if (nfs2_ksp_server != NULL)
@@
-385,15
+357,8
@@
static int nfs_read (void)
return (0);
}
return (0);
}
-#endif /* NFS_HAVE_READ */
void module_register (void)
{
void module_register (void)
{
- plugin_register_data_set (&procedure_ds);
-
-#if NFS_HAVE_READ
plugin_register_read ("nfs", nfs_read);
plugin_register_read ("nfs", nfs_read);
-#endif
-}
-
-#undef MODULE_NAME
+} /* void module_register */