hadoop_health_check.py
1.03 KB
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
import os
import sys
sys.path.append(os.path.dirname(sys.path[0]))
from utils.common_util import CommonUtil
def check_hadoop():
import os
try:
output = str(os.popen('hdfs dfsadmin -report').read())
lines = output.split("\n")
for line in lines:
line = line.strip()
if line.startswith("Live datanodes"):
print("success")
print(line)
if line.startswith("Dead datanodes"):
print(line)
content = "hadoop节点存在宕机情况,请检查!"
users = [
'wujicang',
'huangjian',
'fangxingjun',
'chenjianyun',
'wangrui4'
]
print("发送微信消息中!")
CommonUtil.send_wx_msg(users, "hadoop健康检查", content)
print("success")
pass
except:
pass
pass
if __name__ == '__main__':
check_hadoop()
pass