Solved

Limiting CPU usage per user

Posted on 2004-08-04
4
2,595 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

777 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