磁盘利用率脚本--我的第一篇blog
#!/bin/bash
WARNING=(80 90 100)
df |sed -rn "/^\/dev\/[a-z][a-z]/s#^([^ ]+) .* ([0-9]+)%.*#\1 \2#p"|while read DEVICE USE;do
if [[ $USE -le ${WARNING[2]} ]]&& [[ $USE -gt ${WARNING[1]} ]];then
echo -e "\033[1;31mDISK will full from `hostname -I`: $DEVICE, USE: $USE\033[0m"
elif [ $USE -gt ${WARNING[0]} ] && [ $USE -lt ${WARNING[1]} ];then
echo -e "\033[1;33mDISK will full from `hostname -I`: $DEVICE, USE: $USE\033[0m"
elif [ $USE -lt ${WARNING[0]} ];then
echo -e "\033[1;35mDISK is OK from `hostname -I`: $DEVICE, USE: $USE\033[0m"
else
echo "ok"
fi
done
posted on 2021-02-24 11:56 Santiago_hao 阅读(38) 评论(0) 编辑 收藏 举报