summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h26
-rw-r--r--src/command_parse.cpp2
-rw-r--r--src/coremods/core_dns.cpp10
-rw-r--r--src/coremods/core_hostname_lookup.cpp4
-rw-r--r--src/coremods/core_stats.cpp22
-rw-r--r--src/inspircd.cpp15
-rw-r--r--src/listensocket.cpp6
-rw-r--r--src/users.cpp8
8 files changed, 45 insertions, 48 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 633a0d58d..30625c42a 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -174,38 +174,38 @@ class serverstats
public:
/** Number of accepted connections
*/
- unsigned long statsAccept;
+ unsigned long Accept;
/** Number of failed accepts
*/
- unsigned long statsRefused;
+ unsigned long Refused;
/** Number of unknown commands seen
*/
- unsigned long statsUnknown;
+ unsigned long Unknown;
/** Number of nickname collisions handled
*/
- unsigned long statsCollisions;
+ unsigned long Collisions;
/** Number of DNS queries sent out
*/
- unsigned long statsDns;
+ unsigned long Dns;
/** Number of good DNS replies received
* NOTE: This may not tally to the number sent out,
* due to timeouts and other latency issues.
*/
- unsigned long statsDnsGood;
+ unsigned long DnsGood;
/** Number of bad (negative) DNS replies received
* NOTE: This may not tally to the number sent out,
* due to timeouts and other latency issues.
*/
- unsigned long statsDnsBad;
+ unsigned long DnsBad;
/** Number of inbound connections seen
*/
- unsigned long statsConnects;
+ unsigned long Connects;
/** Total bytes of data transmitted
*/
- unsigned long statsSent;
+ unsigned long Sent;
/** Total bytes of data received
*/
- unsigned long statsRecv;
+ unsigned long Recv;
#ifdef _WIN32
/** Cpu usage at last sample
*/
@@ -227,8 +227,8 @@ class serverstats
/** The constructor initializes all the counts to zero
*/
serverstats()
- : statsAccept(0), statsRefused(0), statsUnknown(0), statsCollisions(0), statsDns(0),
- statsDnsGood(0), statsDnsBad(0), statsConnects(0), statsSent(0), statsRecv(0)
+ : Accept(0), Refused(0), Unknown(0), Collisions(0), Dns(0),
+ DnsGood(0), DnsBad(0), Connects(0), Sent(0), Recv(0)
{
}
};
@@ -368,7 +368,7 @@ class CoreExport InspIRCd
/** Stats class, holds miscellaneous stats counters
*/
- serverstats* stats;
+ serverstats stats;
/** Server Config class, holds configuration file data
*/
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index d89d7cbb5..0669c89ad 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -208,7 +208,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
{
if (user->registered == REG_ALL)
user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command",command.c_str());
- ServerInstance->stats->statsUnknown++;
+ ServerInstance->stats.Unknown++;
return;
}
}
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 30c736757..17e489794 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -603,7 +603,7 @@ class MyManager : public Manager, public Timer, public EventHandler
if (recv_packet.flags & QUERYFLAGS_OPCODE)
{
ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG, "Resolver: Received a nonstandard query");
- ServerInstance->stats->statsDnsBad++;
+ ServerInstance->stats.DnsBad++;
recv_packet.error = ERROR_NONSTANDARD_QUERY;
request->OnError(&recv_packet);
}
@@ -637,26 +637,26 @@ class MyManager : public Manager, public Timer, public EventHandler
break;
}
- ServerInstance->stats->statsDnsBad++;
+ ServerInstance->stats.DnsBad++;
recv_packet.error = error;
request->OnError(&recv_packet);
}
else if (recv_packet.questions.empty() || recv_packet.answers.empty())
{
ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG, "Resolver: No resource records returned");
- ServerInstance->stats->statsDnsBad++;
+ ServerInstance->stats.DnsBad++;
recv_packet.error = ERROR_NO_RECORDS;
request->OnError(&recv_packet);
}
else
{
ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG, "Resolver: Lookup complete for " + request->name);
- ServerInstance->stats->statsDnsGood++;
+ ServerInstance->stats.DnsGood++;
request->OnLookupComplete(&recv_packet);
this->AddCache(recv_packet);
}
- ServerInstance->stats->statsDns++;
+ ServerInstance->stats.Dns++;
/* Request's destructor removes it from the request map */
delete request;
diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp
index 3d3e9703a..7f3f23149 100644
--- a/src/coremods/core_hostname_lookup.cpp
+++ b/src/coremods/core_hostname_lookup.cpp
@@ -170,7 +170,7 @@ class UserResolver : public DNS::Request
{
bound_user->WriteNotice("*** Could not resolve your hostname: " + this->manager->GetErrorStr(query->error) + "; using your IP address (" + bound_user->GetIPString() + ") instead.");
dl->set(bound_user, 0);
- ServerInstance->stats->statsDnsBad++;
+ ServerInstance->stats.DnsBad++;
}
}
};
@@ -215,7 +215,7 @@ class ModuleHostnameLookup : public Module
this->dnsLookup.set(user, 0);
delete res_reverse;
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Error in resolver: " + e.GetReason());
- ServerInstance->stats->statsDnsBad++;
+ ServerInstance->stats.DnsBad++;
}
}
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp
index e0e5b3a0f..b8ea21731 100644
--- a/src/coremods/core_stats.cpp
+++ b/src/coremods/core_stats.cpp
@@ -236,9 +236,9 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
char percent[30];
- float n_elapsed = (ServerInstance->Time() - ServerInstance->stats->LastSampled.tv_sec) * 1000000
- + (ServerInstance->Time_ns() - ServerInstance->stats->LastSampled.tv_nsec) / 1000;
- float n_eaten = ((R.ru_utime.tv_sec - ServerInstance->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - ServerInstance->stats->LastCPU.tv_usec);
+ float n_elapsed = (ServerInstance->Time() - ServerInstance->stats.LastSampled.tv_sec) * 1000000
+ + (ServerInstance->Time_ns() - ServerInstance->stats.LastSampled.tv_nsec) / 1000;
+ float n_eaten = ((R.ru_utime.tv_sec - ServerInstance->stats.LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - ServerInstance->stats.LastCPU.tv_usec);
float per = (n_eaten / n_elapsed) * 100;
snprintf(percent, 30, "%03.5f%%", per);
@@ -269,8 +269,8 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
{
KernelTime.dwHighDateTime += UserTime.dwHighDateTime;
KernelTime.dwLowDateTime += UserTime.dwLowDateTime;
- double n_eaten = (double)( ( (uint64_t)(KernelTime.dwHighDateTime - ServerInstance->stats->LastCPU.dwHighDateTime) << 32 ) + (uint64_t)(KernelTime.dwLowDateTime - ServerInstance->stats->LastCPU.dwLowDateTime) )/100000;
- double n_elapsed = (double)(ThisSample.QuadPart - ServerInstance->stats->LastSampled.QuadPart) / ServerInstance->stats->QPFrequency.QuadPart;
+ double n_eaten = (double)( ( (uint64_t)(KernelTime.dwHighDateTime - ServerInstance->stats.LastCPU.dwHighDateTime) << 32 ) + (uint64_t)(KernelTime.dwLowDateTime - ServerInstance->stats.LastCPU.dwLowDateTime) )/100000;
+ double n_elapsed = (double)(ThisSample.QuadPart - ServerInstance->stats.LastSampled.QuadPart) / ServerInstance->stats.QPFrequency.QuadPart;
double per = (n_eaten/n_elapsed);
char percent[30];
@@ -290,13 +290,13 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
case 'T':
{
- results.push_back("249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats->statsAccept)+" refused "+ConvToStr(ServerInstance->stats->statsRefused));
- results.push_back("249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats->statsUnknown));
- results.push_back("249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats->statsCollisions));
- results.push_back("249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats->statsDnsGood+ServerInstance->stats->statsDnsBad)+" succeeded "+ConvToStr(ServerInstance->stats->statsDnsGood)+" failed "+ConvToStr(ServerInstance->stats->statsDnsBad));
- results.push_back("249 "+user->nick+" :connection count "+ConvToStr(ServerInstance->stats->statsConnects));
+ results.push_back("249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats.Accept)+" refused "+ConvToStr(ServerInstance->stats.Refused));
+ results.push_back("249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats.Unknown));
+ results.push_back("249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats.Collisions));
+ results.push_back("249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats.DnsGood+ServerInstance->stats.DnsBad)+" succeeded "+ConvToStr(ServerInstance->stats.DnsGood)+" failed "+ConvToStr(ServerInstance->stats.DnsBad));
+ results.push_back("249 "+user->nick+" :connection count "+ConvToStr(ServerInstance->stats.Connects));
results.push_back(InspIRCd::Format("249 %s :bytes sent %5.2fK recv %5.2fK", user->nick.c_str(),
- ServerInstance->stats->statsSent / 1024.0, ServerInstance->stats->statsRecv / 1024.0));
+ ServerInstance->stats.Sent / 1024.0, ServerInstance->stats.Recv / 1024.0));
}
break;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index efbb013ca..ff28be6c1 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -133,7 +133,6 @@ void InspIRCd::Cleanup()
DeleteZero(this->Modes);
DeleteZero(this->XLines);
DeleteZero(this->Parser);
- DeleteZero(this->stats);
DeleteZero(this->Modules);
DeleteZero(this->BanCache);
DeleteZero(this->SNO);
@@ -268,7 +267,6 @@ InspIRCd::InspIRCd(int argc, char** argv) :
this->SNO = 0;
this->BanCache = 0;
this->Modules = 0;
- this->stats = 0;
this->Parser = 0;
this->XLines = 0;
this->Modes = 0;
@@ -296,7 +294,6 @@ InspIRCd::InspIRCd(int argc, char** argv) :
this->BanCache = new BanCacheManager;
this->Modules = new ModuleManager();
dynamic_reference_base::reset_all();
- this->stats = new serverstats();
this->Parser = new CommandParser;
this->XLines = new XLineManager;
@@ -549,7 +546,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
FreeConsole();
}
- QueryPerformanceFrequency(&stats->QPFrequency);
+ QueryPerformanceFrequency(&stats.QPFrequency);
#endif
Logs->Log("STARTUP", LOG_DEFAULT, "Startup complete as '%s'[%s], %d max open sockets", Config->ServerName.c_str(),Config->GetSID().c_str(), SocketEngine::GetMaxFds());
@@ -683,18 +680,18 @@ void InspIRCd::Run()
{
#ifndef _WIN32
getrusage(RUSAGE_SELF, &ru);
- stats->LastSampled = TIME;
- stats->LastCPU = ru.ru_utime;
+ stats.LastSampled = TIME;
+ stats.LastCPU = ru.ru_utime;
#else
- if(QueryPerformanceCounter(&stats->LastSampled))
+ if(QueryPerformanceCounter(&stats.LastSampled))
{
FILETIME CreationTime;
FILETIME ExitTime;
FILETIME KernelTime;
FILETIME UserTime;
GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime);
- stats->LastCPU.dwHighDateTime = KernelTime.dwHighDateTime + UserTime.dwHighDateTime;
- stats->LastCPU.dwLowDateTime = KernelTime.dwLowDateTime + UserTime.dwLowDateTime;
+ stats.LastCPU.dwHighDateTime = KernelTime.dwHighDateTime + UserTime.dwHighDateTime;
+ stats.LastCPU.dwLowDateTime = KernelTime.dwLowDateTime + UserTime.dwLowDateTime;
}
#endif
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index cb4bfd2db..2a74c0b68 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -114,7 +114,7 @@ void ListenSocket::AcceptInternal()
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "HandleEvent for Listensocket %s nfd=%d", bind_desc.c_str(), incomingSockfd);
if (incomingSockfd < 0)
{
- ServerInstance->stats->statsRefused++;
+ ServerInstance->stats.Refused++;
return;
}
@@ -170,11 +170,11 @@ void ListenSocket::AcceptInternal()
}
if (res == MOD_RES_ALLOW)
{
- ServerInstance->stats->statsAccept++;
+ ServerInstance->stats.Accept++;
}
else
{
- ServerInstance->stats->statsRefused++;
+ ServerInstance->stats.Refused++;
ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Refusing connection on %s - %s",
bind_desc.c_str(), res == MOD_RES_DENY ? "Connection refused by module" : "Module for this port not found");
SocketEngine::Close(incomingSockfd);
diff --git a/src/users.cpp b/src/users.cpp
index 6e9e8202e..4acf80395 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -285,7 +285,7 @@ eol_found:
recvq = recvq.substr(qpos);
// TODO should this be moved to when it was inserted in recvq?
- ServerInstance->stats->statsRecv += qpos;
+ ServerInstance->stats.Recv += qpos;
user->bytes_in += qpos;
user->cmds_in++;
@@ -540,7 +540,7 @@ bool LocalUser::CheckLines(bool doZline)
void LocalUser::FullConnect()
{
- ServerInstance->stats->statsConnects++;
+ ServerInstance->stats.Connects++;
this->idle_lastmsg = ServerInstance->Time();
/*
@@ -629,7 +629,7 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
if (MOD_RESULT == MOD_RES_DENY)
{
- ServerInstance->stats->statsCollisions++;
+ ServerInstance->stats.Collisions++;
return false;
}
}
@@ -837,7 +837,7 @@ void LocalUser::Write(const std::string& text)
eh.AddWriteBuf(text);
eh.AddWriteBuf(wide_newline);
- ServerInstance->stats->statsSent += text.length() + 2;
+ ServerInstance->stats.Sent += text.length() + 2;
this->bytes_out += text.length() + 2;
this->cmds_out++;
}