该脚本结合ssh免密钥使用,效果挺好
#!/bin/bash
#memory_used_rateLoadMemory=$(cat /proc/meminfo | awk '{print $2}')
Total=$(echo $LoadMemory | awk '{print $1}')
Free1=$(echo $LoadMemory | awk '{print $2}')
Free2=$(echo $LoadMemory | awk '{print $3}')
Free3=$(echo $LoadMemory | awk '{print $4}')
Used=`expr $Total - $Free1 - $Free2 - $Free3`
Used_Rate=`expr $Used/$Total*100 | bc -l`
Memory_Used_Rate=`expr $Used_Rate/1 | bc`
#####IP
IP1=`/sbin/ifconfig eth0 2>/dev/null|grep Bcast|sed 's/inet.*r://'|sed 's/Bcast.*$//'`
IP2=`/sbin/ifconfig eth1 2>/dev/null|grep Bcast|sed 's/inet.*r://'|sed 's/Bcast.*$//'`
IP3=`/sbin/ifconfig eth2 2>/dev/null|grep Bcast|sed 's/inet.*r://'|sed 's/Bcast.*$//'`
if [ ! -n "$IP1" ]; then
IP=${IP2}
else
IP=${IP1}
fi
#####df
Df1=`df -h 2>/dev/null|grep -v "/dev/sr"|awk -F'[% ]+' 'NR>1{print $5}'|sort -r|head -1`
#Df2=`df -h 2>/dev/null|grep -v "/dev/sr"|sed 's/.*\(.\{2\}\)%.*/\1/g'|grep '[0-9]$'|sort | tail -1`
#echo "$IP|$Memory_Used_Rate%|$Df1%"
printf "%-15s %-3s %s\n" $IP $Memory_Used_Rate% $Df1