summaryrefslogtreecommitdiff
path: root/ctdb/config
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2015-08-03 16:20:40 +1000
committerAmitay Isaacs <amitay@samba.org>2015-08-29 17:06:25 +0200
commit02fa6c3d106e8fbf0e685afafa5e6a9bc0c3d22d (patch)
tree09841fb3bbbdafa41ee11099bfcf6aec51e8e9a1 /ctdb/config
parentb7b6e25b3e26210ed196be7fc5848e3320b5c35b (diff)
downloadsamba-02fa6c3d106e8fbf0e685afafa5e6a9bc0c3d22d.tar.gz
ctdb-scripts: Factor out new function check_thresholds()
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/config')
-rw-r--r--ctdb/config/events.d/05.system53
1 files changed, 32 insertions, 21 deletions
diff --git a/ctdb/config/events.d/05.system b/ctdb/config/events.d/05.system
index da96254384e..770c0dc6055 100644
--- a/ctdb/config/events.d/05.system
+++ b/ctdb/config/events.d/05.system
@@ -17,6 +17,35 @@ validate_percentage ()
esac
}
+check_thresholds ()
+{
+ _thing="$1"
+ _thresholds="$2"
+ _usage="$3"
+
+ case "$_thresholds" in
+ *:*)
+ _warn_threshold="${_thresholds%:*}"
+ _unhealthy_threshold="${_thresholds#*:}"
+ ;;
+ *)
+ _warn_threshold="$_thresholds"
+ _unhealthy_threshold=""
+ esac
+
+ if validate_percentage "$_unhealthy_threshold" "$_thing" ; then
+ if [ "$_usage" -ge "$_unhealthy_threshold" ] ; then
+ die "ERROR: ${_thing} utilization ${_usage}% >= threshold ${_unhealthy_threshold}%"
+ fi
+ fi
+
+ if validate_percentage "$_warn_threshold" "$_what" ; then
+ if [ "$_usage" -ge "$_warn_threshold" ] ; then
+ echo "WARNING: ${_thing} utilization ${_usage}% >= threshold ${_warn_threshold}%"
+ fi
+ fi
+}
+
monitor_filesystem_usage ()
{
# Check each specified filesystem, specified in format
@@ -38,27 +67,9 @@ monitor_filesystem_usage ()
continue
fi
- case "$_fs_thresholds" in
- *:*)
- _fs_warn_threshold="${_fs_thresholds%:*}"
- _fs_unhealthy_threshold="${_fs_thresholds#*:}"
- ;;
- *)
- _fs_warn_threshold="$_fs_thresholds"
- _fs_unhealthy_threshold=""
- esac
-
- if validate_percentage "$_fs_unhealthy_threshold" "$_fs" ; then
- if [ "$_fs_usage" -ge "$_fs_unhealthy_threshold" ] ; then
- die "ERROR: Filesystem ${_fs_mount} utilization ${_fs_usage}% >= threshold ${_fs_unhealthy_threshold}%"
- fi
- fi
-
- if validate_percentage "$_fs_warn_threshold" "$_fs" ; then
- if [ "$_fs_usage" -ge "$_fs_warn_threshold" ] ; then
- echo "WARNING: Filesystem ${_fs_mount} utilization ${_fs_usage}% >= threshold ${_fs_warn_threshold}%"
- fi
- fi
+ check_thresholds "Filesystem ${_fs_mount}" \
+ "$_fs_thresholds" \
+ "$_fs_usage"
done
}