#include "inspircd.h"
#include "httpd.h"
+#include "protocol.h"
/* $ModDesc: Provides statistics over HTTP via m_httpd.so */
/* $ModDep: httpd.h */
static StatsHash* sh = new StatsHash();
static SortedList* so = new SortedList();
-static StatsHash* Servers = new StatsHash();
-
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;
}
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/"))
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>";
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>";
this->changed = true;
}
- char* OnRequest(Request* request)
+ const char* OnRequest(Request* request)
{
return NULL;
}
virtual Version GetVersion()
{
- return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
+ return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
}
};