X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_stats.cpp;h=878ea2fae70c2e88debe207b7348a541283998cf;hb=56a1ef63e7f2628ad92a5040b3acae64cd99b56a;hp=b9165390872665dd33183b735087096dabf15bb1;hpb=c0aba5b728b0a921d95ec120aa638dab1520b42f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index b91653908..878ea2fae 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -41,8 +41,8 @@ class CommandStats : public Command * @param user The user issuing the command * @return A value from CmdResult to indicate command success or failure. */ - CmdResult Handle(const std::vector& parameters, User *user); - RouteDescriptor GetRouting(User* user, const std::vector& parameters) + CmdResult Handle(const std::vector& parameters, User* user) CXX11_OVERRIDE; + RouteDescriptor GetRouting(User* user, const std::vector& parameters) CXX11_OVERRIDE { if ((parameters.size() > 1) && (parameters[1].find('.') != std::string::npos)) return ROUTE_UNICAST(parameters[1]); @@ -58,7 +58,7 @@ static void GenerateStatsLl(Stats::Context& stats) for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i) { LocalUser* u = *i; - stats.AddRow(211, u->nick+"["+u->ident+"@"+(stats.GetSymbol() == 'l' ? u->dhost : u->GetIPString())+"] "+ConvToStr(u->eh.getSendQSize())+" "+ConvToStr(u->cmds_out)+" "+ConvToStr(u->bytes_out)+" "+ConvToStr(u->cmds_in)+" "+ConvToStr(u->bytes_in)+" "+ConvToStr(ServerInstance->Time() - u->signon)); + stats.AddRow(211, u->nick+"["+u->ident+"@"+(stats.GetSymbol() == 'l' ? u->GetDisplayedHost() : u->GetIPString())+"] "+ConvToStr(u->eh.getSendQSize())+" "+ConvToStr(u->cmds_out)+" "+ConvToStr(u->bytes_out)+" "+ConvToStr(u->cmds_in)+" "+ConvToStr(u->bytes_in)+" "+ConvToStr(ServerInstance->Time() - u->signon)); } } @@ -76,7 +76,7 @@ void CommandStats::DoStats(Stats::Context& stats) ServerInstance->SNO->WriteToSnoMask('t', "%s '%c' denied for %s (%s@%s)", (IS_LOCAL(user) ? "Stats" : "Remote stats"), - statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str()); + statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str()); stats.AddRow(481, (std::string("Permission Denied - STATS ") + statschar + " requires the servers/auspex priv.")); return; } @@ -87,7 +87,7 @@ void CommandStats::DoStats(Stats::Context& stats) { stats.AddRow(219, 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()); + (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str()); return; } @@ -99,18 +99,10 @@ void CommandStats::DoStats(Stats::Context& stats) for (std::vector::const_iterator i = ServerInstance->ports.begin(); i != ServerInstance->ports.end(); ++i) { ListenSocket* ls = *i; - std::string ip = ls->bind_addr; - if (ip.empty()) - ip.assign("*"); - else if (ip.find_first_of(':') != std::string::npos) - { - ip.insert(ip.begin(), '['); - ip.insert(ip.end(), ']'); - } std::string type = ls->bind_tag->getString("type", "clients"); std::string hook = ls->bind_tag->getString("ssl", "plaintext"); - stats.AddRow(249, ip + ":"+ConvToStr(ls->bind_port) + " (" + type + ", " + hook + ")"); + stats.AddRow(249, ls->bind_sa.str() + " (" + type + ", " + hook + ")"); } } break; @@ -175,7 +167,7 @@ void CommandStats::DoStats(Stats::Context& stats) if (!oper->server->IsULine()) { LocalUser* lu = IS_LOCAL(oper); - stats.AddRow(249, oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " + + stats.AddRow(249, oper->nick + " (" + oper->ident + "@" + oper->GetDisplayedHost() + ") Idle: " + (lu ? ConvToStr(ServerInstance->Time() - lu->idle_lastmsg) + " secs" : "unavailable")); idx++; } @@ -247,12 +239,13 @@ void CommandStats::DoStats(Stats::Context& stats) /* 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); @@ -368,7 +361,7 @@ void CommandStats::DoStats(Stats::Context& stats) stats.AddRow(219, 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()); + (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str()); return; }