直接先上图,本人小白一枚,有不足的,一定要指出,太感谢。
当你的分区每个区都小于80%使用率时是这样的:
反之,图是这样的:
代码如下:倒计时的那个是另外的脚本,不在下面的脚本之中
1 setterm -foreground red
1 setterm -foreground red
2 IP=$( ifconfig |grep -B2 '\<inet\>' |grep -v '\-\-'|sed 's/inet//' |awk '{print $1}' |tr '\n' ' ')
3 echo " Welcome!Now is "$(date)
4 cat /proc/cpuinfo |grep "model name"|uniq|cut -d: -f 2-
5 echo " my name is ljd'F17,your ip is:"
6 echo " $IP"
7 echo ""
8 MT=$(free -m |sed -n 2p|awk '{print $2}')
9 MU=$(free -m |sed -n 2p|awk '{print $3}')
10 MF=$(free -m |sed -n 2p|awk '{print $4}')
11 MB=$(free -m |sed -n 2p|awk '{print $6}')
12 MC=$(free -m |sed -n 2p|awk '{print $7}')
13 declare -i MUS=$MU-$MB-$MC
14 declare -i MUF=$MF+$MB+$MC
15 echo " mem(M): used " $MUS "MB free " $MUF "MB"
16 H=$(df -lh|grep '^\/dev\/sd'|wc -l)
17 for ((i=1;i<=${H};i++))
18 do
19 BF=$(df -lh |grep '^\/dev\/sd'|sed -n "${i}p")
20 BFB=$(echo ${BF} |awk '{print $5}'|tr -d '%')
21
22 if [ ${BFB} -ge 80 ]; then
23 N1=$(echo ${BF}|awk '{print $1}')
24 N2=$(echo ${BF}|awk '{for(i=6;i<=NF;i++)printf $i" ";printf "\n"}')
25 N3=$(echo ${BF}|awk '{print $4}')
26 echo " [Warning]: $N1 will full,mount on $N2,user $BFB%,free $N3"
27 fi
28 done
29 sh /root/shell/.djs.sh
30 setterm -foreground default
转载于:https://blog.51cto.com/q8886888/1169411