]> jfr.im git - solanum.git/blobdiff - modules/m_stats.c
modules: chase MsgBuf API change
[solanum.git] / modules / m_stats.c
index ce0f14d743809eb94bc2b534b73846ffa91b3b49..63f9dc1f290a9d7e92b8e0f8c922a6c2c2a4383d 100644 (file)
@@ -49,8 +49,9 @@
 #include "reject.h"
 #include "whowas.h"
 #include "irc_radixtree.h"
+#include "sslproc.h"
 
-static int m_stats (struct Client *, struct Client *, int, const char **);
+static int m_stats (struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message stats_msgtab = {
        "STATS", 0, 0, 0, MFLG_SLOW,
@@ -76,7 +77,7 @@ static void stats_l_list(struct Client *s, const char *, int, int, rb_dlink_list
 static void stats_l_client(struct Client *source_p, struct Client *target_p,
                                char statchar);
 
-static void stats_spy(struct Client *, char, const char *);
+static int stats_spy(struct Client *, char, const char *);
 static void stats_p_spy(struct Client *);
 
 /* Heres our struct for the stats table */
@@ -109,6 +110,7 @@ static void stats_operedup(struct Client *);
 static void stats_ports(struct Client *);
 static void stats_tresv(struct Client *);
 static void stats_resv(struct Client *);
+static void stats_ssld(struct Client *);
 static void stats_usage(struct Client *);
 static void stats_tstats(struct Client *);
 static void stats_uptime(struct Client *);
@@ -162,6 +164,8 @@ static struct StatsStruct stats_cmd_table[] = {
        {'Q', stats_resv,               1, 0, },
        {'r', stats_usage,              1, 0, },
        {'R', stats_usage,              1, 0, },
+       {'s', stats_ssld,               1, 1, },
+       {'S', stats_ssld,               1, 1, },
        {'t', stats_tstats,             1, 0, },
        {'T', stats_tstats,             1, 0, },
        {'u', stats_uptime,             0, 0, },
@@ -187,11 +191,12 @@ static struct StatsStruct stats_cmd_table[] = {
  * if found execute it.
  */
 static int
-m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_stats(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        static time_t last_used = 0;
        int i;
        char statchar;
+       int did_stats = 0;
 
        statchar = parv[1][0];
 
@@ -215,7 +220,11 @@ m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *
                return 0;
 
        if((statchar != 'L') && (statchar != 'l'))
-               stats_spy(source_p, statchar, NULL);
+               did_stats = stats_spy(source_p, statchar, NULL);
+
+       /* if did_stats is true, a module grabbed this STATS request */
+       if (did_stats)
+               goto stats_out;
 
        for (i = 0; stats_cmd_table[i].letter; i++)
        {
@@ -246,6 +255,7 @@ m_stats(struct Client *client_p, struct Client *source_p, int parc, const char *
                }
        }
 
+stats_out:
        /* Send the end of stats notice, and the stats_spy */
        sendto_one_numeric(source_p, RPL_ENDOFSTATS,
                           form_str(RPL_ENDOFSTATS), statchar);
@@ -281,12 +291,10 @@ stats_hash_cb(const char *buf, void *client_p)
 static void
 stats_hash(struct Client *source_p)
 {
-       hash_stats(source_p);
+       sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :%-30s %-15s %-10s %-10s %-10s %-10s",
+               "NAME", "TYPE", "OBJECTS", "DEPTH SUM", "AVG DEPTH", "MAX DEPTH");
 
-       sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :Dictionary stats:");
        irc_dictionary_stats_walk(stats_hash_cb, source_p);
-
-       sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :Radix tree stats:");
        irc_radixtree_stats_walk(stats_hash_cb, source_p);
 }
 
@@ -880,6 +888,26 @@ stats_resv(struct Client *source_p)
        }
 }
 
+static void
+stats_ssld_foreach(void *data, pid_t pid, int cli_count, enum ssld_status status)
+{
+       struct Client *source_p = data;
+
+       sendto_one_numeric(source_p, RPL_STATSDEBUG,
+                       "S :%u %c %u",
+                       pid,
+                       status == SSLD_DEAD ? 'D' : (status == SSLD_SHUTDOWN ? 'S' : 'A'),
+                       cli_count);
+}
+
+static void
+stats_ssld(struct Client *source_p)
+{
+#if 0
+       ssld_foreach_info(stats_ssld_foreach, source_p);
+#endif
+}
+
 static void
 stats_usage (struct Client *source_p)
 {
@@ -1055,6 +1083,8 @@ static struct shared_flags shared_flagtable[] =
        { SHARED_TDLINE,        'd' },
        { SHARED_PDLINE,        'D' },
        { SHARED_UNDLINE,       'E' },
+       { SHARED_GRANT,         'G' },
+       { SHARED_DIE,           'I' },
        { 0,                    '\0'}
 };
 
@@ -1261,7 +1291,7 @@ stats_memory (struct Client *source_p)
 
        size_t total_memory = 0;
 
-       count_whowas_memory(&ww, &wwm);
+       whowas_memory_usage(&ww, &wwm);
 
        RB_DLINK_FOREACH(ptr, global_client_list.head)
        {
@@ -1711,7 +1741,7 @@ stats_comm(struct Client *source_p)
  * any damage with stats requests now anyway. So, why show them?
  * -Dianora
  */
-static void
+static int
 stats_spy(struct Client *source_p, char statchar, const char *name)
 {
        hook_data_int data;
@@ -1719,8 +1749,11 @@ stats_spy(struct Client *source_p, char statchar, const char *name)
        data.client = source_p;
        data.arg1 = name;
        data.arg2 = (int) statchar;
+       data.result = 0;
 
        call_hook(doing_stats_hook, &data);
+
+       return data.result;
 }
 
 /* stats_p_spy()