]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_mrtg.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_mrtg.c
index d74b95f9ac76b82f8b84ee07587ed6a8905c84d2..12e09f0f0ec89c96c93b5b005ae21c4ae37627d4 100644 (file)
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
 #include "control.h"
-#include "dynloader.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
@@ -49,6 +47,9 @@
 #include "tools.h"
 
 
+#include "ctdl_module.h"
+
+
 /*
  * Other functions call this one to output data in MRTG format
  */
@@ -84,10 +85,12 @@ void mrtg_users(void) {
 
         for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
 
-               ++connected_users;
+               if (cptr->internal_pgm == 0) {
+                       ++connected_users;
 
-               if ( (time(NULL) - (cptr->lastidle)) < 900L) {
-                       ++active_users;
+                       if ( (time(NULL) - (cptr->lastidle)) < 900L) {
+                               ++active_users;
+                       }
                }
 
        }
@@ -108,25 +111,27 @@ void mrtg_messages(void) {
  * Fetch data for MRTG
  */
 void cmd_mrtg(char *argbuf) {
-       char which[SIZ];
+       char which[32];
 
-       extract(which, argbuf, 0);
+       extract_token(which, argbuf, 0, '|', sizeof which);
 
        if (!strcasecmp(which, "users")) {
                mrtg_users();
        }
-       if (!strcasecmp(which, "messages")) {
+       else if (!strcasecmp(which, "messages")) {
                mrtg_messages();
        }
        else {
                cprintf("%d Unrecognized keyword '%s'\n",
-                       ERROR+ILLEGAL_VALUE, which);
+                       ERROR + ILLEGAL_VALUE, which);
        }
 }
 
 
-char *Dynamic_Module_Init(void)
+CTDL_MODULE_INIT(mrtg)
 {
         CtdlRegisterProtoHook(cmd_mrtg, "MRTG", "Supply stats to MRTG");
+
+       /* return our Subversion id for the Log */
         return "$Id$";
 }