码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-05-31 17:27:23      阅读:790      评论:0      收藏:0      [点我收藏+]

标签:python 监控elasticsear

#!/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

标签:python 监控elasticsear

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!