KCC: docstring for kcc.graph.InternalEdge
[Samba.git] / ctdb / config / events.d / 40.fs_use
blob603b4635fa9bc480b0ebc5c981ffc85f779fd07f
1 #!/bin/sh
2 # ctdb event script for checking local file system utilization
4 [ -n "$CTDB_BASE" ] || \
5 export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
7 . $CTDB_BASE/functions
8 loadconfig
10 case "$1" in
11 monitor)
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
17 fs_mount="${fs%:*}"
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"
23 exit 1
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"
29 exit 1
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"
38 exit 1
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%)"
44 exit 1
46 done
51 ctdb_standard_event_handler "$@"
53 esac
55 exit 0