1、cpu
./bunsan2.sh uptime < servers.txt | awk '{print $11 }' |sed 's/,//g'
#!/bin/bashcpu_load=$(uptime | awk '{print $11 }' |sed 's/,//g')echo $cpu_load > /home/data/wuxi147_cpu.txtscp /home/data/wuxi147_cpu.txt root@58.241.41.150:/usr/local/apache2/htdocs/
2、内存
#!/bin/bashtotal=$(free -m|grep Mem|awk '{print $2}')used=$(free -m|grep Mem|awk '{print $3}')echo "$used/$total"|bc -l |awk '{printf "%.2f%\n",$1*100 }' > /home/data/wuxi147_memory.txtscp /home/data/wuxi147_memory.txt root@58.241.41.150:/usr/local/apache2/htdocs/
#!/bin/bashcount=1for i in {1..6..1}dototal=$(free -m|grep Mem|awk '{print $2}')used=$(free -m|grep Mem|awk '{print $3}')echo "$used/$total"|bc -l > /home/data/memory1.txtawk '{printf "%.2f%\n",$1*100 }' /home/data/memory1.txt > /usr/local/apache2/htdocs/wuxi150_memory.txtecho $isleep 10done
3、磁盘
#!/bin/bashLocation=/dev/sda3Disk_Used_Rate=$(df -h | grep $Location | awk '{print $5}')echo $Disk_Used_Rate > /home/wuxi147_disk.txtscp /home/wuxi147_disk.txt root@58.241.41.150:/usr/local/apache2/htdocs/
#!/bin/bashLocation=/dev/sda3total=$(df -h |grep $Location | awk '{print $2}'|sed 's/G//g' )used=$(df -h |grep $Location | awk '{print $4}'|sed 's/G//g' )echo "$used/$total"|bc -l > /home/data/wuxi147_disk.txtscp /home/data/wuxi147_disk.txt root@58.241.41.150:/usr/local/apache2/htdocs/
#!/bin/bashtotal=$(free -m|grep Mem|awk '{print $2}')used=$(free -m|grep Mem|awk '{print $7}')echo "$used/$total"|bc -l > /home/wuxi147_cache.txtscp /home/wuxi147_cache.txt root@58.241.41.150:/usr/local/apache2/htdocs/