projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
df: remove legacy code skipping "rootfs" monitoring
[collectd.git]
/
src
/
swap.c
diff --git
a/src/swap.c
b/src/swap.c
index
46d3534
..
8d8f752
100644
(file)
--- a/
src/swap.c
+++ b/
src/swap.c
@@
-160,6
+160,8
@@
static int swap_init (void) /* {{{ */
/* #endif defined(VM_SWAPUSAGE) */
#elif HAVE_LIBKVM_GETSWAPINFO
/* #endif defined(VM_SWAPUSAGE) */
#elif HAVE_LIBKVM_GETSWAPINFO
+ char errbuf[_POSIX2_LINE_MAX];
+
if (kvm_obj != NULL)
{
kvm_close (kvm_obj);
if (kvm_obj != NULL)
{
kvm_close (kvm_obj);
@@
-168,14
+170,11
@@
static int swap_init (void) /* {{{ */
kvm_pagesize = getpagesize ();
kvm_pagesize = getpagesize ();
- if ((kvm_obj = kvm_open (NULL, /* execfile */
- NULL, /* corefile */
- NULL, /* swapfile */
- O_RDONLY, /* flags */
- NULL)) /* errstr */
- == NULL)
+ kvm_obj = kvm_openfiles (NULL, "/dev/null", NULL, O_RDONLY, errbuf);
+
+ if (kvm_obj == NULL)
{
{
- ERROR ("swap plugin: kvm_open
failed."
);
+ ERROR ("swap plugin: kvm_open
files failed, %s", errbuf
);
return (-1);
}
/* #endif HAVE_LIBKVM_GETSWAPINFO */
return (-1);
}
/* #endif HAVE_LIBKVM_GETSWAPINFO */
@@
-339,7
+338,7
@@
static int swap_read_combined (void) /* {{{ */
fclose (fh);
fclose (fh);
- if (
have_data != 0x07
)
+ if (
(have_data & 0x03) != 0x03
)
return (ENOENT);
if (isnan (swap_total)
return (ENOENT);
if (isnan (swap_total)
@@
-351,7
+350,8
@@
static int swap_read_combined (void) /* {{{ */
swap_submit_gauge (NULL, "used", 1024.0 * swap_used);
swap_submit_gauge (NULL, "free", 1024.0 * swap_free);
swap_submit_gauge (NULL, "used", 1024.0 * swap_used);
swap_submit_gauge (NULL, "free", 1024.0 * swap_free);
- swap_submit_gauge (NULL, "cached", 1024.0 * swap_cached);
+ if (have_data & 0x04)
+ swap_submit_gauge (NULL, "cached", 1024.0 * swap_cached);
return (0);
} /* }}} int swap_read_combined */
return (0);
} /* }}} int swap_read_combined */
@@
-534,10
+534,10
@@
static int swap_read (void) /* {{{ */
return (0);
/* Allocate and initialize the swaptbl_t structure */
return (0);
/* Allocate and initialize the swaptbl_t structure */
- s =
(swaptbl_t *) s
malloc (swap_num * sizeof (swapent_t) + sizeof (struct swaptable));
+ s = malloc (swap_num * sizeof (swapent_t) + sizeof (struct swaptable));
if (s == NULL)
{
if (s == NULL)
{
- ERROR ("swap plugin:
s
malloc failed.");
+ ERROR ("swap plugin: malloc failed.");
return (-1);
}
return (-1);
}
@@
-547,7
+547,7
@@
static int swap_read (void) /* {{{ */
s_paths = calloc (swap_num, PATH_MAX);
if (s_paths == NULL)
{
s_paths = calloc (swap_num, PATH_MAX);
if (s_paths == NULL)
{
- ERROR ("swap plugin:
m
alloc failed.");
+ ERROR ("swap plugin:
c
alloc failed.");
sfree (s);
return (-1);
}
sfree (s);
return (-1);
}