首页 > 编程语言 > 详细

python 监控elasticsearch集群状态并推送到openfalcon

时间:2018-05-31 17:20:05      阅读:292      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/python #! --*-- coding:utf-8 --*-- import requests import time import json import sys import commands ts = int(time.time()) #print ts cmd = 'curl 172.31.0.92:9200/_cat/health' (a, b) = commands.getstatusoutput(cmd) #print b status= b.split(' ')[157] if status=='green':     healthy=3 elif status=='yellow':     healthy=2 elif status=='red':     healthy=1 else:      healthy=0 #print healthy payload = [     {         "endpoint": "TBK01",         "metric": "elasticsearch_status",         "timestamp": ts,         "step": 60,         "value": 1,         "counterType": "GAUGE",         "tags": "status=green",     } ] r = requests.post("http://127.0.0.1:1988/v1/push", data=json.dumps(payload)) #print r.text


python 监控elasticsearch集群状态并推送到openfalcon

原文:http://blog.51cto.com/haoyonghui/2122523

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!