CPU Stat 1.06

This is the revival of an old MetaMod? plugin found here on NSMod, created by prodigy, which I find moderately useful when one is hosting one or more instance of HLDS.

It simply shows the complete CPU usage statistics of the box, in addition to the server FPS count, the entity count on the map, and the complete loadavg on Linux.

As you may be aware of, this plugin has long since been abandoned by it's original author, and the available builds (and source) would crash as soon as someone asked for statistics!

This is where I come in. I managed to fix these crashs, as well as make some little cleanup, rewrote part of the code and even added complete new features (yay!): detailed CPU usage stats of the host HLDS process and its threads, and detailed CPU usage info for each CPU of SMP systems! The number of online logical CPUs should also automatically be detected on Linux. (It was a windows only feature before). If for some reason it fails, the cpustat_numcpu cvar is still available.

As I'm hardly a C/C++ coder, this may very well be pretty ugly code, but at least it works ;D

One other caveat is that as I don't have a Windows dev env, this new feature is Linux only.


There's only a bunch of cvars available:

cpustat_numcpu - Sets the number of CPUs available on the box. (It should be autodetected correctly on Windows & Linux, so you shouldn't have to touch this)

cpustat_passwd - Sets the password for the client command. You need to set this.

cpustat_display - Change the manner of displaying the stats. (0: pretty HUD messages, 1: console messages)

cpustat_freq - Frequency (in seconds) to announce the stats. (Default to 2s)

cpustat_hlds - Available only on Linux. Toggle the detailed CPU usage stats for HLDS. It may be a little expensive, so if you're short on CPU power, disable it. (Default: 1, enabled)

cpustat_smp - Available only on Linux. Toggle the detailed CPUs usage stats for SMP systems. It may be a little expensive, so if you're short on CPU power, disable it. (Default: 1, enabled) (Forcibly disabled on UP systems)


Server command:

cpuStat <#id> <1|0> - Enable the stats on the specified userid. (ie. cpuStat 12 1 enables the stats for player #12)

Client command:

/cpu <password> - It's a say handler, and the password is set via the cvar cpustat_password. Just say (or say_team) /cpu yourpassword and enjoy ;)


The source is available on this SVN repo, here ;)


Linux binary.

No ETA yet on Windows builds.



6221 by NiLuJe on 2010-05-03 20:29:28


  • Oops. That's stupid. We endend up with CPU:0 instead of CPU0: with the long prefix.
6220 by NiLuJe on 2010-05-03 20:06:34


  • Yeah, well, I forgot about that damn buffer size. Ditch alignment of SMP stats, it takes too much characters.
6219 by NiLuJe on 2010-05-03 19:55:58


  • Fix alignment of the SMP stats after a linebreak.
6217 by NiLuJe on 2010-05-03 08:08:22


  • And I will stop breaking the UTF-8 output…
6216 by NiLuJe on 2010-05-03 08:06:56


  • Repeat after me: I will stop messing with the HUD msg vertical alignment.

This software is licensed under the CC-GNU GPL.
Last modified 9 years ago Last modified on May 3, 2010, 2:20:10 AM