2
# ctdb event script for checking local file system utilization
9
# check each specified fs to be checked
10
# config format is <fs_mount>:<fs_threshold>
11
for fs in $CTDB_CHECK_FS_USE
13
# parse fs_mount and fs_threshold
14
fs_mount=`echo "$fs" | awk -F : '{print $1}'`
15
fs_threshold=`echo "$fs" | awk -F : '{print $2}'`
17
# check if given fs_mount is existing directory
18
if [ ! -d "$fs_mount" ]; then
19
echo "$0: Directory $fs_mount does not exist"
23
# check if given fs_threshold is number
24
if ! (echo "$fs_threshold" | egrep -q '^[0-9]+$') ; then
25
echo "$0: Threshold $fs_threshold is invalid number"
29
# get utilization of given fs from df
30
fs_usage=`df -kP $fs_mount | grep '%' | awk {'print $5'} | sed 's/%//g' | tail -n 1`
32
# check if fs_usage is number
33
if ! (echo "$fs_usage" | egrep -q '^[0-9]+$') ; then
34
echo "$0: FS utilization $fs_usage is invalid number"
38
# check if fs_usage is higher than or equal to fs_threshold
39
if [ "$fs_usage" -ge "$fs_threshold" ] ; then
40
echo "ERROR: Utilization of $fs_mount ($fs_usage%) is higher than threshold ($fs_threshold%)"
48
ctdb_standard_event_handler "$@"