Skip to content

Commit 4d3a99c

Browse files
authored
Merge pull request #21570 from keithc-ca/dynatrace51
Print Dynatrace core_pattern location in java dumps
2 parents 3dcfa8b + d557db9 commit 4d3a99c

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

runtime/rasdump/dmpsup.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,18 +1381,21 @@ initSystemInfo(J9JavaVM *vm)
13811381
{
13821382
J9RASSystemInfo *corePatternInfo = appendSystemInfoFromFile(vm, J9RAS_SYSTEMINFO_CORE_PATTERN, J9RAS_CORE_PATTERN_FILE);
13831383
if (NULL != corePatternInfo) {
1384+
static const char search[] = "/oneagent/agent/rdp";
1385+
static const char replacement[] = "/oneagent/agent/conf/original_core_pattern";
1386+
static const char original_core_pattern[] = "/var/lib/dynatrace/oneagent/agent/backup/original_core_pattern";
1387+
13841388
/* A common core_pattern is Dynatrace; for example, |/opt/dynatrace/oneagent/agent/rdp
1385-
* This program sends the core to the originally configured
1386-
* core_pattern as stored in, for example,
1387-
* /opt/dynatrace/oneagent/agent/conf/original_core_pattern
13881389
*
1389-
* If we find this Dynatrace core_pattern, extract its installation
1390-
* directory and then read original_core_pattern relative to that.
1390+
* Newer releases of Dynatrace capture the orginal core_pattern in a file at a fixed
1391+
* location (original_core_pattern): if that file is found, it is assumed that the
1392+
* installation of Dynatrace is recent and that file contains useful information.
1393+
* Otherwise the location is derived from the current core_pattern, which based on
1394+
* the example, would be /opt/dynatrace/oneagent/agent/conf/original_core_pattern.
1395+
* If that file is found its contents are captured in the dump.
13911396
*/
13921397
const char *corePattern = (const char *)corePatternInfo->data;
13931398
if ('|' == corePattern[0]) {
1394-
static const char search[] = "/oneagent/agent/rdp";
1395-
static const char replacement[] = "/oneagent/agent/conf/original_core_pattern";
13961399
const char *dynatracePath = strstr(corePattern, search);
13971400

13981401
/* Check if core_pattern includes the Dynatrace agent. */
@@ -1401,8 +1404,15 @@ initSystemInfo(J9JavaVM *vm)
14011404
/* The length of the agent path prefix, minus the pipe character. */
14021405
size_t prefixLength = dynatracePath - corePattern - 1;
14031406

1404-
/* Ensure that the original_core_pattern path will fit in our buffer. */
1405-
if (prefixLength <= (sizeof(namebuf) - sizeof(replacement))) {
1407+
if (NULL != appendSystemInfoFromFile(
1408+
vm,
1409+
J9RAS_SYSTEMINFO_CORE_ORIGINAL_PATTERN,
1410+
original_core_pattern)
1411+
) {
1412+
/* The information was found in the new, fixed location. */
1413+
} else if (prefixLength <= (sizeof(namebuf) - sizeof(replacement))) {
1414+
/* The original_core_pattern path fits in our buffer. */
1415+
14061416
/* Copy the prefix starting after the pipe character. */
14071417
memcpy(namebuf, corePattern + 1, prefixLength);
14081418

runtime/rasdump/rasdump_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void setAllocationThreshold(J9VMThread *vmThread, UDATA min, UDATA max);
117117
#define J9RAS_SCHED_COMPAT_YIELD_FILE "/proc/sys/kernel/sched_compat_yield"
118118
#define J9RAS_CORE_PATTERN_FILE "/proc/sys/kernel/core_pattern"
119119
#define J9RAS_CORE_USES_PID_FILE "/proc/sys/kernel/core_uses_pid"
120-
#define J9RAS_CORE_ORIGINAL_PATTERN ".../oneagent/agent/conf/original_core_pattern"
120+
#define J9RAS_CORE_ORIGINAL_PATTERN "original_core_pattern"
121121

122122
#if defined(WIN32)
123123
#define ALT_DIR_SEPARATOR '/'

0 commit comments

Comments
 (0)