sysstat(sar), systemd and better stats

When installing sysstat on a systemd based installation there will be 3 services that get installed:

  • sysstat
  • sysstat-collect.timer
  • sysstat-collect.service

By default, sysstat will do its normal 1s/10m collectiof data, which isn’t great. But, you can change how sysstat collects data by modifying the sysstat-collect.service unit to change the sa1 command to:

[Unit]
Description=system activity accounting tool
Documentation=man:sa1(8)
After=sysstat.service

[Service]
Type=oneshot
User=root
ExecStart=/usr/lib/sa/sa1 -S XALL 60 1

This will cause sysstat to collect data for 60s and then write it out to the archive. This gives you a full minute worth of samples every minute, a much better statistic than 1s per 10 minutes worth of data, that is only 1/600th of the info you’ll likely want!

To make this work, you’ll also have to change the sysstat-collect.timer so it fires off the service every minute instead of once every 10 minutes. The timer unit should become:

# /usr/lib/systemd/system/sysstat-collect.timer
# (C) 2014 Tomasz Torcz <tomek@pipebreaker.pl>
#
# sysstat-12.5.5 systemd unit file:
#        Activates activity collector every 10 minutes

[Unit]
Description=Run system activity accounting tool every 1 minute

[Timer]
OnCalendar=*:00/1

[Install]
WantedBy=sysstat.service

Making these two changes will give you more accurate system statistics as well as all the system statistics information (like interrupts and such) that a process like netdata collects but in the compact, serialized data format used by sysstat which will save disk space and make maintenance through the cli more friendly.

About

Agathezol is a gamer, programmer, father, husband, and musician. When he's not writing blog posts nobody reads he generally writes protocol stacks, network code, and core telecommunications software but has dabbled in game design, web programming, mobile device software, and desktop software.

Categories: General, Linux