Google+

Sunday 1 December 2013

Sar Command in Linux

SAR (System Activity Monitor) command, frequently used monitoring command in Linux and Unix flavors. sar utility provided by the sysstat package in Linux.

In top we can view the real time analysis (CPU, Memory, load) when we logged into the server. But sar can be used to log the historical events in the server to analyze the bottlenecks with respect to CPU, Memory and load averages in the past.

sysstat package also installs other packages like iostst,pidstat,mpstat,sar etc..

sar utility also installs cron job function to record the historical events.


# vim /etc/cron.d/sysstat


sar
The first cron job used to record the system events for every 10 minutes. Depends on requirement we can change it.
The second cron job runs at midnight to save the daily summary report.

We can also edit the sysstat configuration from the below file.

# vim /etc/sysconfig/sysstat


sar-command-in-linux
The HISTORY and COMPRESSAFTER parameters used to store the sar log files for a specified period of time.


To view the CPU usage of a system.



# sar 2 5


sar-cpu
Displays 5 values of cpu usages with 2 sec interval.

To view the memory usage of a system


# sar -r 1 3

sar memory issue
Displays 3 values of memory usage with 1 sec interval.


To view the server uptime



# uptime

The uptime command used to view

1. how long the server is running(uptime)
2.The no of users logged into the server
3.Load average of the server with  interval 01,05,15 minutes.


uptime