forked from techarkit/shell-scripting-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdiskspace.sh
More file actions
28 lines (23 loc) · 632 Bytes
/
diskspace.sh
File metadata and controls
28 lines (23 loc) · 632 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
#!/bin/bash
#Purpose: Monitoring Disk Space Utilization and Send Email Alert
#Version:1.0
#Created Date: Wed Jun 6 22:38:01 IST 2018
#Modified Date:
#WebSite: https://arkit.co.in
#Author: Ankam Ravi Kumar
# START #
THRESHOULD=40
mailto="root"
HOSTNAME=$(hostname)
for path in `/bin/df -h | grep -vE 'Filesystem|tmpfs' | awk '{print $5}' |sed 's/%//g'`
do
if [ $path -ge $THRESHOULD ]; then
df -h | grep $path% >> /tmp/temp
fi
done
VALUE=`cat /tmp/temp | wc -l`
if [ $VALUE -ge 1 ]; then
mail -s "$HOSTNAME Disk Usage is Critical" $mailto < /tmp/temp
fi
#rm -rf /tmp/temp
# END #