Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Limiting CPU usage per user

Posted on 2004-08-04
4
Medium Priority
?
2,659 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 760 total points
ID: 11755788
That should have been 'max % of CPU', rather than 'man % of processor usage':)

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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…
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month7 days, 2 hours left to enroll

782 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