projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/Makefile.am: Added utils_cmd_putval to exec_la_SOURCES.
[collectd.git]
/
src
/
swap.c
diff --git
a/src/swap.c
b/src/swap.c
index
f03a5a9
..
4a414b7
100644
(file)
--- a/
src/swap.c
+++ b/
src/swap.c
@@
-36,26
+36,9
@@
# include <kvm.h>
#endif
# include <kvm.h>
#endif
-#if KERNEL_LINUX || HAVE_LIBKSTAT || defined(VM_SWAPUSAGE) || HAVE_LIBKVM || HAVE_LIBSTATGRAB
-# define SWAP_HAVE_READ 1
-#else
-# define SWAP_HAVE_READ 0
-#endif
-
#undef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#undef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
-static data_source_t data_source[1] =
-{
- {"value", DS_TYPE_GAUGE, 0, 1099511627776.0}
-};
-
-static data_set_t data_set =
-{
- "swap", 1, data_source
-};
-
-#if SWAP_HAVE_READ
#if KERNEL_LINUX
/* No global variables */
/* #endif KERNEL_LINUX */
#if KERNEL_LINUX
/* No global variables */
/* #endif KERNEL_LINUX */
@@
-76,6
+59,10
@@
int kvm_pagesize;
#elif HAVE_LIBSTATGRAB
/* No global variables */
#elif HAVE_LIBSTATGRAB
/* No global variables */
+/* #endif HAVE_LIBSTATGRAB */
+
+#else
+# error "No applicable input method."
#endif /* HAVE_LIBSTATGRAB */
static int swap_init (void)
#endif /* HAVE_LIBSTATGRAB */
static int swap_init (void)
@@
-111,7
+98,7
@@
static int swap_init (void)
NULL)) /* errstr */
== NULL)
{
NULL)) /* errstr */
== NULL)
{
-
syslog (LOG_ERR,
"swap plugin: kvm_open failed.");
+
ERROR (
"swap plugin: kvm_open failed.");
return (-1);
}
/* #endif HAVE_LIBKVM */
return (-1);
}
/* #endif HAVE_LIBKVM */
@@
-133,7
+120,7
@@
static void swap_submit (const char *type_instance, double value)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname);
+ strcpy (vl.host, hostname
_g
);
strcpy (vl.plugin, "swap");
strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
strcpy (vl.plugin, "swap");
strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
@@
-156,7
+143,9
@@
static int swap_read (void)
if ((fh = fopen ("/proc/meminfo", "r")) == NULL)
{
if ((fh = fopen ("/proc/meminfo", "r")) == NULL)
{
- syslog (LOG_WARNING, "memory: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("memory: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
return (-1);
}
@@
-182,7
+171,11
@@
static int swap_read (void)
}
if (fclose (fh))
}
if (fclose (fh))
- syslog (LOG_WARNING, "memory: fclose: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ WARNING ("memory: fclose: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
if ((swap_total == 0LL) || ((swap_free + swap_cached) > swap_total))
return (-1);
if ((swap_total == 0LL) || ((swap_free + swap_cached) > swap_total))
return (-1);
@@
-203,8
+196,9
@@
static int swap_read (void)
if (swapctl (SC_AINFO, &ai) == -1)
{
if (swapctl (SC_AINFO, &ai) == -1)
{
- syslog (LOG_ERR, "swap plugin: swapctl failed: %s",
- strerror (errno));
+ char errbuf[1024];
+ ERROR ("swap plugin: swapctl failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
return (-1);
}
@@
-303,14
+297,9
@@
static int swap_read (void)
return (0);
} /* int swap_read */
return (0);
} /* int swap_read */
-#endif /* SWAP_HAVE_READ */
void module_register (void)
{
void module_register (void)
{
- plugin_register_data_set (&data_set);
-
-#if SWAP_HAVE_READ
plugin_register_init ("swap", swap_init);
plugin_register_read ("swap", swap_read);
plugin_register_init ("swap", swap_init);
plugin_register_read ("swap", swap_read);
-#endif /* SWAP_HAVE_READ */
-}
+} /* void module_register */