CPULimit, limiter les ressources CPU utilisées par un processus sous Debian
Date de publication Samedi 05 mars 2011 à 13:03:27
par Cyril
Catégorie Administration Linux
Voici un outil bien sympathique, simple d'utilisation qui peut rendre bien des services :
cpulimit
Dans bien des situations, il peut être intéressant de limiter l'usage du ou des processeur(s) de sa machine, pour ce faire nous allons utiliser ici un limiteur maléable permettant par exemple de limiter un processus par son nom ou par son PID
Tout d'abord installons cpulimit
Cyril: /home/nunux/
aptitude install cpulimit
Voyons ensuite comment limiter un processus ...
Supposons
limiter le service proftpd par exemple à 20% d'utilisation CPU ( valable pour un processeur ou un coeur )
Cyril: /home/nunux/
cpulimit -e proftpd -l 20
Plus long mais tout autant jouable
Cyril: /home/nunux/
cpulimit --exe proftpd --limit 20
Il est aussi possible de limiter un processus par son PID, dans ce cas il suffira de localiser le PID avec un simple
HTOP au préalable puis
Cyril: /home/nunux/
cpulimit -p Numéro-du-PID -l 20
Plus long mais tout autant jouable
Cyril: /home/nunux/
cpulimit --pid Numéro du PID --limit 20
Ah dernier détail et pas des moindres,
cplumit restera en premier plan dans votre console, pour s'en sortir
saisissez la combinaison de touches CTRL+C !
Voici un petit man de cpulimit pour mémoire :)
Cyril: /home/nunux/
CPULIMIT(1) User commands CPULIMIT(1)
NAME
cpulimit -- limits the CPU usage of a process
SYNOPSIS
cpulimit TARGET [OPTIONS...]
DESCRIPTION
TARGET must be exactly one of these:
-p, --pid=N
pid of the process
-e, --exe=FILE
name of the executable program file
-P, --path=PATH
absolute path name of the executable program file
OPTIONS
-l, --limit=N
percentage of CPU allowed from 0 to 100 (mandatory)
-v, --verbose
show control statistics
-z, --lazy
exit if there is no suitable target process, or if it dies
-h, --help
display this help and exit
EXAMPLES
Assuming you have started âfoo --barâ and you find out with top(1) or ps(1) that this process uses all your CPU time you can
either
# cpulimit -e foo -l 50
limits the CPU usage of the process by acting on the executable program file (note: the argument "--bar" is omitted)
# cpulimit -p 1234 -l 50
limits the CPU usage of the process by acting on its PID, as shown by ps(1)
# cpulimit -P /usr/bin/foo -l 50
same as -e but uses the absolute path name
AUTHOR
This manpage was written for the Debian project by gregor herrmann but may be used by others.
cpulimit November 2006 CPULIMIT(1)
Billet issu du site internet Cyril Levert, my blog
http://www.cyril-levert.info
URL du billet
http://www.cyril-levert.info/blog_cpulimit_limiter_les_ressources_cpu_utilisees_par_un_processus_sous_debian_105.html