shell 腳本如下
#!/bin/bash
if (( $# != 1))
then
echo "please input sum times:"
exit 1
fi
sar -u 1 $1 | sed '1,3d'|sed '$d' > sar_cpu_1.txt
sar -r 1 $1 |sed '1,3d'|sed '$d' > sar_men_1.txt
sar -b 1 $1 |sed '1,3d'|sed '$d' > sar_io_1.txt
對txt文件的處理
- 轉(zhuǎn)換KB
- 除掉問題數(shù)據(jù)
function to1024(num){
return parseFloat(parseFloat(num/1024).toFixed(2));
}
function getNotNullArr(arrT){
var temp= [];
for(var i =0; i<arrT.length; i++){
if(arrT[i]!=""){
temp.push(arrT[i]);
}
}
return temp;
}
js展示效果
$(function () {
var rtps= [];
var wtps = [];
var rsk = [];
var wsk = [];
var categories = [];
var temp2;
$.get( "txt/sar_io.txt", function( data ) {
var resourceContent = data.toString(); // can be a global variable too...
var rc = resourceContent.split("\n");
for(var i=0; i<rc.length; i++){
temp2 = getNotNullArr(rc[i].split(" "));
rtps.push(parseFloat(temp2[3]));
wtps.push(parseFloat(temp2[4]));
rsk.push(to1024(temp2[5]));
wsk.push(to1024(temp2[6]));
categories.push(temp2[0]);
}
set_h_title("硬盤IO使用情況 1");
set_h_sub_title("test.com");
set_h_xaxis_setp(2);
set_h_tooltip("");
set_h_yaxis_title("IO使用情況");
set_h_xaxis_categories(categories);
set_h_series( [{name: '讀請求',data:rtps},{name: '寫請求',data:wtps},{name: '讀KB',data:rsk},{name: '寫KB',data:wsk}]);
highchartsinit("#container",get_h_title(),get_h_sub_title(),get_h_xaxis_setp(),get_h_xaxis_categories(),get_h_yaxis_title(),get_h_tooltip(),get_h_series());
});
});
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者