8. iostat sar
[root@server1 ~]# ls –l /var/log/sa
总计 10428
-rw-r--r-- 1 scott scott 580848 2008-11-01 sa01
-rw-r--r-- 1 scott scott 577424 2008-11-02 sa02
-rw-r--r-- 1 scott scott 580848 2008-11-03 sa03
-rw-r--r-- 1 scott scott 580848 2008-11-04 sa04
-rw-r--r-- 1 scott scott 578672 2008-10-28 sa28
-rw-r--r-- 1 scott scott 580848 2008-10-29 sa29
-rw-r--r-- 1 scott scott 580848 2008-10-30 sa30
-rw-r--r-- 1 scott scott 580848 2008-10-31 sa31
-rw-r--r-- 1 scott scott 633705 2008-11-01 sar01
-rw-r--r-- 1 scott scott 614991 2008-11-02 sar02
-rw-r--r-- 1 scott scott 633714 2008-11-03 sar03
[root@server1 ~]# sar -b -f /var/log/sa/sa04
-rw-r--r-- 1 scott scott 628709 2008-10-27 sar27
Linux 2.6.18-92.el5 (rac1) 10/05/2008
-rw-r--r-- 1 scott scott 620661 2008-10-28 sar28
-rw-r--r-- 1 scott scott 633705 2008-10-29 sar29
-rw-r--r— 1 scott scott 633705 2008-10-30 sar30 rtps
12:00:01 PM tps wtps bread/s bwrtn/s
12:10:01 PM 423.63 29.29 394.34 637.68 3852.12
-rw-r--r-- 1 scott scott 633705 2008-10-31 sar31
12:20:01 PM 419.81 24.26 395.55 495.33 3881.80
12:30:01 PM 421.92 33.01 388.90 777.04 3849.28
12:40:01 PM 420.26 30.92 389.34 712.69 3879.17
9. Gnuplot (1)
[root@server1 ~]# LANG=C sar -P ALL -f /var/log/sa/sa04 | awk '/^[012]/ {print $0}' | grep
all > cpu.dat
[root@server1 ~]# LANG=C sar -b -f /var/log/sa/sa04 | awk '/^[012]/ {print $0}' > io.dat
此处生成了两个规则的数据文件,以cpu.dat为例说明此组合命令:
LANG=C 以24小时为时间统计标准
sar -P ALL -f /var/log/sa/sa04 获得所有CPU负载数据
awk '/^[012]/ {print $0}' 过滤出以0,1,2开始的行
grep all 过滤出带有all字眼的行
[root@server1 ~]# gnuplot
gnuplot> set xdata time
gnuplot> set timefmt "%H:%M:%S"
gnuplot> set xlabel "TIME"
gnuplot> set ylabel "CPU/IO"
set xdata time 配置当前X轴的数据为时间
set timefmt “%H:%M:%S” 配置时间的显示格式
set xlabel “TIME” 命名X轴为“TIME”
set xlabel “CPU/IO” 命名X轴为“CPU/IO”
通过cpu.dat文件的第3列输入数据,图表名字为CPU,以直线方式连接数据点,并生成图表
gnuplot> plot "cpu.dat" using 1:($3) title "CPU" with lines