- char buf[BUFSIZE] = "";
-
- if (snprintf(buf, BUFSIZE, "%u:%u",
- (unsigned int)curtime,
- users) >= BUFSIZE)
- return;
-
- plugin_submit(MODULE_NAME, NULL, buf);
- return;
-}
-#undef BUFSIZE
-
-void users_write(host, inst, val)
- char *host;
- char *inst;
- char *val;
-{
- rrd_update_file(host, rrd_file, val, ds_def, ds_num);
- return;
-}
-
-void module_register(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)