记录bigdesk中ElasticSearch的性能参数
- #coding=gbk
- import httplib
import json
import time
import es_savelog
import ConfigHelper
import MQHelper- def main():
- #变量初始化
#上一次统计数据
dictLastNodeInfo={}
#本次统计当前节点
dictNodeInfo={}- print "start..."
while 1==1:
flag=ConfigHelper.GetIntConfig("Flag")
if flag <> 1:
#判断是否满足退出条件
print "终止"+str(flag)
break- urlarray = ConfigHelper.GetStringConfig("EsUrl").split('|')
#取出每次执行完成后的休眠时长:秒
sleeptime=ConfigHelper.GetFloatConfig("SleepTime")- for urlindex in range(0,len(urlarray)):
url=urlarray[urlindex]
conn = httplib.HTTPConnection(url)- #取出ES版本号
conn.request("GET","")
serverinfo=conn.getresponse()
objServerJson=json.loads(serverinfo.read())
esVersion=str(objServerJson["version"]["number"])- #取出集群健康状况
conn.request("GET","/_cluster/health")
healthinfo=conn.getresponse()
objHealthJson=json.loads(healthinfo.read())
health=str(objHealthJson["status"])- #取出各ES节点统计数据
conn.request("GET", "/_nodes/stats?human=true")
nodesread = conn.getresponse()
objNodesJson=json.loads(nodesread.read())- for i in range(0,len(objNodesJson["nodes"].values())):
try:
esNode=objNodesJson["nodes"].values()[i]
nodename=str(esNode["name"])
dictNodeInfo["EsVersion"]=esVersion
dictNodeInfo["Health"]=health- #记录ES节点名称
dictNodeInfo["NodeName"]=nodename
dictNodeInfo["Interval"]=sleeptime- #记录CPU信息
dictNodeInfo["OSUserCpu"]=esNode["os"]["cpu"]["user"]- #记录ThreadpoolCount
dictNodeInfo["ThreadpoolCount"]=esNode["thread_pool"]["search"]["active"]- #记录JVM堆内存
dictNodeInfo["HeapMem"]=float(esNode["jvm"]["mem"]["heap_used"].replace("gb","").replace("mb",""))
curGCYoungCount=int(esNode["jvm"]["gc"]["collectors"]["young"]["collection_count"])
curGCOldCount=int(esNode["jvm"]["gc"]["collectors"]["old"]["collection_count"])
curGCYoungTime=int(esNode["jvm"]["gc"]["collectors"]["young"]["collection_time_in_millis"])
curGNCOldTime=int(esNode["jvm"]["gc"]["collectors"]["old"]["collection_time_in_millis"])
lastGCYoungCount=int(dictLastNodeInfo.get(nodename+"_GCYoungCount",-1))
lastGCOldCount=int(dictLastNodeInfo.get(nodename+"_GCOldCount",-1))
lastGCYoungTime=int(dictLastNodeInfo.get(nodename+"_GCYoungTime",-1))
lastGCOldTime=int(dictLastNodeInfo.get(nodename+"_GCOldTime",-1))
if lastGCYoungCount>=0 and lastGCOldCount>=0 and lastGCYoungTime>=0 and lastGCYoungTime>=0:
dictNodeInfo["GCYoungCount"]=curGCYoungCount-lastGCYoungCount
dictNodeInfo["GCOldCount"]=curGCOldCount-lastGCOldCount
dictNodeInfo["GCYoungTime"]=curGCYoungTime-lastGCYoungTime
dictNodeInfo["GCOldTime"]=curGNCOldTime-lastGCOldTime
if lastGCOldCount>0:
dictNodeInfo["GCYOCountRate"]=lastGCYoungCount/lastGCOldCount
dictLastNodeInfo[nodename+"_GCYoungCount"]=curGCYoungCount
dictLastNodeInfo[nodename+"_GCOldCount"]=curGCOldCount
dictLastNodeInfo[nodename+"_GCYoungTime"]=curGCYoungTime
dictLastNodeInfo[nodename+"_GCOldTime"]=curGNCOldTime- #记录连接数信息
dictNodeInfo["ChannelTransport"]=esNode["transport"]["server_open"]
dictNodeInfo["ChannelHttp"]=esNode["http"]["current_open"]- #记录当前节点Indices-Query信息
objSearch=esNode["indices"]["search"]
curQueryTotal=objSearch["query_total"]
curFetchTotal=objSearch["fetch_total"]
curTimestamp=esNode["timestamp"]
lastQueryTotal=dictLastNodeInfo.get(nodename+"_QueryTotal",-1)
lastFetchTotal=dictLastNodeInfo.get(nodename+"_FetchTotal",-1)
lastTimestamp=dictLastNodeInfo.get(nodename+"_Timestamp",-1)- if lastQueryTotal>0 and curQueryTotal>0:
curQueryCount=curQueryTotal-lastQueryTotal
curFetchCount=curFetchTotal-lastFetchTotal
curQueryTime=(curTimestamp-lastTimestamp)/1000
dictNodeInfo["Interval"]=curQueryTime
#print curQueryTotal,lastQueryTotal,curQueryCount,curTimestamp,lastTimestamp,curQueryTime,curQueryCount/curQueryTime
#记录QPS
if curQueryTime>0:
dictNodeInfo["IndicesQueryPS"]=curQueryCount/curQueryTime
dictNodeInfo["IndicesFetchPS"]=curFetchCount/curQueryTime
#print curQueryCount,curQueryTime,curQueryCount/curQueryTime- #更新上次节点数据对象
dictLastNodeInfo[nodename+"_QueryTotal"]=curQueryTotal
dictLastNodeInfo[nodename+"_FetchTotal"]=curFetchTotal
dictLastNodeInfo[nodename+"_Timestamp"]=curTimestamp- #取出cache信息
dictNodeInfo["FilterCache"] = float(esNode["indices"]["filter_cache"]["memory_size"].replace("mb","").replace("kb",""))
dictNodeInfo["FieldCache"] = float(esNode["indices"]["fielddata"]["memory_size"].replace("mb","").replace("kb",""))- #保存数据到数据库
if(dictNodeInfo.get("IndicesQueryPS",-1) < 0 or dictNodeInfo.get("GCYoungCount",-1) < 0):
continue
es_savelog.SaveLog(dictNodeInfo)- #推送ELK消息
dictNodeInfo["IndexName"] = "esbigdesk"
dictNodeInfo["LogTime"] = time.strftime("%Y-%m-%d %H:%M:%S.000", time.localtime())
print json.dumps(dictNodeInfo)
MQHelper.SendMessage(json.dumps(dictNodeInfo))
dictNodeInfo.clear()
except Exception,ex:
print Exception,":",ex- #休眠
time.sleep(sleeptime)- #启动
if __name__=="__main__":
main()
print "over"
记录bigdesk中ElasticSearch的性能参数的更多相关文章
- ElasticSearch中的JVM性能调优
ElasticSearch中的JVM性能调优 前一段时间被人问了个问题:在使用ES的过程中有没有做过什么JVM调优措施? 在我搭建ES集群过程中,参照important-settings官方文档来的, ...
- 【记录一个问题】opencl enqueueWriteBuffer()中,cl_bool blocking参数设置无效
err = queue.enqueueWriteBuffer(in_buf, true, 0, bmp_size, bmp_data, NULL, &event); 以上代码中,第二个参数设置 ...
- elasticsearch 基础 —— Mapping参数boost、coerce、copy_to、doc_values、dynamic、
boost 在查询时,各个字段可以自动提升 - 更多地依赖于相关性得分,boost参数如下: PUT my_index { "mappings": { "_doc&quo ...
- Java虚拟机(JVM)体系结构概述及各种性能参数优化总结
转自:http://blog.csdn.net/zhongwen7710/article/details/39213377 第一部分:相关的概念 数据类型 Java虚拟机中,数据类型可以分为两类:基本 ...
- 认识loadrunner及相关性能参数
认识loadrunner及相关性能参数 LoadRunner,是一种预测系统行为和性能的负载测试工具.通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找问题,LoadRunner能够对整 ...
- Java生鲜电商平台-SpringCloud微服务架构中网络请求性能优化与源码解析
Java生鲜电商平台-SpringCloud微服务架构中网络请求性能优化与源码解析 说明:Java生鲜电商平台中,由于服务进行了拆分,很多的业务服务导致了请求的网络延迟与性能消耗,对应的这些问题,我们 ...
- [转帖]Java虚拟机(JVM)体系结构概述及各种性能参数优化总结
Java虚拟机(JVM)体系结构概述及各种性能参数优化总结 2014年09月11日 23:05:27 zhongwen7710 阅读数 1437 标签: JVM调优jvm 更多 个人分类: Java知 ...
- PolarDB阿里初赛问题记录 PolarDB 阿里 中间件 比赛 性能 工程手册
Contents 这篇纯碎是碎碎念记录. 每个value都是4KB,总共最多会写6400W个value,算下来就是64 * 1000 * 1000 * 4 * 1024 Bytes ≈ 256G. 每 ...
- 浅谈JavaScript中的变量、参数、作用域和作用域链
基本类型和引用类型 在JavaScript中有两种数据类型值.基本类型值和引用类型值.基本类型值指的是简单的数据段,而引用类型值指的是可能由多个值构成的对象.在JavaScript中有5种基本数据类型 ...
随机推荐
- EXT学习之——Ext下拉框绑定以及级联写法
/*******步骤有四个,缺一不可*********/ function () {xxxxxx = Ext.extend(construct, {InitControl: function () { ...
- 学习总结 java连接数据库
package com.hanqi.test; import java.sql.*; public class jdbcTest { public static void main(String[] ...
- 洛谷P1519 穿越栅栏 Overfencing
P1519 穿越栅栏 Overfencing 69通过 275提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 USACO是100分,洛谷是20分 为什么 ...
- 分层服务提供者(LSP)
分层服务提供者(LSP)(1) 开发过滤数据包的LSP程序可以定义过滤规则,恩,先看看LSP本身是DLL,可以将它安装至Winsock目录,创建套接字的应用程序不必知道此LSP的任何信息就能调用它 1 ...
- jQuery 监控键盘一段时间内没输入
监控一段时间没输入可用于简单的输入完成 上次实现了一个模拟输入完成则发送请求到后台获取数据的并显示到前台的问题,其中核心的判断标准是输入完成的定义. 即:用户怎么算输入完成. 我使用的标准是,当一个文 ...
- zz
婚恋新现象 杭州男为何更愿意娶外地女孩?-浙江新闻-浙江在线 剩男三无
- windows server 时间同步
域环境,加入域的客户端时间同步服务器时间 问题:服务器存在一种情况,不存在"intelnet时间"选项卡 解决办法:手动修改为正确时间 客户端运行: CMD-->w32tm ...
- ftp自动上传下载文件脚本
FTP自动登录批量下载文件 从ftp服务器192.168.1.60 上的/home/data 到本地的/home/databackup目录 #!/bin/bash ftp -v -n 192.168. ...
- sqlite mvc分页
<tr class="tr1"> <td> 共<asp:Literal r ...
- C#winform初试报表
步骤1.新建一个窗口,拖一个ReportViewer控件上去,设置该控件的Dock为Fill. 步骤2.添加一个报表文件,如:Report1.rdlc,设置其中的参数,这里设置的参数和下面的代码里面的 ...