X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fmrtg%2Fserv_mrtg.c;h=8eb9c53fdfe39faa1569da14dc1cf05fd80c4191;hb=3e8fdc8192b85bb7009405e6adef5e4b337b3a8e;hp=666e04a413561f976ea2468c53ddcc2fa0c211e2;hpb=5fbe6be7535361f2797b415fd0e32df4918097ec;p=citadel.git diff --git a/citadel/modules/mrtg/serv_mrtg.c b/citadel/modules/mrtg/serv_mrtg.c index 666e04a41..8eb9c53fd 100644 --- a/citadel/modules/mrtg/serv_mrtg.c +++ b/citadel/modules/mrtg/serv_mrtg.c @@ -109,6 +109,37 @@ void mrtg_messages(void) { } +struct num_accounts { + long total; + long active; +}; + +/* + * Helper function for mrtg_accounts() + */ +void tally_account(struct ctdluser *EachUser, void *userdata) +{ + struct num_accounts *n = (struct num_accounts *) userdata; + + ++n->total; + if ( (time(NULL) - EachUser->lastcall) <= 2592000 ) ++n->active; +} + + +/* + * Number of accounts and active accounts + */ +void mrtg_accounts(void) { + struct num_accounts n = { + 0, + 0 + }; + + ForEachUser(tally_account, (void *)&n ); + mrtg_output(n.total, n.active); +} + + /* * Fetch data for MRTG */ @@ -123,9 +154,11 @@ void cmd_mrtg(char *argbuf) { 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); + cprintf("%d Unrecognized keyword '%s'\n", ERROR + ILLEGAL_VALUE, which); } }