2 # ctdb event script for checking local file system utilization
4 [ -n "$CTDB_BASE" ] || \
5 export CTDB_BASE
=$
(cd -P $
(dirname "$0") ; dirname "$PWD")
12 # check each specified fs to be checked
13 # config format is <fs_mount>:<fs_threshold>
14 for fs
in $CTDB_CHECK_FS_USE
16 # parse fs_mount and fs_threshold
18 fs_threshold
="${fs#*:}"
20 # check if given fs_mount is existing directory
21 if [ ! -d "$fs_mount" ]; then
22 echo "Directory $fs_mount does not exist"
26 # check if given fs_threshold is number
27 if ! (echo "$fs_threshold" |
egrep -q '^[0-9]+$') ; then
28 echo "Threshold $fs_threshold is invalid number"
32 # get utilization of given fs from df
33 fs_usage
=$
(df
-kP $fs_mount |
sed -n -e 's@.*[[:space:]]\([[:digit:]]*\)%.*@\1@p')
35 # check if fs_usage is number
36 if [ -z "$fs_usage" ] ; then
37 echo "Unable to get FS utilization for $fs_mount"
41 # check if fs_usage is higher than or equal to fs_threshold
42 if [ "$fs_usage" -ge "$fs_threshold" ] ; then
43 echo "ERROR: Utilization of $fs_mount ($fs_usage%) is higher than threshold ($fs_threshold%)"
51 ctdb_standard_event_handler
"$@"