From 99a1ea0892b575c6d66d9f4c0aab5042c261ce4a Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 8 May 2008 22:40:11 +0000 Subject: Add call to protocol interface to get useful info on the server map. Return a std::list of classes each of which has a server name, parent server name, user and oper count, and latency in millisecs git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9673 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_httpd_stats.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src/modules/m_httpd_stats.cpp') diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index d95824c83..aa64dc3ea 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -13,6 +13,7 @@ #include "inspircd.h" #include "httpd.h" +#include "protocol.h" /* $ModDesc: Provides statistics over HTTP via m_httpd.so */ /* $ModDep: httpd.h */ @@ -26,8 +27,6 @@ typedef SortedList::iterator SortedIter; static StatsHash* sh = new StatsHash(); static SortedList* so = new SortedList(); -static StatsHash* Servers = new StatsHash(); - class ModuleHttpStats : public Module { @@ -73,18 +72,6 @@ class ModuleHttpStats : public Module so->clear(); for (StatsIter a = sh->begin(); a != sh->end(); a++) InsertOrder(a->first, a->second); - for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) - { - StatsHash::iterator n = Servers->find(u->second->server); - if (n != Servers->end()) - { - n->second++; - } - else - { - Servers->insert(std::make_pair(u->second->server,1)); - } - } this->changed = false; } @@ -156,11 +143,17 @@ class ModuleHttpStats : public Module data << ""; - for (StatsHash::iterator b = Servers->begin(); b != Servers->end(); b++) + ProtoServerList sl; + ServerInstance->PI->GetServerList(sl); + + for (ProtoServerList::iterator b = sl.begin(); b != sl.end(); ++b) { data << ""; - data << "" << b->first << ""; - data << "" << b->second << ""; + data << "" << b->servername << ""; + data << "" << b->parentname << ""; + data << "" << b->usercount << ""; + data << "" << b->opercount << ""; + data << "" << b->latencyms << ""; data << ""; } data << ""; -- cgit v1.3.1-10-gc9f91