forked from heydevopsorg/Shell_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisk_Utilization.sh
More file actions
30 lines (26 loc) · 770 Bytes
/
Disk_Utilization.sh
File metadata and controls
30 lines (26 loc) · 770 Bytes
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
#!/bin/bash
# default value to use if none specified
PERCENT=30
# test for command line arguement is present
if [[ $# -le 0 ]]
then
printf "There are no disks running with more usage than= %d\n" $PERCENT
# test if argument is an integer
# if it is, use that as percent, if not use default
else
if [[ $1 =~ ^-?[0-9]+([0-9]+)?$ ]]
then
PERCENT=$1
fi
fi
let "PERCENT += 0"
printf "Threshold = %d\n" $PERCENT
df -Ph | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5,$1 }' | while read data;
do
used=$(echo $data | awk '{print $1}' | sed s/%//g)
p=$(echo $data | awk '{print $2}')
if [ $used -ge $PERCENT ]
then
"$p\" has used $usedecho "WARNING: The partition \% of total available space - Date: $(date)"
fi
done