X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_stats.cpp;h=906ad901f2201fb0b49329dc61cc6b4cba53bd0e;hb=1200d6285b1d64699c6fa2c8241e2ee40f52d2a3;hp=0857adb446ba5d61f09165d8e59a88e4aa3c8fdc;hpb=a3802dee4bdfcf3dc11df09c59e6ed1912fbadd9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 0857adb44..906ad901f 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -13,14 +13,17 @@ #include "inspircd.h" #ifndef WIN32 -#include - -/* This is just to be completely certain that the change which fixed getrusage on RH7 doesn't break anything else -- Om */ -#ifndef RUSAGE_SELF -#define RUSAGE_SELF 0 + #include + /* This is just to be completely certain that the change which fixed getrusage on RH7 doesn't break anything else -- Om */ + #ifndef RUSAGE_SELF + #define RUSAGE_SELF 0 + #endif +#else + #include + #include "inspircd_win32wrapper.h" + #pragma comment(lib, "psapi.lib") #endif -#endif #include "xline.h" #include "commands/cmd_stats.h" #include "commands/cmd_whowas.h" @@ -48,7 +51,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str { std::string sn(ServerInstance->Config->ServerName); - if ((!*ServerInstance->Config->UserStats && !IS_OPER(user)) || (!IS_OPER(user) && !ServerInstance->ULine(user->server) && !strchr(ServerInstance->Config->UserStats,statschar))) + if (!user->HasPrivPermission("servers/auspex") && !strchr(ServerInstance->Config->UserStats, statschar)) { ServerInstance->SNO->WriteToSnoMask('t', "%s '%c' denied for %s (%s@%s)", @@ -59,9 +62,14 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str } int MOD_RESULT = 0; - FOREACH_RESULT(I_OnStats,OnStats(statschar,user,results)); + FOREACH_RESULT(I_OnStats,OnStats(statschar, user, results)); if (MOD_RESULT) + { + results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report"); + ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)", + (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str()); return; + } switch (statschar) { @@ -80,11 +88,9 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str } break; + /* These stats symbols must be handled by a linking module */ case 'n': case 'c': - { - /* This stats symbol must be handled by a linking module */ - } break; case 'i': @@ -202,15 +208,17 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str results.push_back(sn+" 249 "+user->nick+" :MOTD(VECTOR) "+ConvToStr(ServerInstance->Config->MOTD.size())+", RULES(VECTOR) "+ConvToStr(ServerInstance->Config->RULES.size())); float kbitpersec_in, kbitpersec_out, kbitpersec_total; + char kbitpersec_in_s[30], kbitpersec_out_s[30], kbitpersec_total_s[30]; + ServerInstance->SE->GetStats(kbitpersec_in, kbitpersec_out, kbitpersec_total); - snprintf(kbitspersec_total_s, 30, "%03.5f%%", kbitspersec_total); - snprintf(kbitspersec_out_s, 30, "%03.5f%%", kbitspersec_out); - snprintf(kbitspersec_in_s, 30, "%03.5f%%", kbitspersec_in); + snprintf(kbitpersec_total_s, 30, "%03.5f", kbitpersec_total); + snprintf(kbitpersec_out_s, 30, "%03.5f", kbitpersec_out); + snprintf(kbitpersec_in_s, 30, "%03.5f", kbitpersec_in); - results.push_back(sn+" 249 "+user->nick+" :Bandwidth total: "+ConvToStr(kbitspersec_total_s)+" kilobits/sec"); - results.push_back(sn+" 249 "+user->nick+" :Bandwidth out: "+ConvToStr(kbitspersec_out_s)+" kilobits/sec"); - results.push_back(sn+" 249 "+user->nick+" :Bandwidth in: "+ConvToStr(kbitspersec_in_s)+" kilobits/sec"); + results.push_back(sn+" 249 "+user->nick+" :Bandwidth total: "+ConvToStr(kbitpersec_total_s)+" kilobits/sec"); + results.push_back(sn+" 249 "+user->nick+" :Bandwidth out: "+ConvToStr(kbitpersec_out_s)+" kilobits/sec"); + results.push_back(sn+" 249 "+user->nick+" :Bandwidth in: "+ConvToStr(kbitpersec_in_s)+" kilobits/sec"); #ifndef WIN32 /* Moved this down here so all the not-windows stuff (look w00tie, I didn't say win32!) is in one ifndef. @@ -245,6 +253,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr((MemCounters.WorkingSetSize + MemCounters.PagefileUsage) / 1024)+"K"); results.push_back(sn+" 249 "+user->nick+" :Pagefile usage: "+ConvToStr(MemCounters.PagefileUsage / 1024)+"K"); results.push_back(sn+" 249 "+user->nick+" :Page faults: "+ConvToStr(MemCounters.PageFaultCount)); + results.push_back(sn+" 249 "+user->nick+" :CPU Usage: " + ConvToStr(getcpu()) + "%"); } #endif }