Link to home
Start Free TrialLog in
Avatar of e1337coderz
e1337coderz

asked on

Limiting CPU usage per user

setup: RedHat 9.0
What exactly am I doing: Running multiple counterstrike servers for private people.
What I am fearing: I know that the dedicated server apps use almost no cpu power (usually 0.1% when idle and 6% when 32people are on.), but i give full ssh access to the accounts, and I can't have an infinite look disturbing all the other users.

So basically I need to limit usage on a per account basis, something like 75% for each user (Only 8 servers).

I see:
nano -w /etc/security/limits.conf
Nothing in there that helps me (I think) just maxlogins and that kind of thing.

I would like that it would limit the CPU usage of the user, but If that is not possible then killing the program would be in the worst case.

Here is what I do not want to do: Patch my kernel, I rent the dedicated server and I ssh to it, I do not have physical access to it, so I cannot do anything once it's down.
Avatar of e1337coderz
e1337coderz

ASKER

.
.
My /etc/security/limits.conf:
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - an user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit
#        - maxlogins - max number of logins for this user
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#
#<domain>      <type>  <item>         <value>
#

The max CPU time gives the max amount of time that the processor can be used rather than the man % of processor usage at any one time.

Therefore the only way I can see that you can do what you need to do is to run some script as root, that 'parses' the top command and adds the % CPU user per user, and compares that with limits that you designate in a file. If the user concerned is exceeding his limits, then his processes are 'nice' d to reduce their impact on the CPU usage.

I am not aware of a readily available solution that does this, but a quick and dirty process that does this once every couple of seconds shouldn't be too hard to put together.

HTH:)
ASKER CERTIFIED SOLUTION
Avatar of pjedmond
pjedmond
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial