-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebsphere_verbosegc.py
85 lines (69 loc) · 3.64 KB
/
websphere_verbosegc.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
82
83
84
85
# -*- coding: utf-8 -*-
'''
Parse websphere verbosegc log and extract data to a csv. Currently it gives you a high level information such as
- Date & Time when invocation of the garbage collection happened
- intervalms -> Interval between the present and previous garbage collection invocation
- totalms -> Total execution time of this garbage collection
- requested_bytes -> Allocation requested bytes
Useful if you want to import this metrics to your load testing tool for further analysis with other metrics.
TODO
- Extract metrics for the heap (i.e. nursery & tenured space) state before the collection and after the collection
- Extract the Heap occupancy details after GC
Links
- https://gauravrohatgi.files.wordpress.com/2014/01/was-tuning.pdf
'''
import xml.etree.ElementTree as ET
from datetime import datetime
from time import strptime
from collections import OrderedDict
import pandas as pd
def parse_verbosegc_data(verbosegc_xml):
verbosegc_list=[]
try:
tree = ET.parse(verbosegc_xml) # create element tree object
for item in tree.findall ('./af'):
df_dict = OrderedDict()
date_time = (item.attrib['timestamp']).split()
date = datetime(int(date_time[3]),strptime(date_time[0],'%b').tm_mon,int(date_time[1])) #converting month (i.e. 'Feb') to month number using strptime
df_dict['date'] = date.strftime("%d/%m/%Y")
df_dict['time'] = date_time[2]
df_dict['type'] = item.attrib['type']
df_dict['intervalms'] = item.attrib['intervalms']
nursery_counter = False
tenured_counter = False
for child in item:
if 'totalms' in child.attrib:
df_dict['totalms'] = child.attrib['totalms']
if 'requested_bytes' in child.attrib:
df_dict['requested_bytes'] = child.attrib['requested_bytes']
if ('freebytes' in child.attrib and 'nursery' in child.tag and nursery_counter == False):
before = 'beforegc_'+ child.tag + '_freebytes'
df_dict[before] = child.attrib['freebytes']
nursery_counter = True
elif ('freebytes' in child.attrib and 'nursery' in child.tag and nursery_counter == True):
after = 'aftergc_'+ child.tag + '_freebytes'
df_dict[after] = child.attrib['freebytes']
nursery_counter = False
if ('freebytes' in child.attrib and 'tenured' in child.tag and tenured_counter == False):
before = 'beforegc_'+ child.tag + '_freebytes'
df_dict[before] = child.attrib['freebytes']
tenured_counter = True
elif ('freebytes' in child.attrib and 'tenured' in child.tag and tenured_counter == True):
after = 'aftergc_'+ child.tag + '_freebytes'
df_dict[after] = child.attrib['freebytes']
tenured_counter = False
if ('gc' in child.tag):
df_dict['gc_intervalms'] = child.attrib['intervalms']
verbosegc_list.append(df_dict)
verbosegc_data = pd.DataFrame(verbosegc_list)
save_verbosegc_data(verbosegc_data)
except Exception as e:
print (e)
def save_verbosegc_data(verbosegc_data):
FILE_TO_WRITE="./sample_files/verbose.csv"
verbosegc_data.to_csv(FILE_TO_WRITE, index=False)
def main():
# parse xml file
parse_verbosegc_data('./sample_files/node1.txt')
if __name__ == "__main__":
main()