summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e8653eb)
raw | patch | inline | side by side (parent: e8653eb)
author | Manuel Sanmartin (no email) <collectd@verplant.org> | |
Mon, 23 Nov 2009 21:10:48 +0000 (22:10 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 23 Nov 2009 21:23:18 +0000 (22:23 +0100) |
src/memory.c | patch | blob | history |
diff --git a/src/memory.c b/src/memory.c
index 799a80c31684c963172fa89363e9f931c24f4886..fa622f9ceb045496c290d53eb3da973b7ef1316d 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
* collectd - src/memory.c
* Copyright (C) 2005-2008 Florian octo Forster
* Copyright (C) 2009 Simon Kuhnle
+ * Copyright (C) 2009 Manuel Sanmartin
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Authors:
* Florian octo Forster <octo at verplant.org>
* Simon Kuhnle <simon at blarzwurst.de>
+ * Manuel Sanmartin
**/
#include "collectd.h"
# include <statgrab.h>
#endif
+#if HAVE_PERFSTAT
+# include <sys/protosw.h>
+# include <libperfstat.h>
+#endif /* HAVE_PERFSTAT */
+
/* vm_statistics_data_t */
#if HAVE_HOST_STATISTICS
static mach_port_t port_host;
#elif HAVE_LIBSTATGRAB
/* no global variables */
/* endif HAVE_LIBSTATGRAB */
-
+#elif HAVE_PERFSTAT
+static int pagesize;
+static perfstat_memory_total_t pmemory;
+/* endif HAVE_PERFSTAT */
#else
# error "No applicable input method."
#endif
#elif HAVE_LIBSTATGRAB
/* no init stuff */
-#endif /* HAVE_LIBSTATGRAB */
+/* #endif HAVE_LIBSTATGRAB */
+#elif HAVE_PERFSTAT
+ pagesize = getpagesize ();
+#endif /* HAVE_PERFSTAT */
return (0);
} /* int memory_init */
memory_submit ("cached", ios->cache);
memory_submit ("free", ios->free);
}
-#endif /* HAVE_LIBSTATGRAB */
+/* #endif HAVE_LIBSTATGRAB */
+
+#elif HAVE_PERFSTAT
+ if (perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1) < 0)
+ {
+ char errbuf[1024];
+ WARNING ("memory plugin: perfstat_memory_total failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+ memory_submit ("used", pmemory.real_inuse * pagesize);
+ memory_submit ("free", pmemory.real_free * pagesize);
+ memory_submit ("cached", pmemory.numperm * pagesize);
+ memory_submit ("system", pmemory.real_system * pagesize);
+ memory_submit ("user", pmemory.real_process * pagesize);
+#endif /* HAVE_PERFSTAT */
return (0);
}