The files are very useful for troubleshooting performance issues, if you don’t have monitoring solution in place.
To visualize the data into graph, you can use generic plotting tool: gnuplot or special tool designed for sar: ksar.
Visualize sar output by gnuplot
gnuplot can be directly installed online in most Linux distributions.file saved by sar cron job is binary, convert it to ascii format. The following example output CPU usage
$LC_ALL=C;sar -u -f /var/log/sa/sa27 | egrep '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]' | sed '1s/^/#/' >sar-cpu.log
LC_ALL=C to ensure time format is H:M:S
Sed is used to add comment line to the first line: the header.
Create gnuplot script to show user CPU (3th column) and system cpu (5th column) usage
$cat cpu.p
set title 'HOST CPU usage'set xdata timeset timefmt '%H:%M:%S'set xlabel 'time'set ylabel ' CPU Usage'set style data linesplot 'sar-cpu.log' using 1:3 title 'User' ,\'sar-cpu.log' using 1:5 title 'System'
Type ‘gnuplot’ to enter interactive shell then run the script.
gnuplot>
gnuplot> load ‘cpu.p’or$gnuplot -persist cpu.p
#Other advanced operations
#Zoom in, display a set period of data only
Visualize sar output by ksargnuplot> set xrange ['01:51:01':'03:51:01']gnuplot> replot#Save the output to image
gnuplot> set terminal pnggnuplot> set output "cpu.png"
gnuplot> replot
The generic graphing tool, gnuplot, can process any data, it is not designed for sar. As a trade-off, it needs lots of customization.
ksar is specifically desgined for sar and understand Linux, Mac and Solaris sar output.
Kar can be downloaded at http://sourceforge.net/projects/ksar/, Ksar is written in Java, so Java executables are prerequisite for ksar.
#Convert sar binary output to ascii for ksar, “-A” means include all counters
$LC_ALL=C;sar -A -f /var/log/sa/sa27 >sar-all.log
It is very easy to view any counter, once sar output files are imported into ksar.
[root@ kSar-5.0.6]$./run.sh -help
[root@ kSar-5.0.6]$./run.sh -input /tmp/sar-all.log
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.