Created
March 16, 2014 08:29
-
-
Save komasaru/9580138 to your computer and use it in GitHub Desktop.
Bash script to check the capacity of disk partitions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 閾値(%) | |
LIMIT=90 | |
# メール件名 | |
SUBJECT="[WARN] The capacity of the disk has decreased! - `hostname`" | |
# df コマンドの結果を1行ずつチェック | |
while read LINE | |
do | |
# パーセンテージ取得 | |
PER=`echo $LINE | sed 's/^.* \([0-9]*\)%.*$/\1/'` | |
# 閾値を超えたら df コマンドの内容をメール送信 | |
if [ $PER -gt $LIMIT ]; then | |
df -h | mail -s "$SUBJECT" root | |
break | |
fi | |
done < <(df | grep '[0-9]\{1,\}%') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment