利用python和jstat命令采集jvm数据
注:用法运行python jvcheck.py 变量如EC或E等
#coding=utf-8
#author=yangzai
# 用jstat检查jvm信息然后用zabbix监控
import commands
import sys
jvmvars=sys.argv[1]
(status, PID) = commands.getstatusoutput("sudo -u tomcat jps|grep Bootstrap$|grep -v Jps$|awk '{print $1}'") # PID
def change_gc_ke(cmd):
(status,gcresult_tmp)=commands.getstatusoutput(cmd)
gcresult_tmp = gcresult_tmp.split('\n')
gcresult_key = gcresult_tmp[0].split() # key
gcresult_values = gcresult_tmp[1].split() # values
gcresult = dict(zip(gcresult_key, gcresult_values))
return gcresult
####gcutil
if jvmvars in ('S0','S1','E','O','M','CCS','YGC','YGCT','FGC','FGCT','GCT'):
cmd_g