diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-19 15:56:42 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-19 15:56:42 +0000 |
commit | 9cf56d917d92959701694477f7944d45ad2c38ed (patch) | |
tree | a379ee905e7485c2ee825790720ed2b69ba127d1 /src/cmd_stats.cpp | |
parent | 3bbb36695383badf5b3ba0ecba070f16094ae51d (diff) |
Windows support. Tested and working to compile on freebsd and linux. Next step is to make sure it actually works in windows too. ;p. Add Burlex to contributors.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7043 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/cmd_stats.cpp')
-rw-r--r-- | src/cmd_stats.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 24fa7e7ec..55b7e68eb 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -13,7 +13,9 @@ #include "inspircd.h" #include "configreader.h" +#ifndef WIN32 #include <sys/resource.h> +#endif #include "users.h" #include "modules.h" #include "xline.h" @@ -21,7 +23,7 @@ #include "commands/cmd_whowas.h" -extern "C" command_t* init_command(InspIRCd* Instance) +extern "C" DllExport command_t* init_command(InspIRCd* Instance) { return new cmd_stats(Instance); } @@ -39,7 +41,7 @@ CmdResult cmd_stats::Handle (const char** parameters, int pcnt, userrec *user) return CMD_SUCCESS; } -void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_list &results) +DllExport void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_list &results) { std::string sn = ServerInstance->Config->ServerName; @@ -171,12 +173,18 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis /* stats z (debug and memory info) */ case 'z': { - rusage R; +#ifndef WIN32 + rusage R; results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes"); results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes, "+ConvToStr(ServerInstance->clientlist->bucket_count())+" buckets)"); results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes, "+ConvToStr(ServerInstance->chanlist->bucket_count())+" buckets)"); results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)"); - +#else + results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes"); + results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes)"); + results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes)"); + results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)"); +#endif if (!ServerInstance->Config->WhoWasGroupSize == 0 && !ServerInstance->Config->WhoWasMaxGroups == 0) { command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS"); @@ -199,7 +207,8 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis results.push_back(sn+" 249 "+user->nick+" :Modules(VECTOR) "+ConvToStr(ServerInstance->modules.size())+" ("+ConvToStr(ServerInstance->modules.size()*sizeof(Module))+" bytes)"); results.push_back(sn+" 249 "+user->nick+" :ClassFactories(VECTOR) "+ConvToStr(ServerInstance->factory.size())+" ("+ConvToStr(ServerInstance->factory.size()*sizeof(ircd_module))+" bytes)"); - if (!getrusage(0,&R)) /* RUSAGE_SELF */ +#ifndef WIN32 + if (!getrusage(0,&R)) /* RUSAGE_SELF */ { results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K"); results.push_back(sn+" 249 "+user->nick+" :Signals: "+ConvToStr(R.ru_nsignals)); @@ -218,6 +227,7 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis snprintf(percent, 30, "%03.5f%%", per); results.push_back(sn+" 249 "+user->nick+" :CPU Usage: "+percent); } +#endif } break; |