summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-14 19:30:42 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-14 19:30:42 +0000
commit4652f73b9e7a0f41ad4c91353e0ac39ef838f6cb (patch)
treea8774e8624dd302e9b01652501592b7e4715d820 /src/inspircd.cpp
parent1a59b542f90c10799085ad2b2d8aed2a6c378acf (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/inspircd.cpp')
-rw-r--r--src/inspircd.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index aef7b09e6..a26b5e4c7 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -716,6 +716,8 @@ bool InspIRCd::LoadModule(const char* filename)
void InspIRCd::DoOneIteration(bool process_module_sockets)
{
+ static rusage ru;
+
/* time() seems to be a pretty expensive syscall, so avoid calling it too much.
* Once per loop iteration is pleanty.
*/
@@ -744,6 +746,12 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
FOREACH_MOD_I(this,I_OnBackgroundTimer,OnBackgroundTimer(TIME));
Timers->TickMissedTimers(TIME);
}
+
+ if (!getrusage(0, &ru))
+ {
+ gettimeofday(&this->stats->LastSampled, NULL);
+ this->stats->LastCPU = ru.ru_utime;
+ }
}
/* Call the socket engine to wait on the active