]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd_stats.cpp
Fix for last nights blockcaps tweak to make it a little more accurate
[user/henk/code/inspircd.git] / src / modules / m_httpd_stats.cpp
index de72dc339ff23409da48e0ed9df81ca4e4ed614c..aa64dc3eabc63783a30a82f9cf38f91632bacae7 100644 (file)
@@ -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->clientlist->begin(); u != ServerInstance->clientlist->end(); u++)
-               {
-                       StatsHash::iterator n = Servers->find(u->second->server);
-                       if (n != Servers->end())
-                       {
-                               n->second++;
-                       }
-                       else
-                       {
-                               Servers->insert(std::make_pair<irc::string,int>(u->second->server,1));
-                       }
-               }
                this->changed = false;
        }
 
@@ -94,6 +81,7 @@ class ModuleHttpStats : public Module
 
                if (event->GetEventID() == "httpd_url")
                {
+                       ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
                        HTTPRequest* http = (HTTPRequest*)event->GetData();
 
                        if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))
@@ -103,9 +91,9 @@ class ModuleHttpStats : public Module
                                data << "<server><name>" << ServerInstance->Config->ServerName << "</name><gecos>" << ServerInstance->Config->ServerDesc << "</gecos></server>";
 
                                data << "<general>";
-                               data << "<usercount>" << ServerInstance->clientlist->size() << "</usercount>";
+                               data << "<usercount>" << ServerInstance->Users->clientlist->size() << "</usercount>";
                                data << "<channelcount>" << ServerInstance->chanlist->size() << "</channelcount>";
-                               data << "<opercount>" << ServerInstance->all_opers.size() << "</opercount>";
+                               data << "<opercount>" << ServerInstance->Users->all_opers.size() << "</opercount>";
                                data << "<socketcount>" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << "</socketcount><socketmax>" << ServerInstance->SE->GetMaxFds() <<
                                        "</socketmax><socketengine>" << ServerInstance->SE->GetName() << "</socketengine>";
 
@@ -155,11 +143,17 @@ class ModuleHttpStats : public Module
 
                                data << "<serverlist>";
                                
-                               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 << "<server>";
-                                       data << "<servername>" << b->first << "</servername>";
-                                       data << "<usercount>" << b->second << "</usercount>";
+                                       data << "<servername>" << b->servername << "</servername>";
+                                       data << "<parentname>" << b->parentname << "</parentname>";
+                                       data << "<usercount>" << b->usercount << "</usercount>";
+                                       data << "<opercount>" << b->opercount << "</opercount>";
+                                       data << "<lagmillisecs>" << b->latencyms << "</lagmillisecs>";
                                        data << "</server>";
                                }
                                data << "</serverlist>";
@@ -225,7 +219,7 @@ class ModuleHttpStats : public Module
                this->changed = true;
        }
 
-       char* OnRequest(Request* request)
+       const char* OnRequest(Request* request)
        {
                return NULL;
        }
@@ -239,7 +233,7 @@ class ModuleHttpStats : public Module
 
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
+               return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
        }
 };