参考まで
cronで適当な間隔で実行するとHDDの容量オーバーをメールで通知してくれます。
本文に日本語を使いたい場合はnkf等で変換した方がいいようです。
cronで適当な間隔で実行するとHDDの容量オーバーをメールで通知してくれます。
本文に日本語を使いたい場合はnkf等で変換した方がいいようです。
#!/bin/bash
#
# status_df.sh
#
#
partition="/" # Mount point
limit=70 # Usage rate(%)
from="*****@foo.co.jp"
to="*****@foo.co.jp"
host="www.foo.co.jp"
#
#
#
## Begin monitoring program.
IFS=$'\n'
r=($(df -k|tail -n +2|awk '{print $5" "$6}'|sed s/%//))for tmp in ${r[@]}; do
IFS=$' '
a=($tmp)
if [ ${a[1]} = $partition ]; then
if [ ${a[0]} -ge $limit ]; then
echo "Subject: Warning of system resource [$host]
From: $from
To: $toDatetime : `date`
Server : $host
Target : $partition
Threshold : $limit`df -k`
" | /usr/lib/sendmail -t -f $from
else
echo "ok"
fi
fi
IFS=$'\n'
done
コメント