summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5faee1b)
raw | patch | inline | side by side (parent: 5faee1b)
author | Florian Forster <octo@collectd.org> | |
Wed, 29 Sep 2010 15:04:53 +0000 (17:04 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 29 Sep 2010 15:04:53 +0000 (17:04 +0200) |
src/contextswitch.c | patch | blob | history |
diff --git a/src/contextswitch.c b/src/contextswitch.c
index f571d39c39201c174d0cfea1ba68054a6565ad0d..c207318f9d62425fbfb18e7e86727bce62b65bcb 100644 (file)
--- a/src/contextswitch.c
+++ b/src/contextswitch.c
static int cs_read (void)
{
- int status = -2;
#if HAVE_SYSCTLBYNAME
- int value;
+ int value = 0;
size_t value_len = sizeof (value);
+ int status;
- if (sysctlbyname ("vm.stats.sys.v_swtch", (void *) &value, &value_len,
- NULL, 0) == 0)
- {
- cs_submit(value);
- status = 0;
- }
- else
+ status = sysctlbyname ("vm.stats.sys.v_swtch",
+ &value, &value_len,
+ /* new pointer = */ NULL, /* new length = */ 0);
+ if (status != 0)
{
- ERROR("contextswitch plugin: sysctlbyname failed");
+ ERROR("contextswitch plugin: sysctlbyname "
+ "(vm.stats.sys.v_swtch) failed");
+ return (-1);
}
+ cs_submit (value);
/* #endif HAVE_SYSCTLBYNAME */
+
#elif KERNEL_LINUX
FILE *fh;
char buffer[64];
int numfields;
char *fields[3];
derive_t result = 0;
+ int status = -2;
fh = fopen ("/proc/stat", "r");
if (fh == NULL) {