3.记录Load Average 到Log
#!/bin/bash
load_average_file='/home/fdipzone/logs/load_average.log'
touch $load_average_file
while :
do
#load average and cpu
load=`uptime`
printf "$load $(date '+%Y-%m-%d-%T')\n" >> $load_average_file
sleep 0.2
done
exit 0
load_average.log 记录:
13:28:20 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:20
13:28:20 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:20
13:28:20 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:21
13:28:21 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:21
13:28:21 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:21
13:28:21 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:21
13:28:21 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:21
13:28:22 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:22
13:28:22 up 17 min, 2 users, load average: 0.08, 0.17, 0.27 2014-02-16-13:28:22
13:28:22 up 17 min, 2 users, load average: 0.08, 0.16, 0.27 2014-02-16-13:28:22
13:28:22 up 17 min, 2 users, load average: 0.08, 0.16, 0.27 2014-02-16-13:28:22
13:28:23 up 17 min, 2 users, load average: 0.08, 0.16, 0.27 2014-02-16-13:28:23
13:28:23 up 17 min, 2 users, load average: 0.08, 0.16, 0.27 2014-02-16-13:28:23
13:28:23 up 17 min, 2 users, load average: 0.08, 0.16, 0.27 2014-02-16-13:28:23