cat cpuinfo.sh #!/bin/bash cpu() { local user system idle cwait user=$(vmstat |awk 'NR==3{print $13}') system=$(vmstat |awk 'NR==3{print $14}') idle=$(vmstat |awk 'NR==3{print $15}') cwait=$(vmstat |awk 'NR==3{print $16}') echo "CPU用戶占用: $user%" echo "CPU系統(tǒng)占用: $system%" echo "CPU空閑: $idle%" echo "CPU等待磁盤I/O響應(yīng)占用: $cwait%" } cpu while true;do bash cpuinfo.sh; sleep 1;done
#!/bin/bash memory() { local total used free used=$(free -m |awk 'NR==3{print $3}') free=$(free -m |awk 'NR==3{print $4}') total=$(($used+$free)) echo "內(nèi)存總共: ${total}M" echo "內(nèi)存使用: ${used}M" echo "內(nèi)存剩余: ${free}M" } Memory
disk() { local mount total used_parent free part=$(df -h |awk 'BEGIN{OFS="="}/^/dev/{print $6,$2,$3,$4,int($5)}') for p in $part;do mount=$(echo $p |cut -d"=" -f1) total=$(echo $p |cut -d"=" -f2) used=$(echo $p |cut -d"=" -f3) free=$(echo $p |cut -d"=" -f4) used_parent=$(echo $p |cut -d"=" -f5) if [ $used_parent -ge 13 ];then echo "掛載點(diǎn): $mount" echo "總大小: $total" echo "使用: $used" echo "剩余:$free" fi done } Disk
traffic() { echo -e " In ------Out" local old_in old_out new_in new_out old_in=$(ifconfig eth0 |awk '/RX/&&/dropped/{print $2}' |awk -F: '{print $2}') old_out=$(ifconfig eth0 |awk '/TX/&&/dropped/{print $2}' |awk -F: '{print $2}') sleep 1 new_in=$(ifconfig eth0 |awk '/RX/&&/dropped/{print $2}' |awk -F: '{print $2}') new_out=$(ifconfig eth0 |awk '/TX/&&/dropped/{print $2}' |awk -F: '{print $2}') in=$(($new_in-$old_in)) out=$(($new_out-$old_out)) echo "$in kB/s,$out kB/s" } traffic
cat sys_all.sh #!/bin/bash cpu() { local user system idle cwait user=$(vmstat |awk 'NR==3{print $13}') system=$(vmstat |awk 'NR==3{print $14}') idle=$(vmstat |awk 'NR==3{print $15}') cwait=$(vmstat |awk 'NR==3{print $16}') echo "CPU用戶占用: $user%" echo "CPU系統(tǒng)占用: $system%" echo "CPU空閑: $idle%" echo "CPU等待磁盤I/O響應(yīng)占用: $cwait%" } memory() { local total used free used=$(free -m |awk 'NR==3{print $3}') free=$(free -m |awk 'NR==3{print $4}') total=$(($used+$free)) echo "內(nèi)存總共: ${total}M" echo "內(nèi)存使用: ${used}M" echo "內(nèi)存剩余: ${free}M" } disk() { local mount total used_parent free part=$(df -h |awk 'BEGIN{OFS="="}/^/dev/{print $6,$2,$3,$4,int($5)}') for p in $part;do mount=$(echo $p |cut -d"=" -f1) total=$(echo $p |cut -d"=" -f2) used=$(echo $p |cut -d"=" -f3) free=$(echo $p |cut -d"=" -f4) used_parent=$(echo $p |cut -d"=" -f5) if [ $used_parent -ge 13 ];then echo "掛載點(diǎn): $mount" echo "總大小: $total" echo "使用: $used" echo "剩余:$free" fi done } traffic() { echo -e " In ------Out" local old_in old_out new_in new_out old_in=$(ifconfig eth0 |awk '/RX/&&/dropped/{print $2}' |awk -F: '{print $2}') old_out=$(ifconfig eth0 |awk '/TX/&&/dropped/{print $2}' |awk -F: '{print $2}') sleep 1 new_in=$(ifconfig eth0 |awk '/RX/&&/dropped/{print $2}' |awk -F: '{print $2}') new_out=$(ifconfig eth0 |awk '/TX/&&/dropped/{print $2}' |awk -F: '{print $2}') in=$(($new_in-$old_in)) out=$(($new_out-$old_out)) echo "$in kB/s,$out kB/s" } cpu memory disk traffic
您的電子郵件地址不會(huì)被公開,必填項(xiàng)已用 * 標(biāo)注。
提交評(píng)論
Δ
? ? ? ? ? ? ? ?Copyright 2020-2026 同袍存儲(chǔ) 粵ICP備2021121885號(hào)網(wǎng)站地圖