summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 12:54:19 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 12:54:19 +0000
commit4c6bae4e369ba9a3d8afe2c7e50304ff5d12a650 (patch)
treee3e5dcc370cff469347e176affc708f0ec5420fe
parentc07c9729f37becb33900a9ff8b0b08ee1e8648a1 (diff)
Moved serverstats stuff out
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2529 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/userprocess.h3
-rw-r--r--src/command_parse.cpp6
-rw-r--r--src/commands.cpp14
-rw-r--r--src/dns.cpp13
-rw-r--r--src/helperfuncs.cpp9
-rw-r--r--src/userprocess.cpp7
6 files changed, 23 insertions, 29 deletions
diff --git a/include/userprocess.h b/include/userprocess.h
index 8ecbe1e79..9f4d52e38 100644
--- a/include/userprocess.h
+++ b/include/userprocess.h
@@ -2,9 +2,10 @@
#define __USERPROCESS_H__
#include "users.h"
+#include "inspircd.h"
void CheckDie();
-void LoadAllModules();
+void LoadAllModules(InspIRCd* ServerInstance);
void CheckRoot();
void OpenLog(char** argv, int argc);
bool DoBackgroundUserStuff(time_t TIME);
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 4f5add0d6..c2e4fc975 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -79,13 +79,11 @@ extern SocketEngine* SE;
// by an integer, meaning there is no need for a scan/search operation.
extern userrec* fd_ref_table[65536];
-extern serverstats* stats;
extern Server* MyServer;
extern ServerConfig *Config;
extern user_hash clientlist;
extern chan_hash chanlist;
-extern command_table cmdlist;
/* This function pokes and hacks at a parameter list like the following:
*
@@ -499,7 +497,7 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
{
if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x]))
{
- stats->statsUnknown++;
+ ServerInstance->stats->statsUnknown++;
WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
return;
}
@@ -621,7 +619,7 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
}
if ((!cmd_found) && (user))
{
- stats->statsUnknown++;
+ ServerInstance->stats->statsUnknown++;
WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
}
}
diff --git a/src/commands.cpp b/src/commands.cpp
index a81214f3d..e6c578b84 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -90,8 +90,6 @@ extern std::vector<userrec*> local_users;
// by an integer, meaning there is no need for a scan/search operation.
extern userrec* fd_ref_table[65536];
-extern serverstats* stats;
-
char* CleanFilename(char* name)
{
char* p = name + strlen(name);
@@ -1436,12 +1434,12 @@ void handle_stats(char **parameters, int pcnt, userrec *user)
if (*parameters[0] == 'T')
{
- WriteServ(user->fd,"249 Brain :accepts %d refused %d",stats->statsAccept,stats->statsRefused);
- WriteServ(user->fd,"249 Brain :unknown commands %d",stats->statsUnknown);
- WriteServ(user->fd,"249 Brain :nick collisions %d",stats->statsCollisions);
- WriteServ(user->fd,"249 Brain :dns requests %d succeeded %d failed %d",stats->statsDns,stats->statsDnsGood,stats->statsDnsBad);
- WriteServ(user->fd,"249 Brain :connections %d",stats->statsConnects);
- WriteServ(user->fd,"249 Brain :bytes sent %dK recv %dK",(stats->statsSent / 1024),(stats->statsRecv / 1024));
+ WriteServ(user->fd,"249 Brain :accepts %d refused %d",ServerInstance->stats->statsAccept,ServerInstance->stats->statsRefused);
+ WriteServ(user->fd,"249 Brain :unknown commands %d",ServerInstance->stats->statsUnknown);
+ WriteServ(user->fd,"249 Brain :nick collisions %d",ServerInstance->stats->statsCollisions);
+ WriteServ(user->fd,"249 Brain :dns requests %d succeeded %d failed %d",ServerInstance->stats->statsDns,ServerInstance->stats->statsDnsGood,ServerInstance->stats->statsDnsBad);
+ WriteServ(user->fd,"249 Brain :connections %d",ServerInstance->stats->statsConnects);
+ WriteServ(user->fd,"249 Brain :bytes sent %dK recv %dK",(ServerInstance->stats->statsSent / 1024),(ServerInstance->stats->statsRecv / 1024));
}
/* stats o */
diff --git a/src/dns.cpp b/src/dns.cpp
index 63322385a..efb690dc2 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -42,7 +42,6 @@ using namespace std;
extern InspIRCd* ServerInstance;
extern ServerConfig* Config;
-serverstats* stats;
#define max(a,b) (a > b ? a : b)
#define DNS_MAX 8 /* max number of nameservers used */
@@ -656,7 +655,7 @@ DNS::~DNS()
bool DNS::ReverseLookup(std::string ip)
{
- stats->statsDns++;
+ ServerInstance->stats->statsDns++;
binip = dns_aton4(ip.c_str());
if (binip == NULL) {
return false;
@@ -676,7 +675,7 @@ bool DNS::ReverseLookup(std::string ip)
bool DNS::ForwardLookup(std::string host)
{
- stats->statsDns++;
+ ServerInstance->stats->statsDns++;
this->myfd = dns_getip4(host.c_str());
if (this->myfd == -1)
{
@@ -722,11 +721,11 @@ std::string DNS::GetResult()
ServerInstance->SE->DelFd(this->myfd);
#endif
if (result) {
- stats->statsDnsGood++;
+ ServerInstance->stats->statsDnsGood++;
dns_close(this->myfd);
return result;
} else {
- stats->statsDnsBad++;
+ ServerInstance->stats->statsDnsBad++;
if (this->myfd != -1)
{
dns_close(this->myfd);
@@ -749,7 +748,7 @@ std::string DNS::GetResultIP()
}
if (result)
{
- stats->statsDnsGood++;
+ ServerInstance->stats->statsDnsGood++;
unsigned char a = (unsigned)result[0];
unsigned char b = (unsigned)result[1];
unsigned char c = (unsigned)result[2];
@@ -759,7 +758,7 @@ std::string DNS::GetResultIP()
}
else
{
- stats->statsDnsBad++;
+ ServerInstance->stats->statsDnsBad++;
log(DEBUG,"DANGER WILL ROBINSON! NXDOMAIN for forward lookup, but we got a reverse lookup!");
return "";
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 3e188ee88..e80bec80c 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -56,7 +56,6 @@ extern time_t TIME;
extern char lowermap[255];
static char list[MAXBUF];
extern userrec* fd_ref_table[65536];
-extern serverstats* stats;
static char already_sent[65536];
extern std::vector<userrec*> all_opers;
extern user_hash clientlist;
@@ -148,7 +147,7 @@ void Write(int sock,char *text, ...)
{
fd_ref_table[sock]->AddWriteBuf(tb);
}
- stats->statsSent += bytes;
+ ServerInstance->stats->statsSent += bytes;
}
else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
}
@@ -181,7 +180,7 @@ void WriteServ(int sock, char* text, ...)
{
fd_ref_table[sock]->AddWriteBuf(tb);
}
- stats->statsSent += bytes;
+ ServerInstance->stats->statsSent += bytes;
}
else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
}
@@ -214,7 +213,7 @@ void WriteFrom(int sock, userrec *user,char* text, ...)
{
fd_ref_table[sock]->AddWriteBuf(tb);
}
- stats->statsSent += bytes;
+ ServerInstance->stats->statsSent += bytes;
}
else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
}
@@ -1073,7 +1072,7 @@ void ShowMOTD(userrec *user)
{
user->AddWriteBuf(WholeMOTD);
}
- stats->statsSent += WholeMOTD.length();
+ ServerInstance->stats->statsSent += WholeMOTD.length();
}
void ShowRULES(userrec *user)
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 9c26eb343..a73eb7d25 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -70,7 +70,6 @@ extern time_t OLDTIME;
extern std::vector<userrec*> local_users;
extern InspIRCd* ServerInstance;
-extern serverstats* stats;
extern ServerConfig *Config;
extern userrec* fd_ref_table[65536];
char data[65536];
@@ -106,7 +105,7 @@ void ProcessUser(userrec* cu)
log(DEBUG,"Read result: %d",result);
if (result)
{
- stats->statsRecv += result;
+ ServerInstance->stats->statsRecv += result;
// perform a check on the raw buffer as an array (not a string!) to remove
// characters 0 and 7 which are illegal in the RFC - replace them with spaces.
// hopefully this should stop even more people whining about "Unknown command: *"
@@ -308,7 +307,7 @@ bool DoBackgroundUserStuff(time_t TIME)
{
log(DEBUG,"signon exceed, registered=3, and modules ready, OK: %d %d",TIME,curr->signon);
curr->dns_done = true;
- stats->statsDnsBad++;
+ ServerInstance->stats->statsDnsBad++;
FullConnectUser(curr);
if (fd_ref_table[currfd] != curr) // something changed, bail pronto
return true;
@@ -377,7 +376,7 @@ void CheckDie()
}
}
-void LoadAllModules()
+void LoadAllModules(InspIRCd* ServerInstance)
{
/* We must load the modules AFTER initializing the socket engine, now */
MODCOUNT = -1;