1. 程式人生 > >linux抓取load average數據

linux抓取load average數據

uptime data time style ive div second linux span

#!/bin/bash

echo ‘‘ > ~/getLoad/1minute.txt
echo ‘‘ > ~/getLoad/5minute.txt
echo ‘‘ > ~/getLoad/15minute.txt

#get load average data
oneminute=`uptime |awk {print $8}`
fiveminute=`uptime |awk {print $9}`
fifteenminute=`uptime |awk {print $10}`
SECONDS=0

# echo ${oneminute:0:4}

while [ $SECONDS -le 1200 ] do echo ${oneminute:0:4} >> ~/getLoad/1minute.txt echo ${fiveminute:0:4} >> ~/getLoad/5minute.txt echo ${fifteenminute} >> ~/getLoad/15minute.txt sleep 2 done

linux抓取load average數據