diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-14 19:30:42 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-14 19:30:42 +0000 |
commit | 4652f73b9e7a0f41ad4c91353e0ac39ef838f6cb (patch) | |
tree | a8774e8624dd302e9b01652501592b7e4715d820 /src/cmd_stats.cpp | |
parent | 1a59b542f90c10799085ad2b2d8aed2a6c378acf (diff) |
CPU Usage percent in stats z! yay!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5988 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/cmd_stats.cpp')
-rw-r--r-- | src/cmd_stats.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 70cbcf2ae..751f9ac68 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -184,6 +184,17 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis results.push_back(sn+" 249 "+user->nick+" :Page faults: "+ConvToStr(R.ru_majflt)); results.push_back(sn+" 249 "+user->nick+" :Swaps: "+ConvToStr(R.ru_nswap)); results.push_back(sn+" 249 "+user->nick+" :Context Switches: "+ConvToStr(R.ru_nvcsw+R.ru_nivcsw)); + + timeval tv; + char percent[30]; + gettimeofday(&tv, NULL); + + float n_elapsed = ((tv.tv_sec - ServerInstance->stats->LastSampled.tv_sec) * 1000000 + tv.tv_usec - ServerInstance->stats->LastSampled.tv_usec); + float n_eaten = ((R.ru_utime.tv_sec - ServerInstance->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - ServerInstance->stats->LastCPU.tv_usec); + float per = (n_eaten / n_elapsed) * 100; + + snprintf(percent, 30, "%03.5f%%", per); + results.push_back(sn+" 249 "+user->nick+" :CPU Usage: "+percent); } } break; |