diff options
| author | Martin Schwenke <martin@meltin.net> | 2011-10-14 15:52:12 +1100 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2011-11-16 16:26:45 +1100 |
| commit | 9187db869e6b7b2eb5bdfaaa9f6bd9221cdc449b (patch) | |
| tree | 1eb14789d61e533df8ade70b894fd5525cf4b654 | |
| parent | 44de394796b8b4f1b046ccf226372cd8ba9ad768 (diff) | |
| download | samba-9187db869e6b7b2eb5bdfaaa9f6bd9221cdc449b.tar.gz samba-9187db869e6b7b2eb5bdfaaa9f6bd9221cdc449b.tar.xz samba-9187db869e6b7b2eb5bdfaaa9f6bd9221cdc449b.zip | |
Eventscripts: Make 40.fs_use use less processes and arguably clearer.
* $fs can be parsed using shell prefix and suffix removal.
* df output can be parsed with a single call to sed.
Failure is indicated by empty output from sed, so we check for that
as the error condition, changing the associated message
appropriately.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit c5ef0d1440f1d952784cc67946c414d149722d01)
| -rw-r--r-- | ctdb/config/events.d/40.fs_use | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ctdb/config/events.d/40.fs_use b/ctdb/config/events.d/40.fs_use index abbc17eb14..f678b511ae 100644 --- a/ctdb/config/events.d/40.fs_use +++ b/ctdb/config/events.d/40.fs_use @@ -11,8 +11,8 @@ case "$1" in for fs in $CTDB_CHECK_FS_USE do # parse fs_mount and fs_threshold - fs_mount=`echo "$fs" | awk -F : '{print $1}'` - fs_threshold=`echo "$fs" | awk -F : '{print $2}'` + fs_mount="${fs%:*}" + fs_threshold="${fs#*:}" # check if given fs_mount is existing directory if [ ! -d "$fs_mount" ]; then @@ -27,11 +27,11 @@ case "$1" in fi # get utilization of given fs from df - fs_usage=`df -kP $fs_mount | grep '%' | awk {'print $5'} | sed 's/%//g' | tail -n 1` + fs_usage=$(df -kP $fs_mount | sed -n -e 's@.*[[:space:]]\([[:digit:]]*\)%.*@\1@p') # check if fs_usage is number - if ! (echo "$fs_usage" | egrep -q '^[0-9]+$') ; then - echo "$0: FS utilization $fs_usage is invalid number" + if [ -z "$fs_usage" ] ; then + echo "$0: Unable to get FS utilization for $fs_mount" exit 1 fi |
