~ubuntu-branches/ubuntu/vivid/ctdb/vivid-proposed

« back to all changes in this revision

Viewing changes to config/events.d/40.fs_use

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2011-11-06 15:18:59 UTC
  • mfrom: (1.2.14)
  • Revision ID: package-import@ubuntu.com-20111106151859-41lblk8ml4es7ra3
Tags: 1.11+git20111102-1
* New upstream release
  - removed 92-apache-service-enable.diff: integrated 
  - removed 99-fix-broken-readdir-test.diff: integrated
* d/rules, d/control, d/compat:
  - converted to dh (% target and dh_auto_*)
  - moved to compat level 9 (buildeps upgraded)
  - dh9 enabled hardening build flags
  - added hardening=+bindnow
  - dh9 enabled multiarch
    + Don't use /use/lib64 on ppc64 (Closes: #644907)
    + libctdb-dev is Multi-Arch: same
    + removed 10_no-lib64.diff: not needed with multiarch
* ctdb.init:
  - removed gettext support
  - synced with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# ctdb event script for checking local file system utilization
 
3
 
 
4
. $CTDB_BASE/functions
 
5
loadconfig
 
6
 
 
7
case "$1" in 
 
8
    monitor)
 
9
        # check each specified fs to be checked
 
10
        # config format is <fs_mount>:<fs_threshold>
 
11
        for fs in $CTDB_CHECK_FS_USE
 
12
        do
 
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}'`
 
16
 
 
17
            # check if given fs_mount is existing directory
 
18
            if [ ! -d "$fs_mount" ]; then
 
19
                echo "$0: Directory $fs_mount does not exist"
 
20
                exit 1
 
21
            fi
 
22
 
 
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"
 
26
                exit 1
 
27
            fi
 
28
 
 
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`
 
31
 
 
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"
 
35
                exit 1
 
36
            fi
 
37
 
 
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%)"
 
41
                exit 1
 
42
            fi
 
43
        done
 
44
 
 
45
        ;;
 
46
 
 
47
    *)
 
48
        ctdb_standard_event_handler "$@"
 
49
        ;;
 
50
esac
 
51
 
 
52
exit 0