Skip to content

Commit

Permalink
Add reporting.graphJmx()
Browse files Browse the repository at this point in the history
Upgrade jmxstat
  • Loading branch information
jonjlee committed Jul 29, 2011
1 parent e380f6a commit 98884e7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: clean templates compile
PROCESS_TPL = scripts/process_tpl.js
SOURCES = lib/header.js lib/config.js lib/util.js lib/stats.js lib/loop/loop.js lib/loop/multiloop.js lib/monitoring/collectors.js lib/monitoring/statslogger.js lib/monitoring/monitor.js lib/monitoring/monitorgroup.js lib/http.js lib/reporting/*.tpl.js lib/reporting/template.js lib/reporting/report.js lib/reporting/reportmanager.js lib/reporting/process.js lib/loadtesting.js lib/remote/endpoint.js lib/remote/endpointclient.js lib/remote/slave.js lib/remote/slaves.js lib/remote/slavenode.js lib/remote/cluster.js lib/remote/httphandler.js lib/remote/remotetesting.js
SOURCES = lib/header.js lib/config.js lib/util.js lib/stats.js lib/loop/loop.js lib/loop/multiloop.js lib/monitoring/collectors.js lib/monitoring/statslogger.js lib/monitoring/monitor.js lib/monitoring/monitorgroup.js lib/http.js lib/reporting/*.tpl.js lib/reporting/template.js lib/reporting/report.js lib/reporting/reportmanager.js lib/reporting/jmx.js lib/loadtesting.js lib/remote/endpoint.js lib/remote/endpointclient.js lib/remote/slave.js lib/remote/slaves.js lib/remote/slavenode.js lib/remote/cluster.js lib/remote/httphandler.js lib/remote/remotetesting.js

all: compile

Expand Down
Binary file modified jmxstat/jmxstat.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/reporting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ exports.Report = report.Report;
exports.Chart = report.Chart;
exports.ReportGroup = report.ReportGroup;
exports.REPORT_MANAGER= require('./reportmanager').REPORT_MANAGER;
exports.spawnAndMonitor = require('./process').spawnAndMonitor;
exports.graphJmx = require('./jmx').graphJmx;
36 changes: 34 additions & 2 deletions lib/reporting/process.js → lib/reporting/jmx.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
/*jslint forin:true */

var BUILD_AS_SINGLE_FILE;
if (!BUILD_AS_SINGLE_FILE) {
var child_process = require('child_process');
var REPORT_MANAGER = require('./reportmanager').REPORT_MANAGER;
}

var spawnAndMonitor;

var graphJmx = exports.graphJmx = function(options) {
// Verify that java & jmxstat jar can be found

// Build command line args, output regex, and field labels
var regex = '\\d{2}:\\d{2}:\\d{2}',
labels = [],
mbeans = [];
for (var m in options.mbeans) {
regex += '\\t([^\\t]*)';
labels.push(m);
mbeans.push(options.mbeans[m]);
}
regex = new RegExp(regex);

// Add graph
var report = REPORT_MANAGER.addReport(options.host),
graph = report.getChart(options.title);

// Spawn jmxstat
var jmx = spawnAndMonitor(
regex, labels,
'java', ['-jar', 'jmxstat/jmxstat.jar', options.host].concat(mbeans).concat(options.interval)
);

graph.updateFromEventEmitter(jmx, labels);
};

/** Spawn a child process and extract data using a regex. Each line is compared to the regex. If a match
is found, the groups are written to an object using the given field names, and the 'data' event is
emitted.
Expand All @@ -23,7 +55,7 @@ then:
will emit('data', {userReadable: 'r', groupReadable: 'r', worldReadable: '-'});
*/
var spawnAndMonitor = exports.spawnAndMonitor = function(regex, fields, spawnArguments) {
function spawnAndMonitor(regex, fields, spawnArguments) {
var buf = '', proc = child_process.spawn.apply(child_process, Array.prototype.slice.call(arguments, 2));
proc.stdout.on('data', function (data) {
buf += data.toString();
Expand All @@ -47,4 +79,4 @@ var spawnAndMonitor = exports.spawnAndMonitor = function(regex, fields, spawnArg
});
});
return proc;
};
}
3 changes: 1 addition & 2 deletions lib/reporting/summary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
labelsDiv: document.getElementById("chartlegend" + chart.uid),
labelsSeparateLines: true,
labels: chart.columns,
xAxisLabelWidth: 80,
pixelsPerXLabel: 100
xAxisLabelWidth: 80
});
}
}
Expand Down
10 changes: 6 additions & 4 deletions nodeload.js

Large diffs are not rendered by default.

0 comments on commit 98884e7

Please sign in to comment.