-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisk_check.sh
76 lines (55 loc) · 1.87 KB
/
disk_check.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
###############################################
# Author: [email protected]
# Date: 2020 6/9
# Usage: ./disk_check.sh
# describition: based on centos7
###############################################
NOW=`date +"%Y-%m-%d"`
#hostname主机名#
echo "#####################hostname#########################" >> /tmp/disk-check-$NOW
echo "$(hostname)" >> /tmp/disk-check-$NOW
echo $NOW
SERVER_IP=`ifconfig|grep 'inet 10.'|awk '{print $2}'|cut -d" " -f1`
# 需要检查的磁盘,root及特定数据卷,如下例的 datavg-lv_data
ROOT_DISK=`/bin/df -h|grep /dev/mapper/centos-root|awk -F" " '{print $5}'|cut -d"%" -f1`
DATA_DISK=`/bin/df -h|grep /dev/sda1|awk -F" " '{print $5}'|cut -d"%" -f1`
echo "---disk-checking---"
echo "---Please waiting---"
# 磁盘空间排查
check_disk(){
# 检查根目录,根据实际环境修改
if
[ $ROOT_DISK -lt 50 ];then
echo "The ROOT_DISK of $SERVER_IP-$HOSTNAME,now ROOT_DISK use is $ROOT_DISK%,space very safe now _^_^_ "
fi
if
[ $ROOT_DISK -gt 60 ];then
echo "The ROOT_DISK of $SERVER_IP-$HOSTNAME,now ROOT_DISK use is $ROOT_DISK%,please check it "
fi
if
[ $ROOT_DISK -eq 90 ];then
echo "The ROOT_DISK of $SERVER_IP-$HOSTNAME,its dangerous now usage is $ROOT_DISK%,,please deal with it ASAP!"
else
echo "The ROOT_DISK of $SERVER_IP-$HOSTNAME is Enough to use"
fi
sleep 3
if
[ $DATA_DISK -lt 50 ];then
echo "The ROOT_DISK of $SERVER_IP-$HOSTNAME,now ROOT_DISK use is $ROOT_DISK%,space very safe now _^_^_. "
fi
if
[ $DATA_DISK -gt 60 ];then
echo "The DATA_DISK of $SERVER_IP-$HOSTNAME,now DATA_DISK use is $DATA_DISK%,please check it! "
fi
if
[ $DATA_DISK -eq 90 ];then
echo "The DATA_DISK of $SERVER_IP-$HOSTNAME,its dangerous now usage is $DATA_DISK%,,please deal with it ASAP!"
else
echo "The DATA_DISK of -$HOSTNAME is Enough to use"
fi
}
main(){
check_disk
}
main