how to install configure and use sysstat utils on rhel 7

16
How to Install Configure and Use sysstat Utils i | Page Contents Overview ....................................................................................................................................................... 1 SAR Package Installation ............................................................................................................................... 1 Verify Installed Status ............................................................................................................................... 1 Install Package........................................................................................................................................... 2 Enable Sysstat Service ............................................................................................................................... 2 Start Sysstat Service .................................................................................................................................. 3 Stop Sysstat Service .................................................................................................................................. 3 Restart Sysstat Service .............................................................................................................................. 4 Check Sysstat Service Status ..................................................................................................................... 4 Sysstat – Default Configuration .................................................................................................................... 5 Sysstat – Cron Job Configuration .................................................................................................................. 5 Package Binaries and Purpose ...................................................................................................................... 6 SAR – Reports Generation ............................................................................................................................ 7 SAR Command – Syntax ............................................................................................................................ 7 SAR Command – Examples ....................................................................................................................... 7 CPU Utilization Statistics ........................................................................................................................... 7 Memory Utilization Statistics .................................................................................................................... 8 Block Device Statistics ............................................................................................................................... 8 Hugepage Utilization Statistics ................................................................................................................. 9 Interrupt Statistics .................................................................................................................................... 9 Network Statistics ..................................................................................................................................... 9 Network Statistics Options.................................................................................................................. 10 Kernel, INode and File Statistics.............................................................................................................. 10 Swap Space Utilization Statistics............................................................................................................. 11 I/O Statistics ............................................................................................................................................ 11 Paging Statistics ...................................................................................................................................... 12 Run Queue Length and Load Average Statistics ..................................................................................... 12 Swap Space Utilization Statistics............................................................................................................. 13 SAR Report – Write Output File .............................................................................................................. 13 SAR Report – Read Output File ............................................................................................................... 13 SAR Report – Read Specific Day Report .................................................................................................. 14

Upload: vcp-muthukrishna

Post on 07-Apr-2017

7.877 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

i | P a g e

Contents

Overview ....................................................................................................................................................... 1

SAR Package Installation ............................................................................................................................... 1

Verify Installed Status ............................................................................................................................... 1

Install Package ........................................................................................................................................... 2

Enable Sysstat Service ............................................................................................................................... 2

Start Sysstat Service .................................................................................................................................. 3

Stop Sysstat Service .................................................................................................................................. 3

Restart Sysstat Service .............................................................................................................................. 4

Check Sysstat Service Status ..................................................................................................................... 4

Sysstat – Default Configuration .................................................................................................................... 5

Sysstat – Cron Job Configuration .................................................................................................................. 5

Package Binaries and Purpose ...................................................................................................................... 6

SAR – Reports Generation ............................................................................................................................ 7

SAR Command – Syntax ............................................................................................................................ 7

SAR Command – Examples ....................................................................................................................... 7

CPU Utilization Statistics ........................................................................................................................... 7

Memory Utilization Statistics .................................................................................................................... 8

Block Device Statistics ............................................................................................................................... 8

Hugepage Utilization Statistics ................................................................................................................. 9

Interrupt Statistics .................................................................................................................................... 9

Network Statistics ..................................................................................................................................... 9

Network Statistics Options.................................................................................................................. 10

Kernel, INode and File Statistics.............................................................................................................. 10

Swap Space Utilization Statistics ............................................................................................................. 11

I/O Statistics ............................................................................................................................................ 11

Paging Statistics ...................................................................................................................................... 12

Run Queue Length and Load Average Statistics ..................................................................................... 12

Swap Space Utilization Statistics ............................................................................................................. 13

SAR Report – Write Output File .............................................................................................................. 13

SAR Report – Read Output File ............................................................................................................... 13

SAR Report – Read Specific Day Report .................................................................................................. 14

Page 2: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

ii | P a g e

SAR Report – Read Specific Day and Time Report .................................................................................. 14

Page 3: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

1 | P a g e

Overview

The System Activity Report or SAR report; collects, reports and save(s) CPU, Memory & I/O usages at regular intervals.

“sar” command supports generating different types of reports on fly and these reports can be exported as well. In this guide we will explain sar command execution with various attributes.

SAR will collate and give information about below;

1. Block Device Statistics 2. Paging Statistics 3. Swap Statistics 4. CPU Utilization Statistics 5. Memory Utilization Statistics 6. Interrupt Statistics 7. Network Statistics 8. Power Management Statistics 9. Report I/O Statistics 10. Report Hugepages utilization statistics

SAR Package Installation

SAR package installation is simple and easy; to install the package follow the below steps.

Verify Installed Status

Before you install the package, check if the package is already installed, to know the package is already installed, run the command;

yum list installed sysstat

Page 4: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

2 | P a g e

Install Package

After checking the package installation and you found that the package is not installed, to install the package run the command;

yum install sysstat -y -q && yum list installed sysstat -q

Enable Sysstat Service

After installation, ensure that the sysstat is enabled, so that it can startup automatically upon boot-up. To enable the service run the command;

systemctl enable sysstat

Page 5: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

3 | P a g e

Start Sysstat Service

Next, you need to start the sysstat service to generate the reports, to start the command;

systemctl start sysstat && systemctl status sysstat -l

Stop Sysstat Service

In case you would like to stop the service run the command;

systemctl stop sysstat && systemctl status sysstat -l

Page 6: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

4 | P a g e

Restart Sysstat Service

In case you would like to restart the service run the command;

systemctl restart sysstat && systemctl status sysstat -l

Check Sysstat Service Status

To check the sysstat service status, run the command;

systemctl status sysstat -l

Page 7: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

5 | P a g e

Sysstat – Default Configuration

Sysstat can be configured as per the business need and disk availability on the server, to view the current configuration run the below command; Each attribute can be reconfigured as per the requirement of the business.

egrep -v '^#|^$|^;' /etc/sysconfig/sysstat

Attribute Default Purpose

HISTORY 28 Configure statistics data to be retained for day(s)

COMPRESSAFTER 31 Compress statistics data after day(s)

SADC_OPTIONS "-S DISK" Configure system activity diagnostics collector option

ZIP "bzip2" Compression command for compressing

Sysstat – Cron Job Configuration

After configuring the sysstat, next we should configure cron job to collect periodical and store “SAR” reports. To view current cron job, run the command 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:53 53 23 * * * root /usr/lib64/sa/sa2 -A

Note: If the job is not configured, copy and paste the above snippet into new cron job.

Page 8: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

6 | P a g e

Package Binaries and Purpose

Package / Binary Purpose / Usage

sysstat To define the maximum no. of days to save SAR reports

/usr/bin/sar Collect, report, or save system activity information

/usr/bin/iostat Report Central Processing Unit (CPU) statistics and input/output statistics

/usr/bin/mpstat Report processors related statistics

/usr/bin/sadf Display data collected by SAR in multiple formats

/usr/lib64/sa summarizes accounting information

/usr/lib64/sa/sa1 Collect and store binary data in the system activity daily data file

/usr/lib64/sa/sa2 Write a daily report in the “/var/log/sa” directory

/usr/lib64/sa/sadc System activity data collector

/usr/bin/cifsiostat Report CIFS statistics

/usr/bin/nfsiostat Report input/output statistics for network filesystems (NFS).

/usr/bin/pidstat Report statistics for Linux tasks.

/usr/lib/systemd/system/sysstat.service

Sysstat Systemd Management control file

Page 9: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

7 | P a g e

SAR – Reports Generation

One of the main purpose “SAR” package is to generate System activity reports on fly and export those reports in different format.

SAR Command – Syntax

sar -[Options] [Interval] [Iteration Count]

sar -[Options] -s [hh:mm:ss] -e [hh:mm:ss] [Interval] [Iteration Count]

sar -o [output filename] [interval] [Iteration Count] >/dev/null 2>&1 &

SAR Command – Examples

SAR Command Purpose

sar -r 10 5 Memory utilization statistics every ten seconds for 5 times.

sar -r -s 10:00:15 -e 10:15:00 Memory utilization statistics report between specific timeframe.

sar -o /tmp/mem_stats -r -u 2 5 >/dev/null 2>&1 & Memory utilization statistics into output file.

CPU Utilization Statistics

To generate CPU Utilization statistics, run the command;

sar -u

sar -u [ALL] 2 2

Note: The above command will run 2 times for CPU utilization statistics every 2 seconds. “ALL” represents all CPU related fields should be shown.

Page 10: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

8 | P a g e

Memory Utilization Statistics

To generate CPU Utilization statistics, run the command;

sar -r

sar -r 2 2

Note: The above command will run 2 times for Memory utilization report every 2 seconds.

Block Device Statistics

To generate block devices statistics, run the command;

sar -d

sar -d 2 2

Note: The above command will run 2 times for each Block Device(s) report every 2 seconds.

Page 11: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

9 | P a g e

Hugepage Utilization Statistics

To generate hugepage utilization statistics, run the command;

sar -H

sar -H 2 2

Note: The above command will run 2 times for huge pages info every 2 seconds.

Interrupt Statistics

To generate interrupt statistics, run the command;

sar -I 15 2 2

sar -I SUM 2 2

Note: The above command will run 2 times for all interrupts report every 2 seconds

Network Statistics

To generate network statistics, run the command;

sar -n [options] 2 2

sar -n DEV 2 2

Page 12: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

10 | P a g e

Network Statistics Options

Option Purpose

DEV Network interfaces

EDEV Network interfaces (errors)

NFS NFS client

NFSD NFS server

SOCK Sockets (v4)

IP IP traffic (v4)

EIP IP traffic (v4) (errors)

ICMP ICMP traffic (v4)

EICMP ICMP traffic (v4) (errors)

TCP TCP traffic (v4)

ETCP TCP traffic (v4) (errors)

UDP UDP traffic (v4)

SOCK6 Sockets (v6)

IP6 IP traffic (v6)

EIP6 IP traffic (v6) (errors)

ICMP6 ICMP traffic (v6)

EICMP6 ICMP traffic (v6) (errors)

UDP6 UDP traffic (v6)

Kernel, INode and File Statistics

To generate INode, file and other kernel table statistics, run the command;

sar -v 2 5

Page 13: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

11 | P a g e

Swap Space Utilization Statistics

To generate swap space utilization statistics, run the command;

sar -S

sar -S 2 2

Note: The above command will run 2 times for swap usage info report every 2 seconds.

I/O Statistics

To generate input/output (I/O) statistics, run the command;

sar -b

sar -b 2 2

Note: The above command will run 2 times for I/O transfer rates info every 2 seconds.

Page 14: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

12 | P a g e

Paging Statistics

To generate paging statistics, run the command;

sar -B

sar -B 2 2

Note: The above command will run 2 times for paging usage info report every 2 seconds.

Run Queue Length and Load Average Statistics

To generate queue length and load averages statistics, run the command;

sar -q

sar -q 2 2

Note: The above command will run 2 times for load & queue usage info report every 2 seconds.

Field Purpose

runq-sz Run queue length (number of processes waiting for run time)

plist-sz Number of processes and threads in the process list

ldavg-1 System load average for the last minute

ldavg-5 System load average for the past 5 minutes

ldavg-15 System load average for the past 15 minutes

Page 15: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

13 | P a g e

Swap Space Utilization Statistics

To generate swap space utilization statistics, run the command;

sar -S

sar -S 2 2

SAR Report – Write Output File

To store “sar” report to a data file, data file is stored in binary format and can be read by sar command, to store the report/data into a file run the command;

sar -o /tmp/cpu_utilization_output_file -u 2 5 >/dev/null 2>&1 &

SAR Report – Read Output File

To read “sar” data file, run the command;

sar -f /tmp/cpu_utilization_output_file

Page 16: How to Install Configure and Use sysstat utils on RHEL 7

How to Install Configure and Use sysstat Utils

14 | P a g e

SAR Report – Read Specific Day Report

All the data files are stored in the directory “/var/log/sa/” by default it’s configured for 28 days. In order to read a specific day’s report, run the command;

sar -f /var/log/sa/saXX

sar -f /var/log/sa/sa10

Note: Day of the month is represented by saXX, where xx means day of month.

SAR Report – Read Specific Day and Time Report

All the data files are stored in the directory “/var/log/sa/” by default it’s configured for 28 days. In order to read a specific day and time report, run the command;

sar -f /var/log/sa/saXX -e -s 21:00:00 -e 22:00:00

sar -f /var/log/sa/sa10 -e -s 21:00:00 -e 22:00:00

Note: Day of the month is represented by saXX, where XX means day of month.