CPU:
linux: vmstat 1 5 | awk '{if(NR>=3) {sum+=$15;l++}} END{printf("cpu average use %f%\n",100-sum/l)}'
aix: vmstat 1 5 | awk '{if(NR>6) {sum+=$16;l++}} END{printf("%f\n",100-sum/l)}'
内存:
linux: free | awk '{if($1~"Mem:") printf("%f\n",(1-($4+$6+$7)/$2)*100)}'
free | awk '{if($1~/Mem/) total=$2;if($2~/buffer/) used=$3} END{printf("%f%s\n", used/total*100,"%")}'
aix: svmon -G | awk '{if($1=="memory") printf("%f\n",$3/$2*100)}'
磁盘:
linux: df | awk '{if($1~"/dev") l++;sub("%","");sum+=$5;} END{printf("%f\n", sum/l)}'
df | awk -F'[ %]+' '{if($1~"/dev") l++;sum+=$5;} END{printf("%f\n",sum/l)}'
aix: df -k | awk -F'[ %]+' '{if(NR>1 && $1~"/dev") {sum+=$6;l++}} END{printf("%f\n",sum/l)}'
阅读(650) | 评论(0) | 转发(1) |