We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0581e1a commit b468795Copy full SHA for b468795
1 file changed
disk-usage.sh
@@ -0,0 +1,31 @@
1
+#!/bin/sh
2
+
3
+# disk-usage.sh - report when disk space starts getting low
4
5
+# Credit to:
6
+# http://www.cyberciti.biz/faq/mac-osx-unix-get-an-alert-when-my-disk-is-full/
7
8
+check() {
9
+ FS="$1"
10
+ OUTPUT=($(LC_ALL=C df -P ${FS}))
11
+ CURRENT=$(echo ${OUTPUT[11]} | sed 's/%//')
12
+ [ $CURRENT -gt $threshold ] && \
13
+ echo "$FS: file system usage at $CURRENT%" && \
14
+ return 1
15
+ return 0
16
+}
17
18
+threshold=80
19
+while test $# -gt 0
20
+do
21
+ case "$1" in
22
+ --threshold|-t)
23
+ shift
24
+ threshold=$1
25
+ ;;
26
+ *)
27
+ check "$1"
28
29
+ esac
30
31
+done
0 commit comments