Back to index

citadel  8.12
Classes | Functions
serv_mrtg.c File Reference
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <pwd.h>
#include <errno.h>
#include <sys/types.h>
#include <time.h>
#include <sys/wait.h>
#include <string.h>
#include <limits.h>
#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "support.h"
#include "config.h"
#include "control.h"
#include "user_ops.h"
#include "database.h"
#include "msgbase.h"
#include "ctdl_module.h"

Go to the source code of this file.

Classes

struct  num_accounts

Functions

void mrtg_output (long value1, long value2)
void mrtg_users (void)
void mrtg_messages (void)
void tally_account (struct ctdluser *EachUser, void *userdata)
void mrtg_accounts (void)
void cmd_mrtg (char *argbuf)
 CTDL_MODULE_INIT (mrtg)

Class Documentation

struct num_accounts

Definition at line 123 of file serv_mrtg.c.

Class Members
long active
long total

Function Documentation

void cmd_mrtg ( char *  argbuf)

Definition at line 157 of file serv_mrtg.c.

                            {
       char which[32];

       extract_token(which, argbuf, 0, '|', sizeof which);

       if (!strcasecmp(which, "users")) {
              mrtg_users();
       }
       else if (!strcasecmp(which, "messages")) {
              mrtg_messages();
       }
       else if (!strcasecmp(which, "accounts")) {
              mrtg_accounts();
       }
       else {
              cprintf("%d Unrecognized keyword '%s'\n", ERROR + ILLEGAL_VALUE, which);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

CTDL_MODULE_INIT ( mrtg  )

Definition at line 177 of file serv_mrtg.c.

{
       if (!threading)
       {
               CtdlRegisterProtoHook(cmd_mrtg, "MRTG", "Supply stats to MRTG");
       }
       
       /* return our module name for the log */
        return "mrtg";
}

Here is the call graph for this function:

void mrtg_accounts ( void  )

Definition at line 143 of file serv_mrtg.c.

                         {
       struct num_accounts n = {
              0,
              0
       };

       ForEachUser(tally_account, (void *)&n );
       mrtg_output(n.total, n.active);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mrtg_messages ( void  )

Definition at line 118 of file serv_mrtg.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void mrtg_output ( long  value1,
long  value2 
)

Definition at line 67 of file serv_mrtg.c.

                                           {
       time_t uptime_t;
       int uptime_days, uptime_hours, uptime_minutes;
       
       uptime_t = time(NULL) - server_startup_time;
       uptime_days = (int) (uptime_t / 86400L);
       uptime_hours = (int) ((uptime_t % 86400L) / 3600L);
       uptime_minutes = (int) ((uptime_t % 3600L) / 60L);

       cprintf("%d ok\n", LISTING_FOLLOWS);
       cprintf("%ld\n", value1);
       cprintf("%ld\n", value2);
       cprintf("%d days, %d hours, %d minutes\n",
              uptime_days, uptime_hours, uptime_minutes);
       cprintf("%s\n", config.c_humannode);
       cprintf("000\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mrtg_users ( void  )

Definition at line 91 of file serv_mrtg.c.

                      {
       long connected_users = 0;
       long active_users = 0;
       
       struct CitContext *cptr;

       begin_critical_section(S_SESSION_TABLE);
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {

              if (cptr->internal_pgm == 0) {
                     ++connected_users;

                     if ( (time(NULL) - (cptr->lastidle)) < 900L) {
                            ++active_users;
                     }
              }

       }
       end_critical_section(S_SESSION_TABLE);
       
       mrtg_output(connected_users, active_users);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tally_account ( struct ctdluser EachUser,
void *  userdata 
)

Definition at line 131 of file serv_mrtg.c.

{
       struct num_accounts *n = (struct num_accounts *) userdata;

       ++n->total;
       if ( (time(NULL) - EachUser->lastcall) <= 2592000 ) ++n->active;
}

Here is the caller graph for this function: