#include "inspircd.h"
#include "xline.h"
+#include "modules/stats.h"
#ifdef _WIN32
#include <psapi.h>
*/
class CommandStats : public Command
{
+ Events::ModuleEventProvider statsevprov;
void DoStats(Stats::Context& stats);
+
public:
/** Constructor for stats.
*/
- CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { allow_empty_last_param = false; syntax = "<stats-symbol> [<servername>]"; }
+ CommandStats(Module* Creator)
+ : Command(Creator, "STATS", 1, 2)
+ , statsevprov(Creator, "event/stats")
+ {
+ allow_empty_last_param = false;
+ syntax = "<stats-symbol> [<servername>]";
+ }
+
/** Handle command.
* @param parameters The parameters to the command
* @param user The user issuing the command
}
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnStats, MOD_RESULT, (stats));
+ FIRST_MOD_RESULT_CUSTOM(statsevprov, Stats::EventListener, OnStats, MOD_RESULT, (stats));
if (MOD_RESULT == MOD_RES_DENY)
{
stats.AddRow(219, statschar, "End of /STATS report");
/* Not sure why we were doing '0' with a RUSAGE_SELF comment rather than just using RUSAGE_SELF -- Om */
if (!getrusage(RUSAGE_SELF,&R)) /* RUSAGE_SELF */
{
+#ifndef __HAIKU__
stats.AddRow(249, "Total allocation: "+ConvToStr(R.ru_maxrss)+"K");
stats.AddRow(249, "Signals: "+ConvToStr(R.ru_nsignals));
stats.AddRow(249, "Page faults: "+ConvToStr(R.ru_majflt));
stats.AddRow(249, "Swaps: "+ConvToStr(R.ru_nswap));
stats.AddRow(249, "Context Switches: Voluntary; "+ConvToStr(R.ru_nvcsw)+" Involuntary; "+ConvToStr(R.ru_nivcsw));
-
+#endif
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);
/* stats o */
case 'o':
{
- ConfigTagList tags = ServerInstance->Config->ConfTags("oper");
- for(ConfigIter i = tags.first; i != tags.second; ++i)
+ for (ServerConfig::OperIndex::const_iterator i = ServerInstance->Config->oper_blocks.begin(); i != ServerInstance->Config->oper_blocks.end(); ++i)
{
- ConfigTag* tag = i->second;
+ OperInfo* ifo = i->second;
+ ConfigTag* tag = ifo->oper_block;
stats.AddRow(243, 'O', tag->getString("host"), '*', tag->getString("name"), tag->getString("type"), '0');
}
}