Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cputool/cputool
  • nkukard/cputool
2 results
Show changes
Commits on Source (23)
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
# Stages we need to progress through
stages:
- build
- release
build_ubuntu_rolling:
stage: build
image: ubuntu:rolling
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y build-essential meson python3-docutils
- meson build
- cd build
- ninja
- ninja install
- cputool --version
build_debian_testing:
stage: build
image: debian:testing
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y build-essential meson python3-docutils
- meson build
- cd build
- ninja
- ninja install
- cputool --version
build_almalinux_rolling:
stage: build
image: almalinux:latest
script:
- dnf -y update
- dnf -y install 'dnf-command(config-manager)'
- dnf config-manager --set-enabled powertools
- dnf -y update
- dnf -y group install "Development Tools"
- dnf -y install meson python3-docutils
- meson build
- cd build
- ninja
- ninja install
- cputool --version
build_idmslinux_rolling:
stage: build
image: idmslinux/rolling
script:
- pacman -Syu --noconfirm base-devel meson python-docutils
- meson build
- cd build
- ninja
- ninja install
- cputool --version
release_job:
image: idmslinux/rolling
stage: release
rules:
- if: $CI_COMMIT_TAG
script:
# Work out variables
- PACKAGE_VERSION=$(echo "$CI_COMMIT_TAG" | sed -e 's/^v//')
- PACKAGE_REGISTRY_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/releases/${PACKAGE_VERSION}"
# Setup environment
- pacman -Syu --noconfirm devtools
# Upload using staging
- cat /usr/share/devtools/pacman-staging.conf > /etc/pacman.conf
- pacman -Syu --noconfirm release-cli
# Release
- assets=()
- release-cli create --name "Release $CI_COMMIT_TAG" --tag-name "$CI_COMMIT_TAG" "${assets[@]}"
Nigel Kukard <nkukard@lbsd.net>
Nigel Kukard <nkukard@LBSD.net>
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell command `./configure && make && make install'
should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
File moved
AM_CFLAGS = -Wall -Werror
cputool_SOURCES = cputool.c cputool.h
cputool_LDADD = -lrt
man8_MANS = cputool.8
bin_PROGRAMS = cputool
# docbook2man writes the output itself, not to stdout
%.8: doc/%.sgml
if [ "$(DOCBOOKTOMAN)" = "docbook2man" ]; then \
$(DOCBOOKTOMAN) $< > /dev/null 2>&1; \
else \
$(DOCBOOKTOMAN) $< 2>&1 > $@ | sed 's/^[^:]*://'; \
fi
# docbook2man creates extra files which need cleaning
distclean-local: killbuildmanpages
killbuildmanpages:
rm -f doc/*.tmp manpage.refs manpage.links
# Introduction
CPU Tool is a utility which can be used to control the CPU utilization of
almost any process. It can take control of processes which are already
running and can also start a process on startup. It can limit CPU usage
running and can also start a process on startup. It can limit CPU usage
depending on both current system load and CPU utilization.
# Building
In order to build CPUTool you will need meson, ninja and rst2man (python-docutils or python3-docutils).
meson builddir
cd builddir
ninja
# Using
Its extremely easy to use:
1. Limit rsync to only use 50% CPU
cputool -c 50 -- rsync -a /home/ /mnt/backup/home
Limit rsync to only use 50% CPU
cputool -c 50 -- rsync -a /home/ /mnt/backup/home
Limit rsync to only use 50% CPU and only run when load is below 3.0
cputool -c 50 -l 3.0 -- rsync -a /home/ /mnt/backup/home
2. Limit rsync to only use 50% CPU and only run when load is below 3.0
cputool -c 50 -l 3.0 -- rsync -a /home/ /mnt/backup/home
Rsync is already running with PID 4324 and we want to limit it to 50% CPU
3. Rsync is already running with PID 4324 and we want to limit it to 50% CPU
cputool -p 4324 -c 50
cputool -p 4324 -c 50
Maybe your machine has multiple processors? easy, express the CPU utilization
......
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.67])
AC_INIT([cputool], [@PKG_VER_MAIN_CLEAN@-@PKG_VER_REL@], [nkukard@lbsd.net])
AM_INIT_AUTOMAKE([-Wno-portability])
AC_CONFIG_SRCDIR([cputool.h])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC_STDC
AC_GNU_SOURCE
# Checks for libraries.
AC_CHECK_LIB([rt], [fabs])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([clock_gettime strerror])
AC_CHECK_PROGS(DOCBOOKTOMAN, docbook-to-man docbook2man, [no],)
if test x"$DOCBOOKTOMAN" = xno
then
AC_MSG_WARN([docbook2man not found])
# fail with a meaningfull error if $DOCBOOKTOMAN called by the makefile
DOCBOOKTOMAN=docbook2man
fi
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
/*
* cputool.c - CPU & load managmenet tool
* Copyright (C) 2012-2014, AllWorldIT
* Copyright (C) 2012-2020, AllWorldIT
* Copyright (C) 2012, Nigel Kukard <nkukard@lbsd.net>
*
* This program is free software: you can redistribute it and/or modify
......@@ -67,7 +67,7 @@ uint64_t statsTimeDelayed = 0;
/* Print out our usage */
static void printUsage(char **argv) {
printf("Usage: %s [options] [command]\n",argv[0]);
printf("%s - Copyright (c) 2012-2021, AllWorldIT\n",PACKAGE_STRING);
printf("Usage: %s [-c PCNT] [-l LOAD] [[-p PID | -P PID] | [--] COMMAND ...]\n",argv[0]);
printf("\n");
printf("Options:\n");
......@@ -429,7 +429,7 @@ static uint64_t getUpdateProcessGroupMembersCPUTime(pid_t pgrp)
/* Loop yet again and close/blank anything not active */
for (p = gPidList; p; p = p->next) {
/* Check if bit was not set */
/* Check if bit was not set */
if ((p->status | CPUTOOL_PID_ACTIVE) != p->status) {
/* Close & reset all data */
if (p->status & CPUTOOL_PID_FDOPEN) {
......@@ -581,10 +581,10 @@ int main (int argc, char *argv[]) {
/* Our long options */
struct option long_options[] = {
{"pid",0,0,'p'},
{"pid-pgrp",0,0,'P'},
{"cpu-limit",0,0,'c'},
{"load-limit",0,0,'l'},
{"pid",1,0,'p'},
{"pid-pgrp",1,0,'P'},
{"cpu-limit",1,0,'c'},
{"load-limit",1,0,'l'},
{"verbose",0,0,'v'},
{"version",0,0,'V'},
{"help",0,0,'h'},
......@@ -609,17 +609,17 @@ int main (int argc, char *argv[]) {
/* Loop with options */
while (1) {
int option_index = 0;
char c;
int opt;
/* Process */
c = getopt_long(argc,argv,"p:P:c:l:vVh",long_options,&option_index);
opt = getopt_long(argc,argv,"p:P:c:l:vVh",long_options,&option_index);
if (c == -1) {
if (opt == -1) {
break;
}
/* Check... */
switch (c) {
switch (opt) {
case 'p':
if (pid != 0) {
fprintf(stderr,"%s: Multiple pid/pidgroups specified.\n",argv[0]);
......@@ -657,7 +657,7 @@ int main (int argc, char *argv[]) {
verbose++;
break;
case 'V':
printf("cputool %s\n",VERSION);
printf("%s\n",PACKAGE_STRING);
return 0;
case 'h':
printUsage(argv);
......
/*
* cputool.h - Headers for the cputool utility
* Copyright (C) 2012-2013, AllWorldIT
* Copyright (C) 2012-2015, AllWorldIT
* Copyright (C) 2012, Nigel Kukard <nkukard@lbsd.net>
*
* This program is free software: you can redistribute it and/or modify
......@@ -45,8 +45,8 @@
/* Structure to hold the info we get from /proc/X/stat */
struct cputool_stat {
int pid; // %d
struct cputool_stat {
int pid; // %d
char comm[256]; // %s
char state; // %c
int ppid; // %d
......@@ -85,9 +85,9 @@ struct cputool_stat {
unsigned long cnswap; // %lu
int exit_signal; // %d
int processor; // %d
unsigned long rt_priority; // %lu
unsigned long policy; // %lu
unsigned long long delayacct_blkio_ticks; // %llu
unsigned long rt_priority; // %lu
unsigned long policy; // %lu
unsigned long long delayacct_blkio_ticks; // %llu
};
/* Format of the /proc/X/stat file */
......
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
<!-- Process this file with docbook-to-man to generate an nroff manual
page: `docbook-to-man manpage.sgml > manpage.1'. You may view
the manual page with: `docbook-to-man manpage.sgml | nroff -man |
less'. A typical entry in a Makefile or Makefile.am is:
manpage.1: manpage.sgml
docbook-to-man $< > $@
The docbook-to-man binary is found in the docbook-to-man package.
Please remember that if you create the nroff version in one of the
debian/rules file targets (such as build), you will need to include
docbook-to-man in your Build-Depends control field.
-->
<!-- Fill in your name for FIRSTNAME and SURNAME. -->
<!ENTITY dhfirstname "<firstname>Nigel</firstname>">
<!ENTITY dhsurname "<surname>Kukard</surname>">
<!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>2014-09-09 18:15</date>">
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
allowed: see man(7), man(1). -->
<!ENTITY dhsection "<manvolnum>8</manvolnum>">
<!ENTITY dhemail "<email>nkukard@lbsd.net</email>">
<!ENTITY dhusername "nkukard">
<!ENTITY dhucpackage "<refentrytitle>CPUTOOL</refentrytitle>">
<!ENTITY dhpackage "cputool">
<!ENTITY author "Nigel Kukard">
<!ENTITY debian "<productname>Debian</productname>">
<!ENTITY gnu "<acronym>GNU</acronym>">
<!ENTITY gpl "&gnu; <acronym>GPL</acronym>">
]>
<refentry>
<refentryinfo>
<address>
&dhemail;
</address>
<author>
&dhfirstname;
&dhsurname;
</author>
<copyright>
<year>2012</year>
<holder>&dhusername;</holder>
</copyright>
&dhdate;
</refentryinfo>
<refmeta>
&dhucpackage;
&dhsection;
</refmeta>
<refnamediv>
<refname>&dhpackage;</refname>
<refpurpose>cputool is a utility which manages CPU usage and system load</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg>--cpu-limit <replaceable>PCNT</replaceable></arg>
<arg>--load-limit <replaceable>LOAD</replaceable></arg>
<group>
<group>
<arg>--pid <replaceable>PID</replaceable></arg>
<arg>--pid-pgrp <replaceable>PID</replaceable></arg>
</group>
<arg><arg>--</arg> <arg rep=repeat choice=plain><replaceable>COMMAND</replaceable></arg></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>
Limit the cpu usage of a process or a process group to a given limit and/or suspend processes if the system load exceeds a
treshold value. Cputool works by sending SIGSTOP and SIGCONT signals to processes depending on the system load.
</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<para>
These programs follow the usual &gnu; command line syntax, with long options starting with two dashes (`-'). A summary of
options is included below.
</para>
<variablelist>
<varlistentry>
<term><option>-c</option>, <option>--cpu-limit <replaceable>PCNT</replaceable></option></term>
<listitem>
<para>
Specify the maxium cpu the process / process group can use. Expressed as percentage of total CPU. Eg. 200 is two full
CPUs in a multi processor system. Specify an integer value.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-l</option>, <option>--load-limit <replaceable>LOAD</replaceable></option></term>
<listitem>
<para>
Specify the maxium load the system may experience for the process process group to continue running. Specifing a
fractional value is possible (e.g. 3.5).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-p</option>, <option>--pid <replaceable>PID</replaceable></option></term>
<listitem>
<para>
Manage the CPU usage of a specific PID. This is the most efficient use of cputool as it does not have to walk the
process tree to look for forks of children.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-P</option>, <option>--pid-pgrp <replaceable>PID</replaceable></option></term>
<listitem>
<para>
Manage the CPU usage of a specific PID's entire process group. The same can be achieved by specifying a
<replaceable>COMMAND</replaceable> which cputool will then execute and manage the process group created by that
command.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option>, <option>--verbose</option></term>
<listitem>
<para>Increase the amount of messages printed to stderr.</para>
<para>-vv will additionally show statistical information.</para>
<para>-vvv will addditionally show signals being sent to processes.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option>, <option>--version</option></term>
<listitem>
<para>Output version information and exit.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-h</option>, <option>--help</option></term>
<listitem>
<para>Display a help page and exit.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>NOTES</title>
<para>
cputool will run on 32-bit and 64-bit Linux systems. It depends on the /proc pseudo-filesystem to detect PIDs and their
resource usage.
</para>
<para>
TCP network connections could time out if a process is suspended for extended periods of time (while the load is too high).
Not all programs handle this case well.
</para>
</refsect1>
<refsect1>
<title>EXAMPLES</title>
<variablelist>
<varlistentry>
<term>cputool -p 4711 -c 75</term>
<listitem>
<para>Limit the PID 4711 to 75% use of one CPU core.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>cputool -l 7.5 -- rsync -av /home /backup/`date +%Y-%m-%d`/</term>
<listitem>
<para>
Run rsync for a local backup only when the system load does not exceed 7.5. See the note for -l when using program that
relies on TCP network connections.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>signals (7), kill(1), uptime(1).</para>
</refsect1>
<refsect1>
<title>AUTHOR</title>
<para>
This manual page was written by Daniel Lange and converted to SGML by &author; &lt;&dhemail;&gt;. Permission is granted to
copy, distribute and/or modify this document under the terms of the &gnu; General Public License, Version 3 any later
version published by the Free Software Foundation.
</para>
<para>
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-3.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
=======
cputool
=======
----------------------------
CPU usage management utility
----------------------------
:Manual section: 8
:Manual group: System Utilities
.. contents::
SYNOPSIS
========
``cputool`` [*OPTION*] [-- *COMMAND*]
DESCRIPTION
===========
CPUTool is a utility which manages CPU usage and system load using SIGSTOP
and SIGCONT. CPUTool is able to "slow down" process CPU usage and manage
load levels caused by processes utilizing CPU and/or IO resources.
A common use for CPUTool is decreasing the CPU load caused by compression
software or backup software where there is no limit on CPU or IO resources
normally imposed, but it can be used to manage almost any process.
OPTIONS
=======
``-h``, ``--help``
Display command line usage then exit.
``-p``, ``--pid`` *PID*
Manage the CPU usage of a specific PID. This is the most efficient use
of CPUTool as it does not have to walk the process tree to look for
forks of children.
``-P``, ``--pid-pgrp`` *PID*
Manage the CPU usage of a specific PID's entire process group. The same can
be achieved by specifying a *COMMAND* which CPUTool will then execute and
manage the process group created by that command.
``-c``, ``--cpu-limit`` *PERCENT*
Specify the maxium CPU the process / process group can use. Expressed as
percentage of total CPU. Eg. 200 is two full CPUs in a multi processor
system. Specify an integer value.
``-l``, ``--load-limit`` *LOAD*
Specify the maxium load the system may experience for the process process
group to continue running. Specifyng a fractional value is possible
(e.g. 3.5).
``-v``, ``--verbose``
Increase the amount of messages printed to stderr.
-vv will additionally show statistical information.
-vvv will addditionally show signals being sent to processes.
``-V``, ``--version``
Output version information and exit.
EXAMPLES
========
Limit the PID 4711 to 75% use of one CPU core:
::
cputool -p 4711 -c 75
Run rsync for a local backup only when the system load does not exceed 7.5.
See the note for -l when using program that relies on TCP network
connections:
::
cputool -l 7.5 -- rsync -av /home /backup/`date +%Y-%m-%d`
NOTES
=====
CPUTool should run on all Linux systems. It depends on the /proc
pseudo-filesystem to detect PIDs and their resource usage.
TCP network connections could time out if process execution is suspended for
extended periods of time (while the load is too high). Not all programs
handle this case well.
BUGS
====
Please report all bugs you discover. This should be done via:
#. the project issue tracker
`https://gitlab.devlabs.linuxassist.net/cputool/cputool/-/issues
<https://gitlab.devlabs.linuxassist.net/cputool/cputool/-/issues>`_
Alternatively, you may report bugs to your software distributor / vendor.
AUTHORS
=======
Please refer to the AUTHORS file distributed with CPUTool.
COPYRIGHT
=========
Copyright (c) 2012-2021, AllWorldIT., and the authors listed in the
CPUTool AUTHORS file.
LICENSE
=======
``cputool`` is distributed under the terms of the GNU v3+.
This is free software; see the source for copying conditions. There
is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE
docs_man_files = [
{ 'name': 'cputool', 'section': '1', 'install': true },
]
docs_man_conf = configuration_data()
docs_man_conf.set('VERSION', meson.project_version())
foreach data : docs_man_files
rst_in_file = '@0@.rst'.format(data['name'])
html_in_file = '@0@.html.in'.format(data['name'])
html_file = '@0@.html'.format(data['name'])
if data.has_key('file')
rst_file = data['file']
else
rst_file = configure_file(
input: rst_in_file,
output: '@0@.rst'.format(data['name']),
configuration: docs_man_conf,
)
endif
if data['install']
man_file = '@0@.@1@'.format(data['name'], data['section'])
man_page = custom_target(
man_file,
input: rst_file,
output: man_file,
# The 'contents' element is the table of contents which is undesired in manpage
command: [ rst2man_prog, '--strip-elements-with-class', 'contents', '--strict', '@INPUT@', '@OUTPUT@' ],
install: true,
install_dir: mandir / 'man@0@'.format(data['section']),
)
endif
endforeach
subdir('manpages')
\ No newline at end of file
project('cputool', 'c',
version : '1.1.0',
license : 'GPL-3.0-or-later',
default_options : ['c_std=c18', 'werror=true'])
# Setup configuration data
conf = configuration_data()
conf.set_quoted('abs_top_builddir', meson.build_root())
conf.set_quoted('abs_top_srcdir', meson.source_root())
conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('VERSION', meson.project_version())
conf.set('_GNU_SOURCE', true)
# Set various paths
if get_option('system')
prefix = '/usr'
libdir = prefix / 'lib64'
if run_command('test', '-d', libdir).returncode() != 0
libdir = prefix / 'lib'
endif
localstatedir = '/var'
sysconfdir = '/etc'
else
prefix = get_option('prefix')
libdir = prefix / get_option('libdir')
localstatedir = prefix / get_option('localstatedir')
sysconfdir = prefix / get_option('sysconfdir')
endif
# if --prefix is /usr, don't use /usr/var for localstatedir or /usr/etc for
# sysconfdir as this makes a lot of things break in testing situations
if prefix == '/usr'
if localstatedir == '/usr/var'
localstatedir = '/var'
endif
if sysconfdir == '/usr/etc'
sysconfdir = '/etc'
endif
endif
runstatedir = get_option('runstatedir')
if runstatedir == ''
runstatedir = localstatedir / 'run'
endif
bindir = prefix / get_option('bindir')
datadir = prefix / get_option('datadir')
includedir = prefix / get_option('includedir')
infodir = prefix / get_option('infodir')
libexecdir = prefix / get_option('libexecdir')
localedir = prefix / get_option('localedir')
mandir = prefix / get_option('mandir')
sbindir = prefix / get_option('sbindir')
sharedstatedir = prefix / get_option('sharedstatedir')
docdir = get_option('docdir')
if docdir == ''
docdir = datadir / 'doc' / meson.project_name()
endif
confdir = sysconfdir / meson.project_name()
pkgdatadir = datadir / meson.project_name()
# Work out compiler flags
cc = meson.get_compiler('c')
possible_cc_flags = ['-fPIE']
possible_link_flags = ['-pie']
if get_option('buildtype') != 'debug'
possible_cc_flags += [
'-ffunction-sections',
'-fdata-sections',
]
possible_link_flags += '-Wl,--gc-sections'
endif
# Add arguments
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
# Locate programs we need
bin_path = [
'/bin',
'/usr/bin',
'/usr/local/bin',
]
required_programs = [
]
required_programs_groups = [
{ 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] },
]
foreach name : required_programs
prog = find_program(name, dirs: bin_path)
varname = name.underscorify()
conf.set_quoted(varname.to_upper(), prog.path())
set_variable('@0@_prog'.format(varname), prog)
endforeach
foreach item : required_programs_groups
prog = find_program(item.get('prog'), dirs: bin_path)
varname = item.get('name').underscorify()
conf.set_quoted(varname.to_upper(), prog.path())
set_variable('@0@_prog'.format(varname), prog)
endforeach
# Write out config.h
config_h = configure_file(
output : 'config.h',
configuration : conf,
)
executable('cputool', 'cputool.c',
install: true,
install_dir: bindir,
)
gen_docs = not get_option('docs').disabled()
if gen_docs
subdir('docs')
endif
# Display summary
misc_summary = {
'docs': gen_docs,
}
summary(misc_summary, section: 'Miscellaneous', bool_yn: true, list_sep: ' ')
option('system', type: 'boolean', value: false, description: 'Set install paths to system ones')
option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')
option('docdir', type: 'string', value: '', description: 'documentation installation directory')
option('docs', type: 'feature', value: 'auto', description: 'whether to generate documentation')