Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Limiting CPU usage per user

Posted on 2004-08-04
4
Medium Priority
?
2,639 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

721 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