From Gentoo Wiki
Jump to:navigation Jump to:search

The sysstat (system statistics) utilities are a collection of performance monitoring tools for Linux. They function as front ends to the kernel's /proc filesystem making statistics easy to access. Sysstat was written by Sebastien Godard.


USE flags

USE flags for app-admin/sysstat System performance tools for Linux

dcron Adjust cronjobs to work properly under sys-process/dcron
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
lm-sensors Add linux lm-sensors (hardware sensors) support
nls Add Native Language Support (using gettextGNU locale utilities)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
static !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking

Add or remove the desired flags to /etc/portage/package.use or /etc/portage/make.conf:

FILE /etc/portage/package.useSysstat package.use example
app-admin/sysstat lm-sensors nls


Emerge app-admin/sysstat:

root #emerge --ask app-admin/sysstat


The /etc/sysstat file influences the behavior of /usr/lib64/sa/sa1 and (sadc(8)) /usr/lib64/sa/sa2 (sar(1)). This file sourced from /bin/sh and it's syntax should thus conform to IEEE Std 1003.1.

The following variables will have some effect:

Variable Description Suggested Value Affected Commands
HISTORY How long to keep log files (in days). If value is greater than 28, then log files are kept in multiple directories, one for each month. 365 sa1


COMPRESSAFTER Compress (using gzip or bzip2) sa and sar files older than (in days) 10 sa2
SADC_OPTIONS Parameters for the system activity data collector (see sadc manual page) which are used for the generation of log files. -S XALL sa1

Statistics Collection and Aggregation

Statistics collection can be achieved by periodical execution of /usr/lib64/sa/sa1 (which invokes sadc) and /usr/lib64/sa/sa2 (which invokes sar).

The common approach is to use crontab(5) or /etc/cron.{hourly,daily,monthly,weekly}.


The cron USE flag installs the files show below.
FILE /etc/cron.hourly/sysstatSetting cron to run an accounting job
# Run system activity accounting tool every 10 minutes
/usr/lib64/sa/sa1 600 6 &
FILE /etc/cron.daily/sysstat
# Generate a daily summary of process accounting. Since this will probably
# get kicked off in the morning, it would probably be better to run against
# the previous days data.
/usr/lib64/sa/sa2 -A &


Ensure that the cron USE flag is not set when this method is used.
root #crontab -l
# app-admin/sysstat : collect system statistics every 10 minutes
*/10    *       *       *       *       /usr/lib64/sa/sa1 1 1
# app-admin/sysstat : aggregate system statistics every day at 23h00
0	23	*	*	*	/usr/lib64/sa/sa2 -A &


The following tools are included with sysstat on Gentoo:[1]

Command Description
cifsiostat Reports CIFS statistics.
iostat Reports CPU statistics and input/output statistics for devices, partitions and network filesystems.
mpstat Reports individual or combined processor related statistics.e
nfsiostat-sysstat Reports input/output statistics for network filesystems (NFS).
pidstat Reports statistics for Linux tasks (processes): I/O, CPU, memory, etc.
sadf Displays data collected by sar in multiple formats (CSV, XML, etc.) Useful to load performance data into a database, or import them to spreadsheets to make graphs.
sar Collects, reports and saves system activity information (CPU, memory, disks, interrupts, network interfaces, TTY, kernel tables, etc.)


Use iostat to watch the input/output of data to attached drives, display the output in megabytes:

user $watch iostat -m

See Also

  • Iotop — a top-like utility that monitors system input/output.
  • Atop
  • Htop — a cross-platform interactive process viewer. It is a text-mode application (for console or X terminals) and requires ncurses.

External Resources

Local man pages will only be available if the doc USE was enabled at build time.
  • The cifsiostat man page locally (man cifsiostat) or online.
  • The iostat man page locally (man iostat) or online.
  • The mpstat man page locally (man mpstat) or online.
  • The pidstatman page locally (man pidstat) or online.
  • The sadf man page locally (man sadf) or online.
  • The sar man page locally (man sar) or online.
  • The sysstat man page locally (man sysstat) or online.
  • The sa1 man page locally (man sa1) or online.
  • The sa2 man page locally (man sa2) or online.
  • The sadc man page locally (man sadc) or online.