Permalink
Browse files

Update jmx & process monitoring to allow monitoring without graphing

Add pause / autoupdate to reports
  • Loading branch information...
1 parent b8b22d0 commit 7cd54f9bbc2ee447267445ef978085a5b4e8cfd6 @jonjlee jonjlee committed Oct 4, 2011
Showing with 39 additions and 24 deletions.
  1. BIN jmxstat/jmxstat.jar
  2. +6 −6 lib/http.js
  3. +22 −11 lib/reporting/external.js
  4. +11 −7 lib/reporting/summary.tpl
View
Binary file not shown.
View
@@ -117,14 +117,14 @@ HttpServer.prototype.serveFile_ = function(file, response) {
/** The global HTTP server used by nodeload */
var HTTP_SERVER = exports.HTTP_SERVER = new HttpServer();
+HTTP_SERVER.on('start', function(hostname, port) {
+ qputs('Started HTTP server on ' + hostname + ':' + port + '.');
+});
+HTTP_SERVER.on('end', function() {
+ qputs('Shutdown HTTP server.');
+});
NODELOAD_CONFIG.on('apply', function() {
if (NODELOAD_CONFIG.HTTP_ENABLED) {
- HTTP_SERVER.on('start', function(hostname, port) {
- qputs('Started HTTP server on ' + hostname + ':' + port + '.');
- });
- HTTP_SERVER.on('end', function() {
- qputs('Shutdown HTTP server.');
- });
HTTP_SERVER.start(NODELOAD_CONFIG.HTTP_PORT);
}
});
View
@@ -8,9 +8,9 @@ var util = require('../util');
var path = require('path');
}
-var graphProcess;
+var monitorProcess;
-var graphJmx = exports.graphJmx = function(options) {
+var monitorJmx = exports.monitorJmx = function(options) {
// Verify that java & jmxstat jar can be found. Search for jmxstat/jmxstat.jar located next to the
// current module or a parent module that included it.
var m = module;
@@ -34,21 +34,26 @@ var graphJmx = exports.graphJmx = function(options) {
// Start jmxstat
var interval = options.interval || '';
- return graphProcess({
- reportName: options.reportName || options.host || 'Monitor',
- chartName: options.chartName || 'JMX',
+ return monitorProcess({
command: 'java -jar ' + jmxstat + ' ' + options.host + ' ' + mbeans.join(' ') + ' ' + interval,
columns: columns,
regex: regex,
dataFormatter: options.dataFormatter
});
};
+var graphJmx = exports.graphJmx = function(options) {
+ var report = REPORT_MANAGER.getReport(options.reportName || options.host || 'Monitor'),
+ graph = report.getChart(options.chartName || 'JMX'),
+ jmx = monitorJmx(options);
+ jmx.on('data', function (data) { graph.put(data); });
+ return jmx;
+};
/** Spawn a child process, extract data using a regex, and graph the results on the summary report.
Returns a standard ChildProcess object.
*/
-var graphProcess = exports.graphProcess = function(options) {
+var monitorProcess = exports.monitorProcess = function(options) {
var delimiter = options.delimiter || ' +',
columns = options.columns || [],
fieldRegex = columns.map(function() { return '([0-9.e+-]+)'; }).join(delimiter), // e.g. ([0-9.e+-]*) +([0-9.e+-]*) +...
@@ -62,10 +67,7 @@ var graphProcess = exports.graphProcess = function(options) {
return o;
};
- var report = REPORT_MANAGER.getReport(options.reportName || 'Monitor'),
- graph = report.getChart(options.chartName || options.command),
- format = options.dataFormatter || valuesToNumber;
-
+ var format = options.dataFormatter || valuesToNumber;
var proc = child_process.spawn('/bin/sh', ['-c', options.command], options.spawnOptions),
lr = new util.LineReader(proc.stdout);
@@ -81,9 +83,18 @@ var graphProcess = exports.graphProcess = function(options) {
obj[prefix + columns[i-1]] = vals[i];
}
}
- graph.put(format(obj));
+ obj = format(obj);
+ if (obj) { proc.emit('data', obj); }
}
});
return proc;
};
+var graphProcess = exports.graphProcess = function(options) {
+ var report = REPORT_MANAGER.getReport(options.reportName || 'Monitor'),
+ graph = report.getChart(options.chartName || options.command),
+ proc = monitorProcess(options);
+
+ proc.on('data', function (data) { graph.put(data); });
+ return proc;
+};
View
@@ -17,9 +17,10 @@
a:hover { text-decoration: none; }
#main { float:left; width: 740px; }
#sidebar { float:right; width: 260px; height: 100%; border-left: #BFC9AE solid 1px; margin-left: 10px; padding-left: 10px;}
- #header { width: 100%; height: 100px; margin: 0px auto; color: #FFFFFF; background: #699C4D; border: 3px solid darkgreen; border-style: none none solid none;}
+ #header { width: 100%; height: 120px; margin: 0px auto; color: #FFFFFF; background: #699C4D; border: 3px solid darkgreen; border-style: none none solid none;}
#header h1 { width: 1024; padding: 25px 0px 0px 0px; margin: 0px auto; font-weight: normal; }
#header p { width: 1024; padding: 15px 0px 0px 0px; margin: 0px auto; }
+ #chkPause { float: right; margin-right: 10px; }
#page { width: 1024px; margin: 0px auto; padding: 30px 0px; }
.post { margin: 0px 0px 30px 0px; }
.post h1, .post h2 { margin: 0px; padding: 0px 0px 5px 0px; border-bottom: #BFC9AE solid 1px; color: #232F01; }
@@ -36,6 +37,7 @@
<div id="header">
<h1>Test Results</h1>
<p id="timestamp"><%=new Date()%></p>
+ <p><input type="checkbox" id="chkAutoRefresh" checked="true"><label for="chkAutoRefresh">Auto-refresh</label></input><p>
</div>
<div id="page">
<div id="main"></div>
@@ -101,14 +103,16 @@
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }
setInterval(function() {
- http.open("GET", "/reports");
- http.onreadystatechange=function() {
- if (http.readyState == 4 && http.status == 200) {
- updateDate();
- update(JSON.parse(http.responseText));
+ if (document.getElementById("chkAutoRefresh").checked) {
+ http.open("GET", "/reports");
+ http.onreadystatechange=function() {
+ if (http.readyState == 4 && http.status == 200) {
+ updateDate();
+ update(JSON.parse(http.responseText));
+ }
}
+ http.send(null);
}
- http.send(null);
}, <%=refreshPeriodMs%>);
graphs = {};

0 comments on commit 7cd54f9

Please sign in to comment.