Solved

Limiting CPU usage per user

Posted on 2004-08-04
4
2,586 Views
Last Modified: 2013-12-15
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.
0
Comment
Question by:e1337coderz
  • 2
  • 2
4 Comments
 

Author Comment

by:e1337coderz
ID: 11729527
.
0
 

Author Comment

by:e1337coderz
ID: 11729532
.
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 11755692
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:)
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 190 total points
ID: 11755788
That should have been 'max % of CPU', rather than 'man % of processor usage':)

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now