任何乙個分割槽使用到90%就傳送乙個郵件給指定的收件人,到95%就在郵件主題出警告(warning),說明傳送郵件程式email
#!/bin/bash
#updated:2008-03-03 pm by:leif([email protected])
email=/usr/local/bin/email
/bin/df -h >/tmp/df.txt
use=`df -h | grep -o [0-9]*% | grep -o 『[0-9]\+'`
for i in $use
do if (( $i > 95 ))
then
$eamil -s 「warning low disk space for $i」 [email protected] break
fi if (( $i > 90 ))
then
$email -s 「low disk space for $i」 [email protected] fi
done
/bin/rm -f /tmp/df.txt
用於監視遠端主機磁碟使用情況的shell指令碼,檔名:disklog.sh
#!/bin/bash
# 檔名:disklog.sh
# 用途:監視遠端系統的磁碟使用情況
logfile="diskusage.log"
if [[ -n $1 ]]
then
logfile=$1
if if [ ! -e $logfile ]
then
printf "%-8s %-14s %-9s %-8s %-6s %-6s %-6s %s\n" "date" "ip address" "device" "capacity" "used" "free" "percent" "status" > $logfile
fi ip_list="127.0.0.1 0.0.0.0"
# 提供遠端主機ip位址列表
( for ip in $ip_list
do ssh slynux@$ip 'df -h' | grep ^/dev/ > /tmp/$$.df
while read line;
do cur_date=$(date +%d)
printf "%-8s %-14s " $cur_date $ip
echo $line | awk ''
pusg=$(echo $line | egrep -o "[0-9]+%")
pusg=$;
if [ $pusg -lt 80 ];
then
echo saft
else
echo alert
fi done< /tmp/$$.df
done
)>>$logfile
我們可以用cron以固定的間隔來排程指令碼執行,例如在crontab中加入如此條目,以實現每天上午10點自動執行指令碼:
00 10 * * * /home/sh/disklog.sh /home/log/diskusg.log
執行crontab -e命令,新增上面一行內容並儲存。
也可以手動執行:
$ ./disklog.sh
監視磁碟使用情況Shell
monitordisk.sh如下 bin bash updated 2008 03 03 pm by leif liangliwen 163.com email usr local bin email bin df h tmp df.txt use df h grep o 0 9 grep o 0 ...
Elasticsearch 磁碟使用情況
es可以根據磁碟使用情況來決定是否繼續分配shard。預設設定是開啟的,也可以通過api關閉 cluster.routing.allocation.disk.threshold enabled false 在開啟的情況下,有兩個重要的設定 cluster.routing.allocation.dis...
監控linux磁碟使用情況
一.配置mail 1.安裝mail yum y install mailx 2.調整配置檔案 vi etc mail.rc 在最後兩行增加如下語句 set from abc qq.com smtp smtp.exmail.qq.com set smtp auth user abc qq.com sm...