How to view past performance with sar in Linux – The Geek Diary (2024)

by admin

There are many tools/utilities that can be used to analyze the current system performance. But how do we gauge the historic system performance? For that you can use the System Activity Report (SAR) tool. Using the sar tool, you will be able to look back over a period of time and see how the server has been running.

In this post we will see how to install and use the sysstat tools; thus, allowing you to examine historical system statistics.

Installing sysstat

First thing first, install the “sysstat” which provides the sar utility.

The historic data for various linux distribution is stored in below directories:
1. Red Hat, Fedora, CentOS, and Scientific Linux should use the /var/log/sa directory
2. Debian, Mint, and Ubuntu users should use the /var/log/sysstat directory

By default, sar stats are collected every 10 minutes. The data is collected using a simple cron job configured within /etc/cron.d/sysstat. This job can be amended to collect the data as frequently as you require. Example /etc/cron.d/sysstat file is provided below.

# cat /etc/cron.d/sysstat# Run system activity accounting tool every 10 minutes*/10 * * * * root /usr/lib64/sa/sa1 1 1# 0 * * * * root /usr/lib64/sa/sa1 600 6 &# Generate a daily summary of process accounting at 23:5353 23 * * * root /usr/lib64/sa/sa2 -A

Gathering historical sar data

1. Getting live sar data is easy with sar. By default sar operates in CPU mode. Simply using the command as named, we will receive CPU activity samples for every 10 minutes of the current day.

# sarLinux 2.6.32-504.el6.x86_64 (geeklab) 09/28/2018 _x86_64_ (16 CPU)12:00:01 AM CPU %user %nice %system %iowait %steal %idle12:10:01 AM all 7.28 0.00 2.94 0.02 0.00 89.7712:20:01 AM all 7.16 0.00 2.47 0.02 0.00 90.3512:30:01 AM all 6.96 0.00 2.43 0.01 0.00 90.5912:40:01 AM all 6.92 0.00 2.42 0.01 0.00 90.64...

2. Lets suppose you want to analyse the system performance at some past time. For example view system performance between 10 A.M. to 12 A.M. when application team faced a slowness in their app.

See Also
FAQ

# sar -r -s 10:00:00 -e 12:00:00

sar uses the -s arguement to specify the start time of a data extract and another (-e) to set the end time. These parameters must be written in HH:MM:SS format, or sar will ignore them with an error. The -r argument is used to display memory usage data.

3. sar historic data is stored in /var/log/sa directory in case of RedHat based distributions. Files are simply binary formats containing sar data for each retained date. Files are prefixed with sa. Thus, sa23 is the sar data for the 23rd of the month. For example, on a CenOS/RHEL system.

# ls /var/log/sasa01 sa04 sa07 sa10 sa13 sa16 sa19 sa22 sa25 sa28 sar01 sar04 sar07 sar10 sar13 sar16 sar19 sar22 sar25 sar30sa02 sa05 sa08 sa11 sa14 sa17 sa20 sa23 sa26 sa30 sar02 sar05 sar08 sar11 sar14 sar17 sar20 sar23 sar26 sar31sa03 sa06 sa09 sa12 sa15 sa18 sa21 sa24 sa27 sa31 sar03 sar06 sar09 sar12 sar15 sar18 sar21 sar24 sar27

Execute the following command to view past I/O statistics for the 10th of the month:

# sar -f /var/log/sysstat/sa10 -b

Changing sar historical data retention

One can change the historical sar data retention using the file /etc/sysconfig/sysstat or /etc/sysstat/sysstat. Change the HISTORY parameter setting to the desired amount of days to retain data. For example, to keep 28 days of records, we could use this:

# cat /etc/sysconfig/sysstat# sysstat-9.0.4 configuration file.# 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.HISTORY=28# Compress (using gzip or bzip2) sa and sar files older than (in days):COMPRESSAFTER=31# Parameters for the system activity data collector (see sadc manual page)# which are used for the generation of log files.SADC_OPTIONS="-S DISK"# Compression program to use.ZIP="bzip2"

You May Also Like

How to view past performance with sar in Linux – The Geek Diary (2024)
Top Articles
10+ Best Python Web Frameworks for Development in 2022
What does the HR Value Chain
Artem The Gambler
Pixel Speedrun Unblocked 76
Dte Outage Map Woodhaven
Belle Meade Barbershop | Uncle Classic Barbershop | Nashville Barbers
How Many Cc's Is A 96 Cubic Inch Engine
Mychart Mercy Lutherville
Alpha Kenny Buddy - Songs, Events and Music Stats | Viberate.com
Barstool Sports Gif
Lost Pizza Nutrition
Toonily The Carry
Prices Way Too High Crossword Clue
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
Walmart Double Point Days 2022
7 Fly Traps For Effective Pest Control
Connect U Of M Dearborn
Watch The Lovely Bones Online Free 123Movies
Walgreens Tanque Verde And Catalina Hwy
Hdmovie 2
Pjs Obits
Bjerrum difference plots - Big Chemical Encyclopedia
Aol News Weather Entertainment Local Lifestyle
Which Sentence is Punctuated Correctly?
Discord Nuker Bot Invite
fft - Fast Fourier transform
Amerisourcebergen Thoughtspot 2023
Marilyn Seipt Obituary
Annapolis Md Craigslist
Craigslist Auburn Al
Progressbook Newark
Noaa Marine Forecast Florida By Zone
5 Star Rated Nail Salons Near Me
Best New England Boarding Schools
Fastpitch Softball Pitching Tips for Beginners Part 1 | STACK
Kristen Hanby Sister Name
Smartfind Express Henrico
Xemu Vs Cxbx
Avance Primary Care Morrisville
KM to M (Kilometer to Meter) Converter, 1 km is 1000 m
Dying Light Nexus
Conroe Isd Sign In
Janaki Kalaganaledu Serial Today Episode Written Update
Sofia With An F Mugshot
Celsius Claims Agent
About Us
Craigslist Houses For Rent Little River Sc
Vci Classified Paducah
Quest Diagnostics Mt Morris Appointment
Erica Mena Net Worth Forbes
Grandma's Portuguese Sweet Bread Recipe Made from Scratch
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated:

Views: 5528

Rating: 5 / 5 (50 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.