本文共 3132 字,大约阅读时间需要 10 分钟。
[root@makeISO sjx]# cat per-html.sh#!/bin/bash perf () {a ## Size Used Avail Use%#echo '
'echo ' 'echo -e "\n\t -----------------------$1-----------------------\n"echo "Size:Used:Avail:Use(%)"|\ tr '-' ' '|\ awk -F ':' '{printf "\n\t\n\t%s\n\t%s\n\t%s\n\t%s\n\n",$1,$2,$3,$4}' ##CPU - - - 0.63%#ssh $1 iostat |head -4 |tail -1|\ awk '{use=100-$6;\ printf "\n\tCPU\n\t-\n\t-\n\t-\n\t%s%\n\n",use}' ##MEM 10.00GB 2.00GB 8.00GB 20.00%#ssh $1 free -k |grep '+'|\ awk '{size=($3+$4)/1024/1024;used=$3/1024/1024;avail=$4/1024/1024;use=$3*100/($3+$4);\ printf "\n\tMEM\n\t%.2fGB\n\t%.2fGB\n\t%.2fGB\n\t%.2f%\n\n",size,used,avail,use}' ##DISK 1000.00GB 200.00GB 800.00GB 20.00%#ssh $1 df |egrep '[v|s]d[a|b|c|d][[:digit:]]*' |\ awk '{size=($3+$4)/1024/1024;used=$3/1024/1024;avail=$4/1024/1024;use=$3*100/$2;\ printf "\n\t%-s\n\t%.2fGB\n\t%.2fGB\n\t%.2fGB\n\t%.2f%\n\n",substr($1,6),size,used,avail,use}'echo ""} echo \ echo \ perf 10.12.29.1perf 10.12.29.11perf 10.12.29.12perf 10.12.29.13 echo \ echo \ [root@makeISO sjx]# sh per-html.sh >perf.html[root@makeISO sjx]# cat perf.html -----------------------10.12.29.1----------------------- Size Used Avail Use(%) CPU - - - 0.04% MEM 15.58GB 1.01GB 14.57GB 6.48% sda1 186.74GB 10.22GB 176.52GB 5.20% -----------------------10.12.29.11----------------------- Size Used Avail Use(%) CPU - - - 0.07% MEM 3.74GB 1.31GB 2.43GB 35.06% sda1 46.59GB 5.07GB 41.52GB 10.32% -----------------------10.12.29.12----------------------- Size Used Avail Use(%) CPU - - - 0.4% MEM 3.74GB 0.51GB 3.23GB 13.56% sda1 46.59GB 3.72GB 42.87GB 7.58% -----------------------10.12.29.13----------------------- Size Used Avail Use(%) CPU - - - 0.28% MEM 3.74GB 1.26GB 2.48GB 33.73% sda1 46.59GB 3.77GB 42.82GB 7.68%[root@makeISO sjx]# cp perf.html /var/www/html/[root@makeISO sjx]# elinks http://127.0.0.1/perf.html -----------------------10.12.29.1----------------------- Size Used Avail Use(%) CPU - - - 0.04% MEM 15.58GB 1.01GB 14.57GB 6.48% sda1 186.74GB 10.22GB 176.52GB 5.20% -----------------------10.12.29.11----------------------- Size Used Avail Use(%) CPU - - - 0.07% MEM 3.74GB 1.31GB 2.43GB 35.06% sda1 46.59GB 5.07GB 41.52GB 10.32% -----------------------10.12.29.12----------------------- Size Used Avail Use(%) CPU - - - 0.4% MEM 3.74GB 0.51GB 3.23GB 13.56% sda1 46.59GB 3.72GB 42.87GB 7.58% -----------------------10.12.29.13----------------------- Size Used Avail Use(%) CPU - - - 0.28% MEM 3.74GB 1.26GB 2.48GB 33.73% sda1 46.59GB 3.77GB 42.82GB 7.68%[root@makeISO sjx]# yum install -y mutt[root@makeISO sjx]# cat .muttrc set envelope_from=yesset from=admin@linux10.comset realname="admin"set use_from=yes[root@makeISO sjx]# source .muttrc [root@makeISO sjx]# cat /var/www/html/perf.html | mutt -s "服务器资源统计" -e "my_hdr content-type:text/html" www1707@vip.qq.com | | | | |
转载于:https://blog.51cto.com/allen03301/1881044