We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4be2163 commit 79d545fCopy full SHA for 79d545f
1 file changed
Disk_Utilization.sh
@@ -0,0 +1,30 @@
1
+#!/bin/bash
2
+
3
+# default value to use if none specified
4
+PERCENT=30
5
6
+# test for command line arguement is present
7
+if [[ $# -le 0 ]]
8
+then
9
+ printf "Using default value for threshold!\n"
10
+# test if argument is an integer
11
+# if it is, use that as percent, if not use default
12
+else
13
+ if [[ $1 =~ ^-?[0-9]+([0-9]+)?$ ]]
14
+ then
15
+ PERCENT=$1
16
+ fi
17
+fi
18
19
+let "PERCENT += 0"
20
+printf "Threshold = %d\n" $PERCENT
21
22
+df -Ph | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5,$1 }' | while read data;
23
+do
24
+ used=$(echo $data | awk '{print $1}' | sed s/%//g)
25
+ p=$(echo $data | awk '{print $2}')
26
+ if [ $used -ge $PERCENT ]
27
28
+ echo "WARNING: The partition \"$p\" has used $used% of total available space - Date: $(date)"
29
30
+done
0 commit comments