From 64573ae3a98b0161df8dd961d59113a796013771 Mon Sep 17 00:00:00 2001 From: Oleg King Date: Mon, 5 May 2008 14:21:37 +0200 Subject: [PATCH] users plugin: Add support for the statgrab library. --- configure.in | 1 + src/Makefile.am | 4 ++++ src/users.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/configure.in b/configure.in index e95f99d6..7477f419 100644 --- a/configure.in +++ b/configure.in @@ -2337,6 +2337,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 --git a/src/Makefile.am b/src/Makefile.am index 88041b99..2618ba9e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -642,6 +642,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 --git a/src/users.c b/src/users.c index afe26e1e..4686443e 100644 --- a/src/users.c +++ b/src/users.c @@ -23,6 +23,10 @@ #include "common.h" #include "plugin.h" +#if HAVE_STATGRAB_H +# include +#endif /* HAVE_STATGRAB_H */ + #if HAVE_UTMPX_H # include /* #endif HAVE_UTMPX_H */ @@ -89,6 +93,16 @@ static int users_read (void) users_submit (users); /* #endif HAVE_GETUTENT */ +#elif HAVE_LIBSTATGRAB + sg_user_stats *us; + + us = sg_get_user_stats (); + if (us == NULL) + return (-1); + + users_submit ((gauge_t) us->num_entries); +/* #endif HAVE_LIBSTATGRAB */ + #else # error "No applicable input method." #endif -- 2.11.0