1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 23:33:12 +02:00

Moved the core pseudo clients out into their own modules

This commit is contained in:
Adam
2011-04-22 03:16:11 -04:00
parent 1782ce260c
commit c8c23158a4
226 changed files with 5187 additions and 4891 deletions
+17 -143
View File
@@ -12,8 +12,7 @@
/*************************************************************************/
#include "module.h"
void get_operserv_stats(long *nrec, long *memuse);
#include "operserv.h"
/**
* Count servers connected to server s
@@ -154,40 +153,6 @@ class CommandOSStats : public Command
return MOD_CONT;
}
CommandReturn DoStatsMemory(CommandSource &source)
{
long count, mem;
source.Reply(_("Bytes read : %5d kB"), TotalRead / 1024);
source.Reply(_("Bytes written : %5d kB"), TotalWritten / 1024);
get_user_stats(count, mem);
source.Reply(_("User : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
get_channel_stats(&count, &mem);
source.Reply(_("Channel : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
get_core_stats(count, mem);
source.Reply(_("NS Groups : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
get_aliases_stats(count, mem);
source.Reply(_("NS Aliases : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
get_chanserv_stats(&count, &mem);
source.Reply(_("ChanServ : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
if (!Config->s_BotServ.empty())
{
get_botserv_stats(&count, &mem);
source.Reply(_("BotServ : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
}
if (!Config->s_HostServ.empty())
{
get_hostserv_stats(&count, &mem);
source.Reply(_("HostServ : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
}
get_operserv_stats(&count, &mem);
source.Reply(_("OperServ : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
get_session_stats(count, mem);
source.Reply(_("Sessions : \002%6d\002 records, \002%5d\002 kB"), count, (mem + 512) / 1024);
return MOD_CONT;
}
public:
CommandOSStats() : Command("STATS", 0, 1, "operserv/stats")
{
@@ -196,33 +161,28 @@ class CommandOSStats : public Command
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
const Anope::string &extra = !params.empty() ? params[0] : "";
Anope::string extra = !params.empty() ? params[0] : "";
if (!extra.empty() && !extra.equals_ci("ALL"))
{
if (extra.equals_ci("AKILL"))
return this->DoStatsAkill(source);
else if (extra.equals_ci("RESET"))
return this->DoStatsReset(source);
else if (!extra.equals_ci("MEMORY") && !extra.equals_ci("UPLINK"))
source.Reply(_("Unknown STATS option \002%s\002."), extra.c_str());
}
if (extra.equals_ci("ALL"))
extra.clear();
if (extra.empty() || (!extra.equals_ci("MEMORY") && !extra.equals_ci("UPLINK")))
if (extra.empty() || extra.equals_ci("AKILL"))
return this->DoStatsAkill(source);
else if (extra.equals_ci("RESET"))
return this->DoStatsReset(source);
else if (extra.empty() || extra.equals_ci("UPTIME"))
this->DoStatsUptime(source);
if (!extra.empty() && (extra.equals_ci("ALL") || extra.equals_ci("UPLINK")))
else if (extra.empty() || extra.equals_ci("UPLINK"))
this->DoStatsUplink(source);
if (!extra.empty() && (extra.equals_ci("ALL") || extra.equals_ci("MEMORY")))
this->DoStatsMemory(source);
else if (!extra.equals_ci("UPLINK"))
source.Reply(_("Unknown STATS option \002%s\002."), extra.c_str());
return MOD_CONT;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
source.Reply(_("Syntax: \002STATS [AKILL | ALL | RESET | MEMORY | UPLINK]\002\n"
source.Reply(_("Syntax: \002STATS [AKILL | ALL | RESET | UPLINK]\002\n"
" \n"
"Without any option, shows the current number of users and\n"
"IRCops online (excluding Services), the highest number of\n"
@@ -235,10 +195,6 @@ class CommandOSStats : public Command
"The \002RESET\002 option currently resets the maximum user count\n"
"to the number of users currently present on the network.\n"
" \n"
"The \002MEMORY\002 option displays information on the memory\n"
"usage of Services. Using this option can freeze Services for\n"
"a short period of time on large networks; don't overuse it!\n"
" \n"
"The \002UPLINK\002 option displays information about the current\n"
"server Anope uses as an uplink to the network.\n"
" \n"
@@ -258,93 +214,11 @@ class OSStats : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(OperServ, &commandosstats);
if (!operserv)
throw ModuleException("OperServ is not loaded!");
this->AddCommand(operserv->Bot(), &commandosstats);
}
};
void get_operserv_stats(long *nrec, long *memuse)
{
unsigned i, end;
long mem = 0, count = 0, mem2 = 0, count2 = 0;
XLine *x;
end = SGLine->GetCount();
count += end;
mem += end * sizeof(XLine);
for (i = 0; i < end; ++i)
{
x = SGLine->GetEntry(i);
mem += x->GetNick().length() + 1;
mem += x->GetUser().length() + 1;
mem += x->GetHost().length() + 1;
mem += x->Mask.length() + 1;
mem += x->By.length() + 1;
mem += x->Reason.length() + 1;
}
if (ircd->snline)
{
end = SNLine->GetCount();
count += end;
mem += end * sizeof(XLine);
for (i = 0; i < end; ++i)
{
x = SNLine->GetEntry(i);
mem += x->GetNick().length() + 1;
mem += x->GetUser().length() + 1;
mem += x->GetHost().length() + 1;
mem += x->Mask.length() + 1;
mem += x->By.length() + 1;
mem += x->Reason.length() + 1;
}
}
if (ircd->sqline)
{
end = SQLine->GetCount();
count += end;
mem += end * sizeof(XLine);
for (i = 0; i < end; ++i)
{
x = SQLine->GetEntry(i);
mem += x->GetNick().length() + 1;
mem += x->GetUser().length() + 1;
mem += x->GetHost().length() + 1;
mem += x->Mask.length() + 1;
mem += x->By.length() + 1;
mem += x->Reason.length() + 1;
}
}
if (ircd->szline)
{
end = SZLine->GetCount();
count += end;
mem += end * sizeof(XLine);
for (i = 0; i < end; ++i)
{
x = SZLine->GetEntry(i);
mem += x->GetNick().length() + 1;
mem += x->GetUser().length() + 1;
mem += x->GetHost().length() + 1;
mem += x->Mask.length() + 1;
mem += x->By.length() + 1;
mem += x->Reason.length() + 1;
}
}
get_exception_stats(count2, mem2);
count += count2;
mem += mem2;
*nrec = count;
*memuse = mem;
}
MODULE_INIT(OSStats)