-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjvm_perf_test.py
81 lines (74 loc) · 2.96 KB
/
jvm_perf_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
_author_='Arun_Raj_R'
import configparser
import argparse
import os
#from apihelper import info
from multiprocessing import Process
from pathlib import Path
_mJavaHome=''
_mJmapHome=''
_mJstackPath=''
_mNodeList=''
_mPIDList=''
_mHeapDumpDest=''
_mHeapDumpLog=''
_mThreadDumpDest=''
_mThreadDumpLog=''
config = configparser.ConfigParser()
config.read('config.ini')
config.sections()
FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
def helperMethod():
_mParser = argparse.ArgumentParser(prog='jvm_perf_catcher',usage='%(prog)s [--auto AUTO] [--pid PID [PID ...]] [--takeHD] [--takeTD] [--jm options [heapdump heap histogram]] [--ji options [flags flag sysprops]] [--js options [gc gcutil ...]] [-h]',description='This is used to take Thread Dump & Heap Dump based on the switches. It provides auditing facility as well. It captures the dump and store it in the configured destination.',epilog='copyrights to Solartis,INC - AR')
_mParser.add_argument('--pid',metavar='pid_no',type=int, nargs='+',help='provide PID of Node name / Server name')
_mParser.add_argument('--takeHD',metavar='heapdump',help='take heap dump for the specified node')
_mParser.add_argument('--takeTD',metavar='threaddump',help='take thread dump for the specified node')
_mParser.add_argument('--jm',choices=['hr','hd','histo'],help='collect all JMap values')
_mParser.add_argument('--ji',choices=['flags','flag','sysprop'],help='collect all JInfo values')
_mParser.add_argument('--js',choices=['all','gc','gccause','gcnew','gcold','gcutil'],help='collect all JStat values')
_mParser.add_argument('--auto',help='collects all based on the configuration files')
_mArgs=_mParser.parse_args()
return()
#print(config['JINFO']['Flag'])
#print("Before funcations")
def checkJava():
return()
def takeThreadDump(x):
temp_value=x
print("_mJavaHome/bin/jstack -l " + temp_value + "> $_mThreadDumpDest/$_mPid+$_mTime")
print('module_name: ',__name__)
print('parent process: ',os.getppid())
print('process id: ',os.getpid())
print('Loop id: ',temp_value)
return()
def takeHeapDump():
print("_mJavaHome/bin/jmap -dump:live,format=b,file=$_mHeapDumpDest/$_mPid+$_mTime $_mPid")
return()
def listJnfo():
for keys in config['JINFO']: print(keys)
return()
#print ("Exited JINFOList")
def listJMAP():
for keys in config['JMAP']: print(keys)
return()
def listJSTAT():
for keys in config['JSTAT']: print(keys)
return()
def listNodeName():
for keys in config['NodeName']: print(keys)
return()
helperMethod()
listJnfo()
listNodeName()
listJSTAT()
listJMAP()
if __name__=='__main__':
for counter in range(1,10):
p = Process(target=takeThreadDump,args=(str(counter),))
p.start()
p.join()
#print("END CARD")
#config['JINFO'] = {}
#config['JMAP'] = {}
#config['JSTAT'] = {}
#config['NodeName'] = {}