#!/bin/sh # ctdb event script for checking local file system utilization [ -n "$CTDB_BASE" ] || \ export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD") . $CTDB_BASE/functions loadconfig monitor_filesystem_usage () { # Check each specified filesystem, specified in format # :, where is a # percentage. for _fs in $CTDB_CHECK_FS_USE ; do _fs_mount="${_fs%:*}" _fs_threshold="${_fs#*:}" if [ ! -d "$_fs_mount" ]; then die "Directory ${_fs_mount} does not exist" fi case "$_fs_threshold" in [0-9]|[0-9][0-9]|100) : ;; *) die "Threshold ${_fs_threshold} is invalid number" esac # Get current utilization _fs_usage=$(df -kP "$_fs_mount" | \ sed -n -e 's@.*[[:space:]]\([[:digit:]]*\)%.*@\1@p') if [ -z "$_fs_usage" ] ; then die "Unable to get FS utilization for ${_fs_mount}" fi if [ "$_fs_usage" -ge "$_fs_threshold" ] ; then die "ERROR: Utilization of ${_fs_mount} ${_fs_usage}% >= threshold ${_fs_threshold}%" fi done } case "$1" in monitor) monitor_filesystem_usage ;; *) ctdb_standard_event_handler "$@" ;; esac exit 0