+static int users_read (void)
+{
+#if HAVE_GETUTXENT
+ unsigned int users = 0;
+ struct utmpx *entry = NULL;
+
+ /* according to the *utent(3) man page none of the functions sets errno
+ in case of an error, so we cannot do any error-checking here */
+ setutxent();
+
+ while (NULL != (entry = getutxent())) {
+ if (USER_PROCESS == entry->ut_type) {
+ ++users;
+ }
+ }
+ endutxent();
+
+ users_submit (users);
+/* #endif HAVE_GETUTXENT */
+
+#elif HAVE_GETUTENT
+ unsigned int users = 0;
+ struct utmp *entry = NULL;
+
+ /* according to the *utent(3) man page none of the functions sets errno
+ in case of an error, so we cannot do any error-checking here */
+ setutent();
+
+ while (NULL != (entry = getutent())) {
+ if (USER_PROCESS == entry->ut_type) {
+ ++users;
+ }
+ }
+ endutent();
+
+ users_submit (users);
+#endif /* HAVE_GETUTENT */
+
+ return (0);
+} /* int users_read */
+#endif /* USERS_HAVE_READ */
+
+void module_register (void)
+{
+#if USERS_HAVE_READ
+ plugin_register_read ("users", users_read);
+#endif
+} /* void module_register(void) */