Editing Sar

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{lowercase}}
 
 
<code>[[Wikipedia: sar (Unix)|sar]]</code> (System Activity Report) is a system utility command used to collect and report different metrics such us [[system load]], CPU activity, [[memory]] (<code>[[sar -r]]</code>), paging (<code>sar -B</code>), swap (<code>sar -S</code>), disk ([[sar -d]]), device load and network. It is extremely useful in analyzing current and recent recorded [[system performance]]. Most Linux distributions provide sar utility binary in the <code>sysstat</code> package. You will also find sar in Solaris, AIX, HP-UX but not in MacOs or FreeBSD.
 
<code>[[Wikipedia: sar (Unix)|sar]]</code> (System Activity Report) is a system utility command used to collect and report different metrics such us [[system load]], CPU activity, [[memory]] (<code>[[sar -r]]</code>), paging (<code>sar -B</code>), swap (<code>sar -S</code>), disk ([[sar -d]]), device load and network. It is extremely useful in analyzing current and recent recorded [[system performance]]. Most Linux distributions provide sar utility binary in the <code>sysstat</code> package. You will also find sar in Solaris, AIX, HP-UX but not in MacOs or FreeBSD.
  
== [[Sar installation]] ==
+
== Installation ==
 +
One line command for installation and basic configuration for collecting :
 +
* Debian/Ubuntu:
 +
:: <code>apt-get -y install sysstat; [[sed]] -i 's/ENABLED="false"/ENABLED="true"/g' /etc/default/sysstat && service sysstat restart && sar</code>
 +
::Optionally modify collection interval in: <code>/etc/[[cron.d]]/sysstat</code>
 +
::Optionally modify collection options in (SADC_OPTIONS="-S XALL"): <code>/etc/sysstat/sysstat</code> (<code>man sadc</code>)
 +
* [[Red Hat]]/[[Fedora]]/Oracle Linux/AWS AMI:
 +
:: <code>yum -y install sysstat && service sysstat start</code>
  
== Binaries ==
 
*<code>/usr/bin/[[sadc]]</code> - System Activity Data Collector, a backend to the sar command. Writes binary log of kernel data to the <code>/var/log/sa/saXX</code> file, where the XX parameter indicates the current day
 
*<code>/usr/bin/sadf</code> - System Activity Data Formatter.        Display data collected by sar in multiple formats.
 
*<code>/usr/bin/sar.sysstat</code> -- (sar is a symbolink link to this binary)
 
  
*<code>/usr/bin/cifsiostat</code>
+
Installing sar Debian, you have to install sysstat package that includes sar and some other performance tools:
*<code>/usr/bin/[[iostat]]</code>
+
* <code>[[apt-get]] -y install sysstat</code>
*<code>/usr/bin/[[mpstat]]</code>
+
* Checking installation: <code>[[dpkg]] -l sysstat</code>
*<code>/usr/bin/pidstat</code>
+
* Binaries installed in ''/usr/bin/'' directory: <code>dpkg -L sysstat | grep "/usr/bin"</code>. Sysstat package contains sar and some other utilities.
*<code>/usr/bin/tapestat</code>
+
* [[Installing sysstat using Ansible]]
 +
 
 +
/usr/bin/[[sadc]] - System Activity Data Collector, a backend to the sar command. Writes binary log of kernel data to the /var/log/sa/saXX file, where the XX parameter indicates the current day
 +
/usr/bin/sadf - System Activity Data Formatter.        Display data collected by sar in multiple formats.
 +
/usr/bin/sar.sysstat  (sar is a symbolink link to this binary)
 +
 
 +
/usr/bin/cifsiostat
 +
/usr/bin/[[iostat]]
 +
/usr/bin/[[mpstat]]
 +
/usr/bin/pidstat
 +
/usr/bin/tapestat
  
 
== Configuration files ==
 
== Configuration files ==
* [[Debian]]/[[Ubuntu]]:
+
[[Debian]]/[[Ubuntu]]:
 
:<code>[[/etc/default/sysstat]]</code>
 
:<code>[[/etc/default/sysstat]]</code>
 
:<code>[[/etc/cron.d/sysstat]]</code>    (Collection interval defined in cron configuration)
 
:<code>[[/etc/cron.d/sysstat]]</code>    (Collection interval defined in cron configuration)
 
:<code>[[/etc/sysstat/sysstat]]</code>  ([[SADC]]_OPTIONS)
 
:<code>[[/etc/sysstat/sysstat]]</code>  ([[SADC]]_OPTIONS)
 
:<code>/etc/sysstat/sysstat.ioconf</code>
 
:<code>/etc/sysstat/sysstat.ioconf</code>
::Data directory: <code>[[/var/log/sysstat/]]</code>
+
::Data directory: <code>/var/log/sysstat</code>
  
* [[RHEL]]
+
[[RHEL]]
:<code>cat [[/etc/sysconfig/sysstat]]</code>
+
cat /etc/sysconfig/sysstat
:<code>cat [[/etc/cron.d/sysstat]]</code>
+
cat /etc/cron.d/sysstat
  
 
== Activation in Debian ==
 
== Activation in Debian ==
* To start collection data modify file <code>[[/etc/default/sysstat]]</code>, changing text <code>disabled</code> by <code>enabled</code>: <code>vi /etc/default/sysstat</code>
+
* To start collection data modify file <code>/etc/default/sysstat</code>, changing text <code>disabled</code> by <code>enabled</code>: <code>vi /etc/default/sysstat</code>
* <code>[[service sysstat restart]]</code> (sysstat written with two "ss" do not misspell with systat with just one "s")
+
* <code>service sysstat restart</code> (sysstat written with two "ss" do not misspell with systat with just one "s")
  
 
Modifying number of days to keep and some other options are done in <code>/etc/sysstat/sysstat</code> file. By default Debian collect files for <code>HISTORY=7</code> 7 days.
 
Modifying number of days to keep and some other options are done in <code>/etc/sysstat/sysstat</code> file. By default Debian collect files for <code>HISTORY=7</code> 7 days.
Line 52: Line 64:
  
 
  5-55/10 * * * * root command -v [[debian-sa1]] > /dev/null && debian-sa1 1 1
 
  5-55/10 * * * * root command -v [[debian-sa1]] > /dev/null && debian-sa1 1 1
 
Every minute
 
* * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
 
  
 
  Every 5 minutes
 
  Every 5 minutes
Line 61: Line 70:
 
  Every 2 minutes
 
  Every 2 minutes
 
  */2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
 
  */2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
 +
 +
Every minute
 +
* * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
  
 
== Usage ==
 
== Usage ==
Line 66: Line 78:
  
 
Binaries
 
Binaries
* <code>[[/usr/bin/sar]]</code> -- reporting utility --  it is a link to /usr/bin/sar.sysstat
+
* <code>/usr/bin/sar</code> -- reporting utility --  it is a link to /usr/bin/sar.sysstat
 
* <code>/usr/lib64/sa/sadc</code>  -- System activity data collector binary, a backend to the sar command. Writes binary log of kernel data to the /var/log/sa/sadd file, where the dd parameter indicates the current day
 
* <code>/usr/lib64/sa/sadc</code>  -- System activity data collector binary, a backend to the sar command. Writes binary log of kernel data to the /var/log/sa/sadd file, where the dd parameter indicates the current day
  
Line 72: Line 84:
 
* <code>/usr/lib64/sa/[[sa1]]</code> or <code>[[/usr/lib/sysstat/sa1]]</code >Collect and store binary data
 
* <code>/usr/lib64/sa/[[sa1]]</code> or <code>[[/usr/lib/sysstat/sa1]]</code >Collect and store binary data
 
* <code>/usr/lib64/sa/[[sa2]]</code> Create a report
 
* <code>/usr/lib64/sa/[[sa2]]</code> Create a report
 
 
* <code>[[sar --help]]</code>
 
  
 
== Basic Usage ==
 
== Basic Usage ==
 
* Displays collected system activity, execute <code>sar</code>, you will have to wait some time, depending on your configuration, for getting collected information:  
 
* Displays collected system activity, execute <code>sar</code>, you will have to wait some time, depending on your configuration, for getting collected information:  
:<code>[[sar (example)|sar]]</code>
+
:<code>sar</code>
 
:<code>[[sar -A]]</code> Report all collected date
 
:<code>[[sar -A]]</code> Report all collected date
 
 
'''[[Memory]]'''
 
'''[[Memory]]'''
 
:<code>[[sar -r]]</code>
 
:<code>[[sar -r]]</code>
 
 
'''[[Swap]]'''
 
'''[[Swap]]'''
 
:<code>[[sar -S]]</code>
 
:<code>[[sar -S]]</code>
:<code>[[sar -W]]</code>
+
'''Disk'''
 
 
'''Disk, [[filesystems]]'''
 
 
:<code>[[sar -d]]</code> To report disk activity. See also <code>[[iostat]] -x</code>.
 
:<code>[[sar -d]]</code> To report disk activity. See also <code>[[iostat]] -x</code>.
 
:<code>[[sar -F]]</code> To report filesystems statistics, disk and [[inodes]] usage. Requires sadc option in <code>/etc/sysstat/sysstat</code> <code>-S XDISK</code> or <code>-S XALL</code> activated.
 
:<code>[[sar -F]]</code> To report filesystems statistics, disk and [[inodes]] usage. Requires sadc option in <code>/etc/sysstat/sysstat</code> <code>-S XDISK</code> or <code>-S XALL</code> activated.
'''[[Network]]'''
+
'''network'''
 
:<code>[[sar -n ALL]]</code> To show '''network''' data collected
 
:<code>[[sar -n ALL]]</code> To show '''network''' data collected
 
'''power management'''
 
'''power management'''
 
:<code>sar -m ALL</code> To show [[power management]] data collected including [[cpu temperature]] (Requires <code>[[sensors]]/[[lm-sensors]]</code> utility to be installed)
 
:<code>sar -m ALL</code> To show [[power management]] data collected including [[cpu temperature]] (Requires <code>[[sensors]]/[[lm-sensors]]</code> utility to be installed)
'''[[Process]]'''
+
'''[[process]]'''
 
:<code>[[sar -q]]</code>
 
:<code>[[sar -q]]</code>
  
Line 108: Line 113:
 
# Install and configure sar to record system activity every 5 minutes
 
# Install and configure sar to record system activity every 5 minutes
 
# Read [[sysstat changelog]]: https://github.com/sysstat/sysstat/blob/master/CHANGES
 
# Read [[sysstat changelog]]: https://github.com/sysstat/sysstat/blob/master/CHANGES
# Read data from day 07 to day 11: <code>echo /var/log/sysstat/sa{07..11}  | [[xargs]] -n1 sar -f</code>
+
# Read data from day 07 to day 11: <code>echo sa{07..11}  | [[xargs]] -n1 sar -f</code>
# Read all collected files: <code>[[for]] SA_FILE in $(ls -1 [[/var/log/sysstat/]]sa??); do sar -f $SA_FILE; done</code>
+
 
  
== Related==
+
== Related terms ==
 
* <code>[[collectl]]</code>
 
* <code>[[collectl]]</code>
 
* [[Prometheus Node exporter]]
 
* [[Prometheus Node exporter]]
* [[Grafana agent]]
 
 
* [[Metricbeat]]
 
* [[Metricbeat]]
 
* [[Zabbix agent]]
 
* [[Zabbix agent]]
 
* [[libsensors4]] package
 
* [[libsensors4]] package
* <code>[[%nice]]</code>
 
  
 
== See also ==
 
== See also ==
 +
* {{top}}
 
* {{io performance commands}}
 
* {{io performance commands}}
* {{sar}}  
+
* {{monitoring}}
 +
* {{sar}}
 +
* [[isag]] - [[wikipedia:tcl]] based command to plot sar/sysstat data
 +
* sargraph https://github.com/sysstat/sysstat/blob/master/contrib/sargraph/sargraph2
 
* systat [[FreeBSD]]<ref>https://www.freebsd.org/cgi/man.cgi?query=systat&apropos=0&sektion=1&manpath=FreeBSD+Ports+11.2&arch=default&format=html</ref> or NetBSD commands.
 
* systat [[FreeBSD]]<ref>https://www.freebsd.org/cgi/man.cgi?query=systat&apropos=0&sektion=1&manpath=FreeBSD+Ports+11.2&arch=default&format=html</ref> or NetBSD commands.
* {{sysstat}}
+
* [[Telegraph]] https://docs.influxdata.com/telegraf/v1.12/introduction/getting-started/
* {{Metrics collectors}}
 
  
 
[[Category:Server administration]]
 
[[Category:Server administration]]
 +
[[Category:Operating systems]]
 +
[[Category:Linux]]
 
[[Category:monitoring]]
 
[[Category:monitoring]]
  

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Advertising: