首页 > 学院 > 操作系统 > 正文

openfalcon 监控fastdfs是否可下载

2024-06-28 16:01:23
字体:
来源:转载
供稿:网友

最近发现AWS某区的服务器重启了,而且重启后,程序起不来也就算了,发现防火墙也打开了,果断处理

iptables -t filter -Fchkconfig iptables off

之后,需要添加针对fastdfs的监控,当然,还是采用openfalcon即可。

脚本如下:

#!/usr/bin/env python#coding: utf8import sysimport jsonimport requestsimport timeimport urllib2, base64# 获取数据r = requests.get('http://xxx/group1/M00/00/01/CgACJViaiuGAXjWBAAAABmkPdf0105.txt')if r.text == "ceshi/n": value = "1"else: value = "0"# 准备上报数据p = []endpoint = "10.0.2.90"metric = "yw"key = "fastdfsceshi"timestamp = int(time.time())step = 60vtype = "GAUGE"tags = ''i = { 'Metric' :'%s.%s'%(metric,key), 'Endpoint': endpoint, 'Timestamp': timestamp, 'Step': step, 'value': value, 'CounterType': vtype, 'TAGS': tags }p.append(i)PRint json.dumps(p, sort_keys=True,indent = 4)#sys.exit(0)# 上报method = "POST"handler = urllib2.HTTPHandler()opener = urllib2.build_opener(handler)url = "http://127.0.0.1:1988/v1/push"request = urllib2.Request(url, data=json.dumps(p))request.add_header('Content-Type','application/json')request.get_method = lambda: methodtry: connection = opener.open(request)except urllib2.HTTPError,e: connection = eif connection.code == 200: print connection.read()else: print '{"err":1,"msg":"%s"}' % connection

当然,ceshi.txt文件还是要先上传到fastdfs里面的

fdfs_upload_file ~/fastdfs/etc/fdfs/client.conf ceshi.txt定时任务* * * * * cd /data/openfalcon/open-falcon/agent/userdefine && ./yw.fastdfsceshi然后就可以添加报警了

这里写图片描述

看看图形画的咋样来

这里写图片描述


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表