巡检shell

日常巡检脚本,主要检查磁盘空间,web登录页面,CPU,内存使用率,各个服务运行情况

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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
CPU=`top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}'`
FREE=`free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'`
DISK=`df -h | awk '{printf "%d/%dGB (%s) %s\n", $3,$2,$5,$6}' | grep -v '/dev' | grep -v '/run' | grep -v '/boot' | grep -v '/sys'`
URL8090=`curl -s -m 5 -IL http://127.0.0.1:8090 | grep 200`
URL15672=`curl -s -m 5 -IL http://127.0.0.1:15672 | grep 200`

if [ "$URL8090" == "" ]
then
echo -e "\033[1;31m停车登录界面无法访问...... \033[0m"
else
echo -e "\033[1;32m停车登录界面访问正常...... \033[0m"
fi

if [ "$URL15672" == "" ]
then
echo -e "\033[1;31mrabbitmq登录界面无法访问...... \033[0m"
else
echo -e "\033[1;32mrabbitmq登录界面访问正常...... \033[0m"
fi

echo -e "\033[1;34mCPU使用率: \033[0m \033[1;32m$CPU \033[0m"
echo -e "\033[1;34m内存使用率: \033[0m \033[1;32m$FREE \033[0m"
echo -e "\033[1;34m磁盘使用率: \033[0m \033[1;32m$DISK \033[0m"

#FDFS
ps -ef |grep fdfs |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mfdfs正在运行 \033[0m"
else
echo -e "\033[1;31mfdfs未运行 \033[0m"
fi

#NGINX
ps -ef |grep nginx |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mnginx正在运行 \033[0m"
else
echo -e "\033[1;31mnginx未运行 \033[0m"
fi

#POSTGRESQL
ps -ef |grep postgresql |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mpostgresql正在运行 \033[0m"
else
echo -e "\033[1;31mpostgresql未运行 \033[0m"
fi

#RABBITMQ
ps -ef |grep rabbitmq |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mrabbitmq正在运行 \033[0m"
else
echo -e "\033[1;31mrabbitmq未运行 \033[0m"
fi

#REDIS
ps -ef |grep redis |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mredis正在运行 \033[0m"
else
echo -e "\033[1;31mredis未运行 \033[0m"
fi

#TOMCAT
ps -ef |grep tomcat |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mtomcat正在运行 \033[0m"
else
echo -e "\033[1;31mtomcat未运行 \033[0m"
fi

#HAPROXY
ps -ef |grep haproxy |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mhaproxy正在运行 \033[0m"
else
echo -e "\033[1;31mhaproxy未运行 \033[0m"
fi

#FILTER
ps -ef |grep filter |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mfilter正在运行 \033[0m"
else
echo -e "\033[1;31mfilter未运行 \033[0m"
fi

#CLEANER
ps -ef |grep cleaner |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mcleaner正在运行 \033[0m"
else
echo -e "\033[1;31mcleaner未运行 \033[0m"
fi

#ADAPTER
ps -ef |grep adapter |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33madapter正在运行 \033[0m"
else
echo -e "\033[1;31madapter未运行 \033[0m"
fi

#DEVICESIM
ps -ef |grep device |grep -v grep >>/dev/null
if [ $? = 0 ]
then
echo -e "\033[1;33mdeviceSim正在运行 \033[0m"
else
echo -e "\033[1;31mdeviceSim未运行 \033[0m"
fi
博主QQ:1012405802
技术交流QQ群:830339411
版权声明:网站内容有原创和转载,如有侵权,请联系删除,谢谢!!
感谢打赏,93bok因你们而精彩!!(支付宝支持花呗)
0%