javacore-analyser 2.0rc1__py3-none-any.whl → 2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ #
2
+ # Copyright IBM Corp. 2024 - 2024
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ #
5
+ import argparse
6
+
7
+ from javacore_analyser import javacore_analyser_batch, constants, javacore_analyser_web
8
+
9
+
10
+ def main():
11
+ parser = argparse.ArgumentParser(prog="python -m javacore_analyser")
12
+ subparsers = parser.add_subparsers(dest="type", help="Application type", required=True)
13
+
14
+ batch = subparsers.add_parser("batch", description="Run batch application")
15
+ batch.add_argument("input", help="Input file(s) or directory")
16
+ batch.add_argument("output", help="Destination report directory")
17
+ batch.add_argument("--separator", default=constants.DEFAULT_FILE_DELIMITER)
18
+
19
+ web = subparsers.add_parser("web", description="Run web application")
20
+ web.add_argument("--debug", help="Debug mode. Use True only for app development", default=False)
21
+ web.add_argument("--port", help="Application port", default=constants.DEFAULT_PORT)
22
+ web.add_argument("--reports-dir", help="Directory to store reports data",
23
+ default=constants.DEFAULT_REPORTS_DIR)
24
+
25
+ args = parser.parse_args()
26
+
27
+ app_type: str = args.type
28
+
29
+ if app_type.lower() == "web":
30
+ print("Running web application")
31
+ javacore_analyser_web.run_web(args.debug, args.port, args.reports_dir)
32
+ elif app_type.lower() == "batch":
33
+ print("Running batch application")
34
+ javacore_analyser_batch.batch_process(args.input, args.output, args.separator)
35
+ else:
36
+ print('Invalid application type. Available types: "batch" or "web"')
37
+
38
+
39
+ if __name__ == '__main__':
40
+ # This is the code to be able to run the app from command line.
41
+ # Try this:
42
+ # python -m javacore_analyser -h
43
+ main()
@@ -59,7 +59,7 @@ class AbstractSnapshotCollection(abc.ABC):
59
59
  self.thread_snapshots.append(snapshot)
60
60
 
61
61
  def index_of(self, snapshot):
62
- for i in range(len(self.thread_snapshotssnaps)):
62
+ for i in range(len(self.thread_snapshots)):
63
63
  if self.thread_snapshots[i] == snapshot: return i
64
64
  return -1
65
65
 
@@ -142,7 +142,7 @@ class AbstractSnapshotCollection(abc.ABC):
142
142
  result = 0
143
143
  for i in self.thread_snapshots:
144
144
  el = i.get_java_stack_depth()
145
- if el>result:
145
+ if el > result:
146
146
  result = el
147
147
  return result
148
148
 
@@ -30,10 +30,11 @@ ENCODING = '1TICHARSET'
30
30
  DATA_OUTPUT_SUBDIR = '/data/'
31
31
  DEFAULT_FILE_DELIMITER = ';'
32
32
 
33
- MIN_JAVACORE_SIZE = 5 * 1024 # Minimal Javacore size in bytes
33
+ MIN_JAVACORE_SIZE = 5 * 1024 # Minimal Javacore size in bytes
34
34
 
35
35
  DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
36
36
 
37
37
  # Web application constants
38
38
  DEFAULT_REPORTS_DIR = "reports"
39
39
  DEFAULT_PORT = 5000
40
+ TEMP_DIR = "temp_data" # Folder to store temporary data for creating reports
@@ -15,6 +15,8 @@ $('.show').click(function () {
15
15
  }
16
16
  });
17
17
 
18
+
19
+
18
20
  function expand_it(whichEl, link) {
19
21
  whichEl.style.display = (whichEl.style.display == "none") ? "" : "none";
20
22
  //if (link) {
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+
3
+ <!--
4
+ # Copyright IBM Corp. 2024 - 2024
5
+ # SPDX-License-Identifier: Apache-2.0
6
+ -->
7
+
8
+ <html lang="en">
9
+ <head>
10
+ <meta http-equiv="refresh" content="30" /> <!-- Refresh this page every 30s until generated page appears -->
11
+ <meta charset="UTF-8">
12
+ <title>The page is being generated</title>
13
+ </head>
14
+ <body>
15
+ <h1>The page is being generated. Once it is ready, it will appear here.</h1>
16
+ </body>
17
+ </html>
@@ -49,10 +49,32 @@ $(function() {
49
49
  searchInNode(rootNode, searchTerm);
50
50
  }
51
51
 
52
+ function processChild(child) {
53
+ try {
54
+ if (isDomNode(child) && child.classList.contains('toggle_expand')) {
55
+ for (i = 0; i < child.childNodes.length; ++i) {
56
+ grandchild = child.childNodes[i];
57
+ if (isDomNode(grandchild) && grandchild.text == '[+] Expand') {
58
+ grandchild.text = '[-] Collapse';
59
+ }
60
+ }
61
+ }
62
+ } catch(err) {
63
+ console.log(err);
64
+ }
65
+ }
66
+
52
67
  function searchInNode(node, searchTerm) {
53
68
  if (!isDomNode(node)) return;
54
69
  if (node.textContent.toUpperCase().match(searchTerm.toUpperCase())) {
55
70
  // expand the node here
71
+ if (!node.classList.contains('show-all')) {
72
+ node.classList.add('show-all');
73
+ for (i = 0; i < node.childNodes.length; ++i) {
74
+ child = node.childNodes[i];
75
+ processChild(child);
76
+ }
77
+ }
56
78
  if (node.getAttribute('style') && node.style.display == "none") {
57
79
  node.style.display = "";
58
80
  }
@@ -99,7 +99,9 @@ const loadChartGC = function() {
99
99
  }
100
100
 
101
101
  const sysResourceE3Elem = document.getElementById('systemresources_myChartGC');
102
- sysResourceE3Elem.classList.remove('hide');
102
+ if (sysResourceE3Elem) {
103
+ sysResourceE3Elem.classList.remove('hide');
104
+ }
103
105
 
104
106
  const ctx = document.getElementById('myChartGC');
105
107
 
@@ -125,7 +127,7 @@ const loadChartGC = function() {
125
127
  startingPoint = timestamp;
126
128
 
127
129
  if(endingPoint < timestamp)
128
- endingPoint > timestamp;
130
+ endingPoint = timestamp;
129
131
  }
130
132
 
131
133
  coresTimeRange['startTime'] = startingPoint;
@@ -145,12 +147,34 @@ const loadChartGC = function() {
145
147
  });
146
148
 
147
149
  // 3. find the HEAP_SIZE
148
- const MB_SIZE = Math.pow(1024, 2)
150
+ const MB_SIZE = Math.pow(1024, 2);
151
+ let heapAsString = document.getElementById('sys_info_table').rows[2].cells[1].innerHTML;
149
152
  let HEAP_SIZE;
150
- if(document.getElementById('sys_info_table').rows[2].cells[1].innerHTML.slice(-1).toLowerCase() === 'g')
151
- HEAP_SIZE = Number(document.getElementById('sys_info_table').rows[2].cells[1].innerHTML.slice(0, -1)) * MB_SIZE * 1024;
152
- else
153
- HEAP_SIZE = Number(document.getElementById('sys_info_table').rows[2].cells[1].innerHTML.slice(0, -1)) * MB_SIZE;
153
+ let heapUnit = heapAsString.slice(-1).toLowerCase();
154
+
155
+ if(!isNaN(Number(heapUnit))) {
156
+ HEAP_SIZE = Number(heapAsString);
157
+ }
158
+ else {
159
+
160
+ switch (heapUnit) {
161
+ case "g":
162
+ HEAP_SIZE =
163
+ Number(heapAsString.slice(0, -1)) * MB_SIZE * 1024;
164
+ break;
165
+ case "m":
166
+ HEAP_SIZE =
167
+ Number(heapAsString.slice(0, -1)) * MB_SIZE;
168
+ break;
169
+ case "k":
170
+ HEAP_SIZE =
171
+ Number(heapAsString.slice(0, -1)) * 1024;
172
+ break;
173
+ default:
174
+ console.log("Hmm, what now .. heap unit undefined!");
175
+ break;
176
+ }
177
+ }
154
178
 
155
179
  // 4. create input data for GC chart
156
180
  // start with gc collection done after the first javacore creation
@@ -20,139 +20,148 @@
20
20
  <script type="text/javascript" src="../data/jquery/wait2scripts.js"> _ </script>
21
21
  <script type="text/javascript" src="../data/jquery/sorting.js"> _ </script>
22
22
  <script type="text/javascript" src="../data/expand.js"> _ </script>
23
-
24
-
23
+ <script src="../data/jquery/jquery.mark.min.js"> _ </script>
24
+ <script type="text/javascript" src="../data/jquery/search.js"> _ </script>
25
25
  </head>
26
26
 
27
27
  <body id="doc_body" height="100%">
28
- <p class="right"><a href="../index.html"> Back to Main page </a></p>
29
- <h2>Wait Report for: <b>{id}</b></h2>
30
- <div id="all_threads">
31
- <table id="javacore_threads_table" class="tablesorter_blue">
32
- <thead>
33
- <tr>
34
- <th class="sixty">Thread name</th>
35
- <th>Total CPU usage (s)</th>
36
- <th>% CPU usage</th>
37
- <th>Memory allocated since last GC (MB)</th>
38
- <th>Java stack depth</th>
39
- <th>Status</th>
40
- </tr>
41
- </thead>
42
- <tbody>
43
- <xsl:for-each select="//Thread/all_snapshot_collection/snapshot_collection/stack[file_name='{id}']">
44
- <xsl:variable name="i" select="position()" />
28
+ <div class="searchbar">
29
+ <input id="search-input" type="search" />
30
+ <button data-search="search" id="search-button">Search</button>
31
+ <button data-search="next">Next</button>
32
+ <button data-search="prev">Prev</button>
33
+ <button data-search="clear">✖</button>
34
+ </div>
35
+ <div class="content">
36
+ <p class="right"><a href="../index.html"> Back to Main page </a></p>
37
+ <h2>Wait Report for: <b>{id}</b></h2>
38
+ <div id="all_threads">
39
+ <table id="javacore_threads_table" class="tablesorter_blue">
40
+ <thead>
45
41
  <tr>
46
- <td class="left">
47
- <div>
48
- <xsl:attribute name="id">
49
- <xsl:value-of select="concat('stack',$i)"/>
50
- </xsl:attribute>
51
- <a target="_blank">
52
- <xsl:attribute name="href">
53
- <xsl:value-of select="concat('../threads/thread_', thread_hash, '.html')"/>
42
+ <th class="sixty">Thread name</th>
43
+ <th>Total CPU usage (s)</th>
44
+ <th>% CPU usage</th>
45
+ <th>Memory allocated since last GC (MB)</th>
46
+ <th>Java stack depth</th>
47
+ <th>Status</th>
48
+ </tr>
49
+ </thead>
50
+ <tbody>
51
+ <xsl:for-each select="//Thread/all_snapshot_collection/snapshot_collection/stack[file_name='{id}']">
52
+ <xsl:variable name="i" select="position()" />
53
+ <tr>
54
+ <td class="left">
55
+ <div>
56
+ <xsl:attribute name="id">
57
+ <xsl:value-of select="concat('stack',$i)"/>
54
58
  </xsl:attribute>
55
- <xsl:value-of select="thread_name"/>
56
- </a>
57
- <xsl:choose>
58
- <xsl:when test="stack_depth &gt; 0">
59
- <div>
60
- <div class="toggle_expand">
61
- <a href="javaScript:;" class="show">[+] Expand</a> <!-- "show" class is used in expand.js -->
59
+ <a target="_blank">
60
+ <xsl:attribute name="href">
61
+ <xsl:value-of select="concat('../threads/thread_', thread_hash, '.html')"/>
62
+ </xsl:attribute>
63
+ <xsl:value-of select="thread_name"/>
64
+ </a>
65
+ <xsl:choose>
66
+ <xsl:when test="stack_depth &gt; 0">
67
+ <div>
68
+ <div class="toggle_expand">
69
+ <a href="javaScript:;" class="show">[+] Expand</a> <!-- "show" class is used in expand.js -->
70
+ </div>
71
+ <p class="stacktrace">
72
+ <xsl:for-each select="*[starts-with(name(), 'line')]">
73
+ <span>
74
+ <xsl:attribute name="class">
75
+ <xsl:value-of select="@kind"/>
76
+ </xsl:attribute>
77
+ <xsl:value-of select="current()"/>
78
+ </span>
79
+ <br/>
80
+ </xsl:for-each>
81
+ </p>
62
82
  </div>
63
- <p class="stacktrace">
64
- <xsl:for-each select="*[starts-with(name(), 'line')]">
65
- <span>
66
- <xsl:attribute name="class">
67
- <xsl:value-of select="@kind"/>
68
- </xsl:attribute>
69
- <xsl:value-of select="current()"/>
70
- </span>
71
- <br/>
72
- </xsl:for-each>
73
- </p>
74
- </div>
83
+ </xsl:when>
84
+ <xsl:otherwise>
85
+ No stack
86
+ </xsl:otherwise>
87
+ </xsl:choose>
88
+ </div>
89
+ </td>
90
+ <td>
91
+ <xsl:choose>
92
+ <xsl:when test="cpu_usage &gt;= 0">
93
+ <xsl:value-of select='format-number(cpu_usage, "0.00")'/>
75
94
  </xsl:when>
76
95
  <xsl:otherwise>
77
- No stack
96
+ <div class="warning">[!]
97
+ <span class="warningtooltip">Error computing CPU usage, javacores may be corrupted</span>
98
+ </div>
78
99
  </xsl:otherwise>
79
100
  </xsl:choose>
80
- </div>
81
- </td>
82
- <td>
83
- <xsl:choose>
84
- <xsl:when test="cpu_usage &gt;= 0">
85
- <xsl:value-of select='format-number(cpu_usage, "0.00")'/>
86
- </xsl:when>
87
- <xsl:otherwise>
88
- <div class="warning">[!]
89
- <span class="warningtooltip">Error computing CPU usage, javacores may be corrupted</span>
90
- </div>
91
- </xsl:otherwise>
92
- </xsl:choose>
93
- </td>
94
- <td>
95
- <xsl:choose>
96
- <xsl:when test="cpu_percentage &gt;= 0">
97
- <xsl:value-of select='format-number(cpu_percentage, "0.0")'/>
98
- </xsl:when>
99
- <xsl:otherwise>
100
- <div class="warning">[!]
101
- <span class="warningtooltip">Error computing CPU percentage, javacores may be corrupted</span>
102
- </div>
103
- </xsl:otherwise>
104
- </xsl:choose>
105
- </td>
106
- <td><xsl:value-of select='format-number(allocated_memory div 1024 div 1024, "0.00")'/></td>
107
- <td><xsl:value-of select='java_stack_depth'/></td>
108
- <xsl:choose>
109
- <xsl:when test="state='CW'">
110
- <td class="waiting">Waiting on condition</td>
111
- </xsl:when>
112
- <xsl:when test="state='R'">
113
- <td class="runnable">Runnable</td>
114
- </xsl:when>
115
- <xsl:when test="state='P'">
116
- <td class="parked">
101
+ </td>
102
+ <td>
117
103
  <xsl:choose>
118
- <xsl:when test="blocked_by=''">
119
- Parked
104
+ <xsl:when test="cpu_percentage &gt;= 0">
105
+ <xsl:value-of select='format-number(cpu_percentage, "0.0")'/>
120
106
  </xsl:when>
121
107
  <xsl:otherwise>
122
- <a target="_blank">
123
- <xsl:attribute name="href">
124
- <xsl:value-of select="concat('../threads/thread_', blocked_by/@thread_hash, '.html')"/>
125
- </xsl:attribute>
126
- <xsl:attribute name="title">
127
- <xsl:value-of select="blocked_by/@name" />
128
- </xsl:attribute>
129
- Parked on <xsl:value-of select="blocked_by/@thread_id"/>
130
- </a>
108
+ <div class="warning">[!]
109
+ <span class="warningtooltip">Error computing CPU percentage, javacores may be corrupted</span>
110
+ </div>
131
111
  </xsl:otherwise>
132
112
  </xsl:choose>
133
113
  </td>
134
- </xsl:when>
135
- <xsl:when test="state='B'">
136
- <td class="blocked">
137
- <a target="_blank">
138
- <xsl:attribute name="href">
139
- <xsl:value-of select="concat('../threads/thread_', blocked_by/@thread_hash, '.html')"/>
140
- </xsl:attribute>
141
- <xsl:attribute name="title">
142
- <xsl:value-of select="blocked_by/@name" />
143
- </xsl:attribute>
144
- Blocked by <xsl:value-of select="blocked_by/@thread_id"/>
145
- </a>
146
- </td>
147
- </xsl:when>
148
- <xsl:otherwise>
149
- <td><xsl:value-of select="state"/></td>
150
- </xsl:otherwise>
151
- </xsl:choose>
152
- </tr>
153
- </xsl:for-each>
154
- </tbody>
155
- </table>
114
+ <td><xsl:value-of select='format-number(allocated_memory div 1024 div 1024, "0.00")'/></td>
115
+ <td><xsl:value-of select='java_stack_depth'/></td>
116
+ <xsl:choose>
117
+ <xsl:when test="state='CW'">
118
+ <td class="waiting">Waiting on condition</td>
119
+ </xsl:when>
120
+ <xsl:when test="state='R'">
121
+ <td class="runnable">Runnable</td>
122
+ </xsl:when>
123
+ <xsl:when test="state='P'">
124
+ <td class="parked">
125
+ <xsl:choose>
126
+ <xsl:when test="blocked_by=''">
127
+ Parked
128
+ </xsl:when>
129
+ <xsl:otherwise>
130
+ <a target="_blank">
131
+ <xsl:attribute name="href">
132
+ <xsl:value-of select="concat('../threads/thread_', blocked_by/@thread_hash, '.html')"/>
133
+ </xsl:attribute>
134
+ <xsl:attribute name="title">
135
+ <xsl:value-of select="blocked_by/@name" />
136
+ </xsl:attribute>
137
+ Parked on <xsl:value-of select="blocked_by/@thread_id"/>
138
+ </a>
139
+ </xsl:otherwise>
140
+ </xsl:choose>
141
+ </td>
142
+ </xsl:when>
143
+ <xsl:when test="state='B'">
144
+ <td class="blocked">
145
+ <a target="_blank">
146
+ <xsl:attribute name="href">
147
+ <xsl:value-of select="concat('../threads/thread_', blocked_by/@thread_hash, '.html')"/>
148
+ </xsl:attribute>
149
+ <xsl:attribute name="title">
150
+ <xsl:value-of select="blocked_by/@name" />
151
+ </xsl:attribute>
152
+ Blocked by <xsl:value-of select="blocked_by/@thread_id"/>
153
+ </a>
154
+ </td>
155
+ </xsl:when>
156
+ <xsl:otherwise>
157
+ <td><xsl:value-of select="state"/></td>
158
+ </xsl:otherwise>
159
+ </xsl:choose>
160
+ </tr>
161
+ </xsl:for-each>
162
+ </tbody>
163
+ </table>
164
+ </div>
156
165
  </div>
157
166
  </body>
158
167
  <script type="text/javascript" src="../data/expand.js"> _ <!-- underscore character is required to prevent converting to <script /> which does not work --> </script>
@@ -355,25 +355,41 @@
355
355
  <h4>Garbage Collection Activity</h4>
356
356
  <a id="togglememusagedoc" href="javascript:expand_it(memusagedoc,togglememusagedoc)" class="expandit">
357
357
  What does this chart tell me?</a>
358
- <div id="memusagedoc" style="display:none;">
359
- This chart shows all the garbage collections that happened between the time
360
- of the first and the last javacore in the data set.
361
- Garbage collections that happened before the first
362
- or after the last javacore generation time are not included.
363
- <ul>
364
- <li><strong>Heap Usage</strong>
365
- is the available Java heap memory over time,
366
- based on the garbage collection data from the verbose GC log files.
367
- </li>
368
- <li><strong>Total Heap</strong>
369
- is the maximum size of the Java heap, configured by using the Xmx Java argument,
370
- expressed in megabytes.
371
- </li>
372
- </ul>
373
- </div>
374
- <div id="systemresources_myChartGC" class="chart-container hide">
375
- <canvas id="myChartGC" height="200"></canvas>
376
- </div>
358
+ <xsl:choose>
359
+ <xsl:when test="doc/report_info/verbose_gc_list/verbose_gc">
360
+ <xsl:choose>
361
+ <xsl:when test="//verbose_gc_list/@total_collects_in_time_limits = 0">
362
+ <br/>
363
+ There were no garbage collections withing the javacore time limits
364
+ </xsl:when>
365
+ <xsl:otherwise>
366
+ <div id="memusagedoc" style="display:none;">
367
+ This chart shows all the garbage collections that happened between the time
368
+ of the first and the last javacore in the data set.
369
+ Garbage collections that happened before the first
370
+ or after the last javacore generation time are not included.
371
+ <ul>
372
+ <li><strong>Heap Usage</strong>
373
+ is the available Java heap memory over time,
374
+ based on the garbage collection data from the verbose GC log files.
375
+ </li>
376
+ <li><strong>Total Heap</strong>
377
+ is the maximum size of the Java heap, configured by using the Xmx Java argument,
378
+ expressed in megabytes.
379
+ </li>
380
+ </ul>
381
+ </div>
382
+ <div id="systemresources_myChartGC" class="chart-container hide">
383
+ <canvas id="myChartGC" height="200"></canvas>
384
+ </div>
385
+ </xsl:otherwise>
386
+ </xsl:choose>
387
+ </xsl:when>
388
+ <xsl:otherwise>
389
+ <br/>
390
+ No verbosegc logs were provided
391
+ </xsl:otherwise>
392
+ </xsl:choose>
377
393
  <h4>CPU Load</h4>
378
394
  <a id="togglecpuloaddoc" href="javascript:expand_it(cpuloaddoc,togglecpuloaddoc)" class="expandit">
379
395
  What does this chart tell me?</a>
@@ -748,7 +764,7 @@
748
764
 
749
765
  <p></p>
750
766
  <div class="margined">
751
- <a href="https://w3.ibm.com/w3publisher/wait2-tool" target="_blank">Documentation</a>
767
+ <a href="https://github.com/IBM/javacore-analyser/wiki" target="_blank">Documentation</a>
752
768
  </div>
753
769
  <div class="margined">
754
770
  In case of any issues with the tool use Slack group: