-
Notifications
You must be signed in to change notification settings - Fork 1
/
01_disk_usage.sh
executable file
·34 lines (28 loc) · 1.39 KB
/
01_disk_usage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# ----------------------------------------------------------- #
# Copyright (C) 2008 Red Hat, Inc. #
# Written by Michel Samia <[email protected]> #
# Adapted for SCE by Martin Preisler <[email protected]> #
# disc_usage.sh #
# ----------------------------------------------------------- #
# report warnning when percent usage greater than
[ "$PERCENT_LIMIT_WARNING" == "" ] && PERCENT_LIMIT_WARNING=80
# report error when percent usage greater than
[ "$PERCENT_LIMIT_ERROR" == "" ] && PERCENT_LIMIT_ERROR=100
RET=$XCCDF_RESULT_PASS
while read device blocks used available_capacity percent_used directory ; do
percent_sign='%'
percent_used_num_only=${percent_used%$percent_sign}
if [ "$percent_used_num_only" -ge "$PERCENT_LIMIT_ERROR" ] ; then
echo "Device $device mounted to $directory is full! There is $percent_used used!"
echo "Please backup and delete unused files from this directory"
RET=$XCCDF_RESULT_FAIL
elif [ "$percent_used_num_only" -ge "$PERCENT_LIMIT_WARNING" ] ; then
echo "Device $device mounted to $directory is going to be full! There is $percent_used used!"
echo "Please backup and delete unused files from this directory"
[ "$RET" == $XCCDF_RESULT_FAIL ] || RET=$XCCDF_RESULT_INFORMATIONAL
fi
done <<EOF
`df -P | tail -n +2 | sort -n -k 5 -r`
EOF
exit $RET