[PATCH 1/4] mon: Make mon compilable with libstatgrab ver 0.9

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 configure.ac |    2 ++
 exec/mon.c   |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 523d2cf..2defc88 100644
--- a/configure.ac
+++ b/configure.ac
@@ -428,6 +428,8 @@ fi
 
 if test "x${enable_monitoring}" = xyes; then
 	PKG_CHECK_MODULES([statgrab], [libstatgrab])
+	PKG_CHECK_MODULES([statgrab], [libstatgrab >= 0.90],
+	    AC_DEFINE([HAVE_LIBSTATGRAB_GE_090], 1, [have libstatgrab >= 0.90]))
 	AC_DEFINE_UNQUOTED([HAVE_MONITORING], 1, [have resource monitoring])
 	PACKAGE_FEATURES="$PACKAGE_FEATURES monitoring"
 	WITH_LIST="$WITH_LIST --with monitoring"
diff --git a/exec/mon.c b/exec/mon.c
index 49c46b4..ab16a47 100644
--- a/exec/mon.c
+++ b/exec/mon.c
@@ -307,8 +307,13 @@ static int32_t percent_mem_used_get(void)
 	sg_swap_stats *swap_stats;
 	long long total, freemem;
 
+#ifdef HAVE_LIBSTATGRAB_GE_090
+	mem_stats = sg_get_mem_stats(NULL);
+	swap_stats = sg_get_swap_stats(NULL);
+#else
 	mem_stats = sg_get_mem_stats();
 	swap_stats = sg_get_swap_stats();
+#endif
 
 	if (mem_stats == NULL || swap_stats != NULL) {
 		log_printf (LOGSYS_LEVEL_ERROR, "Unable to get memory stats: %s",
@@ -348,7 +353,12 @@ static void mem_update_stats_fn (void *data)
 static double min15_loadavg_get(void)
 {
 	sg_load_stats *load_stats;
+
+#ifdef HAVE_LIBSTATGRAB_GE_090
+	load_stats = sg_get_load_stats (NULL);
+#else
 	load_stats = sg_get_load_stats ();
+#endif
 	if (load_stats == NULL) {
 		log_printf (LOGSYS_LEVEL_ERROR, "Unable to get load stats: %s",
 			sg_str_error (sg_get_error()));
@@ -463,7 +473,11 @@ static void mon_instance_init (struct resource_instance* inst)
 
 static char *mon_exec_init_fn (struct corosync_api_v1 *corosync_api)
 {
+#ifdef HAVE_LIBSTATGRAB_GE_090
+	sg_init(1);
+#else
 	sg_init();
+#endif
 
 	api = corosync_api;
 
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux