-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdisk-usage.sh
More file actions
24 lines (22 loc) · 767 Bytes
/
disk-usage.sh
File metadata and controls
24 lines (22 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
DISK_LOG=/tmp/disk_use.tmp
DISK_TOTAL=`fdisk -l |awk '/^Disk.*bytes/&&/\/dev/{printf $2" ";printf "%d",$3;print "GB"}'`
USE_RATE=`df -h |awk '/^\/dev/{print int($5)}'`
for i in $USE_RATE; do
if [ $i -gt 90 ];then
PART=`df -h |awk '{if(int($5)=='''$i''') print $6}'`
echo "$PART = ${i}%" >> $DISK_LOG
fi
done
echo "---------------------------------------"
echo -e "Disk total:\n${DISK_TOTAL}"
if [ -f $DISK_LOG ]; then
echo "---------------------------------------"
cat $DISK_LOG
echo "---------------------------------------"
rm -f $DISK_LOG
else
echo "---------------------------------------"
echo "Disk use rate less than 90% of the partition."
echo "---------------------------------------"
fi