open-falcon 使用 python 监控发布中未分发的命令数
来源:互联网 发布:大数据诚信 编辑:程序博客网 时间:2024/05/20 04:12
性能计数器监控参考 :SqlServer 监控发布中未分发的命令数
但 open-falcon 不能监控 windows 性能计数器,因此只能自定义监控推送监控信息。open-falcon 使用 python 可以推送数据,因此需安装python(脚本使用python2.7)。
自定义push数据到open-falcon 参考:自定义push数据到open-falcon
#coding=gbk#python2.7.13import requestsimport timeimport jsonimport pymssql# 推送默认参数# https://book.open-falcon.org/zh/usage/data-push.htmlendpoint = "KK-PC"metric = "repl."timestamp = int(time.time())step = 300value = 0counterType = "GAUGE"tags = "db="# 存储过程参数声明(保存到json中),用于执行sp_replmonitorsubscriptionpendingcmds"""EXEC distribution.sys.sp_replmonitorsubscriptionpendingcmds @publisher = N'publisher',@publisher_db = N'publisher_db',@publication = N'publication_name',@subscriber = N'subscriber',@subscriber_db = N'subscriber_db',@subscription_type =0"""publicationlist = [ { "publisher": "KK-PC", "publisherdb": "DB01", "publication": "repl_test_DB01", "subscriber": "AA-PC", "subscriberdb": "DB01", }, { "publisher": "KK-PC", "publisherdb": "DB02", "publication": "repl_test_DB02", "subscriber": "AA-PC", "subscriberdb": "DB02", }, { "publisher": "KK-PC", "publisherdb": "DB03", "publication": "repl_test_DB03", "subscriber": "AA-PC", "subscriberdb": "DB03", }, { "publisher": "KK-PC", "publisherdb": "DB04", "publication": "repl_test_DB04", "subscriber": "AA-PC", "subscriberdb": "DB04", },]def main(): #连接数据库执行存储过程 #dbdate 保存存储过程结果;pbdate 保存名称 dbdate = [] pbdate = [] conn=pymssql.connect(host='.',database='distribution') cur=conn.cursor() for i in publicationlist: sql = """ EXEC distribution.sys.sp_replmonitorsubscriptionpendingcmds @publisher = N'"""+i["publisher"]+"""' ,@publisher_db = N'"""+i["publisherdb"]+"""' ,@publication = N'"""+i["publication"]+"""' ,@subscriber = N'"""+i["subscriber"]+"""' ,@subscriber_db = N'"""+i["subscriberdb"]+"""' ,@subscription_type =0""" cur.execute(sql) dbdate.append(cur.fetchall()) pbdate.append(i["publisher"]+"."+i["publisherdb"]) cur.close() conn.close() #配置推送的json格式,都添加到 payload 中 payload = [] data = {"endpoint":endpoint,"metric":metric,"timestamp":timestamp,"step":step,"value":value,"counterType":counterType,"tags":tags} for item,repl in zip(dbdate,pbdate): data = data.copy() data["endpoint"] = endpoint data["metric"] = metric + "pendingcmdcount" data["timestamp"] = timestamp data["step"] = step data["value"] = item[0][0] data["counterType"] = counterType data["tags"] = tags + repl payload.append(data) data = data.copy() data["endpoint"] = endpoint data["metric"] = metric + "estimatedprocesstime" data["timestamp"] = timestamp data["step"] = step data["value"] = item[0][1] data["counterType"] = counterType data["tags"] = tags + repl payload.append(data) r = requests.post("http://127.0.0.1:1988/v1/push", data=json.dumps(payload)) print r.textif __name__ == "__main__": main()
创建定时任务,每个5分钟执行一次。
1 0
- open-falcon 使用 python 监控发布中未分发的命令数
- SqlServer 监控发布中未分发的命令数
- 小米发布的运维监控工具:open falcon
- open-falcon开源监控使用
- open-falcon监控
- open-falcon监控项
- open-falcon监控系统简介
- 开源运维监控工具open falcon
- open-falcon-小米监控工具
- open-falcon agent plugin的使用
- Open-falcon 人性化的互联网企业级监控系统
- open-falcon最好用的互联网企业级监控产品
- Satori 是 Open-Falcon监控系统的一个分支
- open-falcon实现对k8s集群的监控
- open-falcon transfer 模块监控数据处理
- 简析运维监控系统及Open-Falcon
- Open-Falcon 互联网企业级监控系统
- open-falcon小米监控安装部署
- Android单排上王者系列之Dagger2使用解析
- HTTP协议详解
- startActivityForResult 的简单使用
- git远程仓库,远程分支,本地分支的操作和概念
- ArrayList、LinkedList、Vector的区别
- open-falcon 使用 python 监控发布中未分发的命令数
- android studio 解决无法显示preview
- Impala Shell 和 Impala SQL
- android 色值设定:ARGB透明度的设置
- 向页面注入JS代码
- webservice讲解
- JSON.NET VS BinaryFormatter 性能
- Parcealbe传递数据
- JEM software ticket42: CTU bits/distortion calculation mistake for I slice when QTBT is enabled