[collectd] users plugin patch

Oleg King king2 at kaluga.ru
Thu May 1 19:00:44 CEST 2008


Hello!

  Here is a patch for users plugin to allow it to use libstatgrab
  when no other way to get information about users:

diff -pur collectd/configure.in collectd.my/configure.in
--- collectd/configure.in       2008-05-01 20:36:37.000000000 +0400
+++ collectd.my/configure.in    2008-05-01 20:43:20.000000000 +0400
@@ -2336,6 +2336,7 @@ then 
        plugin_load="yes"  
        plugin_memory="yes"
        plugin_swap="yes"
+       plugin_users="yes"
 fi
 
 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
diff -pur collectd/src/Makefile.am collectd.my/src/Makefile.am
--- collectd/src/Makefile.am    2008-05-01 20:36:37.000000000 +0400
+++ collectd.my/src/Makefile.am 2008-05-01 20:52:19.000000000 +0400
@@ -638,6 +638,10 @@ if BUILD_PLUGIN_USERS
 pkglib_LTLIBRARIES += users.la
 users_la_SOURCES = users.c
 users_la_LDFLAGS = -module -avoid-version
+if BUILD_WITH_LIBSTATGRAB
+users_la_CFLAGS = $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+users_la_LIBADD = $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
 collectd_LDADD += "-dlopen" users.la
 collectd_DEPENDENCIES += users.la
 endif
diff -pur collectd/src/users.c collectd.my/src/users.c
--- collectd/src/users.c        2008-05-01 20:36:37.000000000 +0400
+++ collectd.my/src/users.c     2008-05-01 20:56:54.000000000 +0400
@@ -23,6 +23,10 @@
 #include "common.h"
 #include "plugin.h"   
 
+#if HAVE_STATGRAB_H
+# include <statgrab.h>
+#endif /* HAVE_STATGRAB_H */
+
 #if HAVE_UTMPX_H
 # include <utmpx.h>
 /* #endif HAVE_UTMPX_H */   
@@ -90,6 +94,15 @@ static int users_read (void)
        users_submit (users);
 /* #endif HAVE_GETUTENT */
 
+#elif HAVE_LIBSTATGRAB
+        sg_user_stats *us;
+
+        if ((us = sg_get_user_stats()) == NULL) 
+               return (0);   
+
+       users_submit ((gauge_t) us->num_entries);
+/* #endif HAVE_LIBSTATGRAB */
+
 #else
 # error "No applicable input method."
 #endif

-- 
WBR,
 Oleg                          mailto:king2 at kaluga.ru




More information about the collectd mailing list