Skip to content

Commit e6786cc

Browse files
mattcolegatestalleyj
authored andcommitted
Support Node for z/OS (#474)
* Update omr-agentcore submodule to one with zOS * Update omr-agentcore submodule again * Add os390 target conditions to binding.gyp * Pull new omr-agentcore level * bump omr-agentcore * Fix appmetrics zOS binding.gyp defines * Bump omr-agentcore * rebase omr-agentcore * Bump omr-agentcore again * Bump omr-ac * Bmp omr-ac * Bump omr-ac AGAIN * Bump omr-agentc * Bumper omr-core * Bumpy * BMP * Bumppp * Brumper * BUMP * BuMpEr * Blump * Blimp * Bgump * Make it clear what doesn't work on zOS yet * Temporarily disable nodegcplugin * attempt to stop nodegcplugin building again * Fix nodegcplugin for zOS * Put nodegcplugin back in for zOS * Start debug logging * IsGlobalAgent logging * isGlobalAgentAlreadyLoaded logging * iGAAL logging * iGAAL logging * iGAAL logging * getRequireCache pragma convert test * getRequireCache pragma convert test * getRequireCache pragma convert test * Remove isGlobalAgentAlreadyLoaded call on z/OS * Remove isGlobalAgentAlreadyLoaded call on z/OS * Remove isGlobalAgentAlreadyLoaded call on z/OS * Comment out headless * remove headless from index.js * Remove zip from appmetrics.cpp * Attempt to debug startup * Testing whether pragma converts are required * More logging around error * More logging around error and after * More pragma tomfoolery * Taking it back to original * Trying ASCII strings * Trying ASCII strings #2 * Trying EBCDIC strings * correct _zOS #ifdefs * cast unsigned char * to char * * use correct std::string constructor * Trying ASCII strings with hope * Can I get a parent? * ASCIIfy all strings passed to Node functions * EBCDICify all strings passed from Node functions * Reinstate isGlobalAgentAlreadyLoaded() * more output required * more output required * Bump omr-agentcore version * Bump omr-agentcore again * Bumper * Brump * Bumpybump * Output agentcore version, remove heapdump * More logging * Fix compilation error * Sort out getMonitorApiFunction path * Rename pushData function to apiPushData * Bump agentcore; remove unneeded debug * Bumping agentcore to stop building CPUPlugin on zOS * Remove cpuPlugin for z/OS * Attempting to untangle env data * Bump? * Stop building common memory plugin for z/OS * New Node Memory plugin (z/os specific) * Fix compilation errors * Fix more compilation errors * ASCIIfy node strings? * Properly ASCIIfy strings * fix includes * Logging time * Typos * Const char *s for logging * Or not * Formatted string log? * Basic logs * Add necessary handlescope * Functional mutterings * Is osObject null? * Null or Undefined? * Stop function calling * attempt require * attempt require * attempt require * attempt require * attempt require * attempting require * attempting require * More debug around names * Remove broken function code * Get readable output * Attempting to traverse node structure * Get appmetrics object?? * Calling via appmetrics index * Calling via appmetrics index * Clean up logging * Improve logging * Clearing up logging; add memory_node to memory types * Update omr-agentcore to latest master * Re-enable zip functionality for non-zOS platforms * Include headlessutils.h for non-zOS plaforms * Allow headless functionalisty on non-zOS platforms; fix .gitmodules * Fix debug namespace conflict in nodezmemoryplugin * Stop nodezmemoryplugin building on non-zOS platforms * Stop CPU test for z/OS * Explicitly state when tests are skipped due to platform
1 parent f66f081 commit e6786cc

File tree

10 files changed

+467
-150
lines changed

10 files changed

+467
-150
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ install.log
44
libagentcore.so
55
licenses
66
node_modules
7-
plugins
87
.project
98
/agentcore.dll
109
/heapdump.node

appmetrics-api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function API(agent, appmetrics) {
4646
break;
4747
case 'common_memory':
4848
case 'memory':
49+
case 'memory_node':
4950
formatMemory(message);
5051
break;
5152
case 'gc_node':

binding.gyp

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
"nandir%": "<!(node -e \"try {require('nan')}catch (e){console.log(e)}\")",
66
'build_id%': '.<!(["python", "./generate_build_id.py"])',
77
'appmetricsversion%': '<!(["python", "./get_from_json.py", "./package.json", "version"])',
8-
},
9-
"conditions": [
10-
['OS=="aix"', {
11-
"variables": {
8+
"conditions": [
9+
['OS=="aix"', {
1210
"SHARED_LIB_SUFFIX": ".a",
13-
},
14-
}],
15-
],
11+
}],
12+
],
13+
},
1614

1715
"target_defaults": {
1816
"cflags_cc!": [ '-fno-exceptions' ],
@@ -38,12 +36,16 @@
3836
"conditions": [
3937
['OS=="aix"', {
4038
"defines": [ "_AIX", "AIX" ],
41-
"libraries": [ "-Wl,-bexpall,-brtllib,-G,-bernotok,-brtl" ],
39+
"libraries": [ "-Wl,-bexpall,-brtllib,-G,-bernotok,-brtl,-L.,-bnoipath" ],
4240
}],
4341
['OS=="mac"', {
4442
"defines": [ "__MACH__", "__APPLE__", ],
4543
"libraries": [ "-undefined dynamic_lookup" ],
4644
}],
45+
['OS=="os390"', {
46+
"defines": [ "_ZOS", "_UNIX03_THREADS" ],
47+
"cflags_cc": ['-Wc,EXPORTALL'],
48+
}],
4749
['OS=="linux"', {
4850
"defines": [ "_LINUX", "LINUX" ],
4951
"variables": {
@@ -65,8 +67,6 @@
6567
],
6668
},
6769

68-
69-
7070
"targets": [
7171
{
7272
"target_name": "omr-agentcore",
@@ -125,7 +125,6 @@
125125
"<(srcdir)/plugins/node/heap/nodeheapplugin.cpp",
126126
],
127127
},
128-
129128
{
130129
"target_name": "nodeprofplugin",
131130
"type": "shared_library",
@@ -147,7 +146,6 @@
147146
"<(srcdir)/plugins/node/gc/nodegcplugin.cpp",
148147
],
149148
},
150-
151149
{
152150
"target_name": "install",
153151
"type": "none",
@@ -159,33 +157,69 @@
159157
"nodegcplugin",
160158
"nodeprofplugin",
161159
"nodeloopplugin",
162-
],
163-
"copies": [
164-
{
165-
"destination": "./",
166-
"files": [
167-
"<(PRODUCT_DIR)/appmetrics.node",
168-
"<(PRODUCT_DIR)/heapdump.node",
169-
"<(agentcoredir)/<(SHARED_LIB_PREFIX)agentcore<(SHARED_LIB_SUFFIX)",
160+
"nodeheapplugin",
161+
],
162+
"conditions": [
163+
['OS=="os390"', {
164+
"dependencies+": [
165+
"nodezmemoryplugin",
170166
],
171-
},
167+
}],
168+
],
169+
"copies": [
170+
{
171+
"destination": "./",
172+
"files": [
173+
"<(PRODUCT_DIR)/appmetrics.node",
174+
"<(PRODUCT_DIR)/heapdump.node",
175+
"<(agentcoredir)/<(SHARED_LIB_PREFIX)agentcore<(SHARED_LIB_SUFFIX)",
176+
],
177+
},
178+
{
179+
"destination": "./plugins",
180+
"files": [
181+
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeenvplugin<(SHARED_LIB_SUFFIX)",
182+
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeheapplugin<(SHARED_LIB_SUFFIX)",
183+
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodegcplugin<(SHARED_LIB_SUFFIX)",
184+
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeprofplugin<(SHARED_LIB_SUFFIX)",
185+
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeloopplugin<(SHARED_LIB_SUFFIX)",
186+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)hcmqtt<(SHARED_LIB_SUFFIX)",
187+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)cpuplugin<(SHARED_LIB_SUFFIX)",
188+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)envplugin<(SHARED_LIB_SUFFIX)",
189+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)memoryplugin<(SHARED_LIB_SUFFIX)",
190+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)hcapiplugin<(SHARED_LIB_SUFFIX)",
191+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)headlessplugin<(SHARED_LIB_SUFFIX)",
192+
],
193+
"conditions": [
194+
['OS=="os390"', {
195+
# no hcmqtt, cpu or memory plugin
196+
"files!": [
197+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)hcmqtt<(SHARED_LIB_SUFFIX)",
198+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)cpuplugin<(SHARED_LIB_SUFFIX)",
199+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)memoryplugin<(SHARED_LIB_SUFFIX)",
200+
# the following don't work on zOS yet
201+
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)headlessplugin<(SHARED_LIB_SUFFIX)",
202+
],
203+
"files+": [
204+
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodezmemoryplugin<(SHARED_LIB_SUFFIX)",
205+
],
206+
}],
207+
],
208+
},
209+
],
210+
},
211+
],
212+
"conditions": [
213+
['OS=="os390"', {
214+
"targets+": [
172215
{
173-
"destination": "./plugins",
174-
"files": [
175-
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeenvplugin<(SHARED_LIB_SUFFIX)",
176-
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeheapplugin<(SHARED_LIB_SUFFIX)",
177-
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodegcplugin<(SHARED_LIB_SUFFIX)",
178-
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeprofplugin<(SHARED_LIB_SUFFIX)",
179-
"<(PRODUCT_DIR)/<(SHARED_LIB_PREFIX)nodeloopplugin<(SHARED_LIB_SUFFIX)",
180-
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)hcmqtt<(SHARED_LIB_SUFFIX)",
181-
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)cpuplugin<(SHARED_LIB_SUFFIX)",
182-
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)envplugin<(SHARED_LIB_SUFFIX)",
183-
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)memoryplugin<(SHARED_LIB_SUFFIX)",
184-
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)hcapiplugin<(SHARED_LIB_SUFFIX)",
185-
"<(agentcoredir)/plugins/<(SHARED_LIB_PREFIX)headlessplugin<(SHARED_LIB_SUFFIX)",
216+
"target_name": "nodezmemoryplugin",
217+
"type": "shared_library",
218+
"sources": [
219+
"<(srcdir)/plugins/node/memory/nodezmemoryplugin.cpp",
186220
],
187221
},
188222
],
189-
},
223+
}],
190224
],
191225
}

index.js

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ var aspect = require('./lib/aspect.js');
2121
var request = require('./lib/request.js');
2222
var fs = require('fs');
2323
var agent = require('./appmetrics');
24-
var headlessZip = require('./headless_zip.js');
25-
var heapdump = require('./heapdump.js');
24+
const os = require('os');
25+
var notOnZOS = !(process.platform === 'os390');
26+
if (notOnZOS) {
27+
var headlessZip = require('./headless_zip.js');
28+
var heapdump = require('./heapdump.js');
29+
}
2630
var VERSION = require('./package.json').version;
2731
var assert = require('assert');
28-
2932
// Set the plugin search path
3033
agent.spath(path.join(module_dir, 'plugins'));
3134

@@ -41,17 +44,19 @@ var propertyMappings = {
4144
mqtt: 'com.ibm.diagnostics.healthcenter.mqtt',
4245
profiling: 'com.ibm.diagnostics.healthcenter.data.profiling',
4346
};
44-
var headlessPropertyMappings = {
45-
'appmetrics.file.collection': 'com.ibm.diagnostics.healthcenter.headless',
46-
'appmetrics.file.max.size': 'com.ibm.diagnostics.healthcenter.headless.files.max.size',
47-
'appmetrics.file.run.duration': 'com.ibm.diagnostics.healthcenter.headless.run.duration',
48-
'appmetrics.file.delay.start': 'com.ibm.diagnostics.healthcenter.headless.delay.start',
49-
'appmetrics.file.run.pause.duration': 'com.ibm.diagnostics.healthcenter.headless.run.pause.duration',
50-
'appmetrics.file.run.number.of.runs': 'com.ibm.diagnostics.healthcenter.headless.run.number.of.runs',
51-
'appmetrics.file.files.to.keep': 'com.ibm.diagnostics.healthcenter.headless.files.to.keep',
52-
'appmetrics.file.output.directory': 'com.ibm.diagnostics.healthcenter.headless.output.directory',
53-
};
5447

48+
if (notOnZOS) {
49+
var headlessPropertyMappings = {
50+
'appmetrics.file.collection': 'com.ibm.diagnostics.healthcenter.headless',
51+
'appmetrics.file.max.size': 'com.ibm.diagnostics.healthcenter.headless.files.max.size',
52+
'appmetrics.file.run.duration': 'com.ibm.diagnostics.healthcenter.headless.run.duration',
53+
'appmetrics.file.delay.start': 'com.ibm.diagnostics.healthcenter.headless.delay.start',
54+
'appmetrics.file.run.pause.duration': 'com.ibm.diagnostics.healthcenter.headless.run.pause.duration',
55+
'appmetrics.file.run.number.of.runs': 'com.ibm.diagnostics.healthcenter.headless.run.number.of.runs',
56+
'appmetrics.file.files.to.keep': 'com.ibm.diagnostics.healthcenter.headless.files.to.keep',
57+
'appmetrics.file.output.directory': 'com.ibm.diagnostics.healthcenter.headless.output.directory',
58+
};
59+
}
5560
/*
5661
* Load module probes into probes array by searching the probes directory.
5762
* We handle the 'trace' probe as a special case because we don't want to put
@@ -153,6 +158,17 @@ aspect.after(module.__proto__, 'require', data, function(obj, methodName, args,
153158
}
154159
});
155160

161+
if (notOnZOS) {
162+
agent.setHeadlessZipFunction(headlessZip.headlessZip);
163+
}
164+
165+
// Export any functions exported by the agent
166+
for (var prop in agent) {
167+
if (typeof agent[prop] == 'function') {
168+
module.exports[prop] = agent[prop];
169+
}
170+
}
171+
156172
/*
157173
* Provide API to enable data collection for a given data type.
158174
* Profiling is done via a control message to the core monitoring agent.
@@ -255,14 +271,6 @@ module.exports.setConfig = function(data, config) {
255271
}
256272
};
257273

258-
// Export any functions exported by the agent
259-
for (var prop in agent) {
260-
if (typeof agent[prop] == 'function') {
261-
module.exports[prop] = agent[prop];
262-
}
263-
agent.setHeadlessZipFunction(headlessZip.headlessZip);
264-
}
265-
266274
// Export emit() API for JS data providers
267275
module.exports.emit = function(topic, data) {
268276
if (typeof this.api !== 'undefined') {
@@ -315,25 +323,33 @@ module.exports.getJSONProfilingMode = function() {
315323
return jsonProfilingMode;
316324
};
317325

318-
module.exports.writeSnapshot = function(args) {
319-
return heapdump.writeSnapshot(args);
326+
module.exports.getTotalPhysicalMemorySize = function() {
327+
return os.totalmem();
320328
};
321329

330+
if (notOnZOS) {
331+
module.exports.writeSnapshot = function(args) {
332+
return heapdump.writeSnapshot(args);
333+
};
334+
}
335+
322336
module.exports.start = function start() {
323337
agent.setOption(propertyMappings['applicationID'], main_filename);
324-
for (var property in headlessPropertyMappings) {
325-
var prop = agent.getOption(property);
326-
if (prop) {
327-
agent.setOption(headlessPropertyMappings[property], prop);
338+
if (notOnZOS) {
339+
for (var property in headlessPropertyMappings) {
340+
var prop = agent.getOption(property);
341+
if (prop) {
342+
agent.setOption(headlessPropertyMappings[property], prop);
343+
}
344+
}
345+
var headlessOutputDir = agent.getOption('com.ibm.diagnostics.healthcenter.headless.output.directory');
346+
if (headlessOutputDir) {
347+
headlessZip.setHeadlessOutputDir(headlessOutputDir);
348+
}
349+
var headlessFilesToKeep = agent.getOption('com.ibm.diagnostics.healthcenter.headless.files.to.keep');
350+
if (headlessFilesToKeep && !isNaN(headlessFilesToKeep) && headlessFilesToKeep > 0) {
351+
headlessZip.setFilesToKeep(headlessFilesToKeep);
328352
}
329-
}
330-
var headlessOutputDir = agent.getOption('com.ibm.diagnostics.healthcenter.headless.output.directory');
331-
if (headlessOutputDir) {
332-
headlessZip.setHeadlessOutputDir(headlessOutputDir);
333-
}
334-
var headlessFilesToKeep = agent.getOption('com.ibm.diagnostics.healthcenter.headless.files.to.keep');
335-
if (headlessFilesToKeep && !isNaN(headlessFilesToKeep) && headlessFilesToKeep > 0) {
336-
headlessZip.setFilesToKeep(headlessFilesToKeep);
337353
}
338354
var am = this;
339355
agent.start();
@@ -343,9 +359,11 @@ module.exports.start = function start() {
343359
clearInterval(latencyCheckLoop);
344360
clearInterval(latencyReportLoop);
345361
}
346-
var headlessMode = agent.getOption('com.ibm.diagnostics.healthcenter.headless');
362+
if (notOnZOS) {
363+
var headlessMode = agent.getOption('com.ibm.diagnostics.healthcenter.headless');
364+
}
347365
am.stop();
348-
if (headlessMode == 'on') {
366+
if (notOnZOS && headlessMode == 'on') {
349367
headlessZip.tryZipOnExit();
350368
}
351369
});

0 commit comments

Comments
 (0)