diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 7347069..5ede7d0 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -11,6 +11,7 @@ Bug Fixes: * config: Add 'nodeload/config' module for configuring global parameters * multiloop: polling time for next change in load or user profiles was always 1 second * stats: Fix one-off error in Histogram.percentile wouldn't return the greatest number if it is greater than the number of buckets (i.e. in extra[]) +* nl.js: #issue/5: nl.js discarded URL query string and hash ## v0.2.0 (2010/12/01) ## diff --git a/lib/nl/options.js b/lib/nl/options.js index 1a9f979..800b701 100644 --- a/lib/nl/options.js +++ b/lib/nl/options.js @@ -80,6 +80,8 @@ parser.on(2, function (value) { testConfig.host = testConfig.url.hostname || testConfig.host; testConfig.port = Number(testConfig.url.port) || testConfig.port; testConfig.path = testConfig.url.pathname || testConfig.path; + testConfig.path += testConfig.url.search || ''; + testConfig.path += testConfig.url.hash || ''; }); parser.on( diff --git a/nodeload.js b/nodeload.js index 74a2df0..7712c72 100755 --- a/nodeload.js +++ b/nodeload.js @@ -99,8 +99,7 @@ if(callback){callback(data?fn(data):fn);} else{return data?fn(data):fn;}}};exports.create=template.create.bind(template);var BUILD_AS_SINGLE_FILE;if(!BUILD_AS_SINGLE_FILE){var util=require('../util');var querystring=require('querystring');var LogFile=require('../stats').LogFile;var template=require('./template');var config=require('../config');var REPORT_SUMMARY_TEMPLATE=require('./summary.tpl.js').REPORT_SUMMARY_TEMPLATE;var NODELOAD_CONFIG=config.NODELOAD_CONFIG;var START=NODELOAD_CONFIG.START;var DYGRAPH_SOURCE=require('./dygraph.tpl.js').DYGRAPH_SOURCE;} var Chart,timeFromStart;var Report=exports.Report=function(name){this.name=name;this.uid=util.uid();this.summary={};this.charts={};};Report.prototype={getChart:function(name){if(!this.charts[name]){this.charts[name]=new Chart(name);} return this.charts[name];},updateFromMonitor:function(monitor){monitor.on('update',this.doUpdateFromMonitor_.bind(this,monitor,''));return this;},updateFromMonitorGroup:function(monitorGroup){var self=this;monitorGroup.on('update',function(){util.forEach(monitorGroup.monitors,function(monitorname,monitor){self.doUpdateFromMonitor_(monitor,monitorname);});});return self;},doUpdateFromMonitor_:function(monitor,monitorname){var self=this;monitorname=monitorname?monitorname+' ':'';util.forEach(monitor.stats,function(statname,stat){util.forEach(stat.summary(),function(name,val){self.summary[self.name+' '+monitorname+statname+' '+name]=val;});if(monitor.interval[statname]){self.getChart(monitorname+statname).put(monitor.interval[statname].summary());}});}};var Chart=exports.Chart=function(name){this.name=name;this.uid=util.uid();this.columns=["time"];this.rows=[[timeFromStart()]];};Chart.prototype={put:function(data){var self=this,row=[timeFromStart()];util.forEach(data,function(column,val){var col=self.columns.indexOf(column);if(col<0){col=self.columns.length;self.columns.push(column);self.rows[0].push(0);} -row[col]=val;});self.rows.push(row);},updateFromEventEmitter:function(eventEmitter,fields,event){var self=this;eventEmitter.on(event||'data',function(data){var row={};fields.forEach(function(i){if(data[i]!==undefined){row[i]=data[i];}});console.log(row) -self.put(row);});}};var ReportGroup=exports.ReportGroup=function(){this.reports=[];this.logNameOrObject='results-'+START.getTime()+'.html';};ReportGroup.prototype={addReport:function(report){report=(typeof report==='string')?new Report(report):report;this.reports.push(report);return report;},setLogFile:function(logNameOrObject){this.logNameOrObject=logNameOrObject;},setLoggingEnabled:function(enabled){clearTimeout(this.loggingTimeoutId);if(enabled){this.logger=this.logger||(typeof this.logNameOrObject==='string')?new LogFile(this.logNameOrObject):this.logNameOrObject;this.loggingTimeoutId=setTimeout(this.writeToLog_.bind(this),this.refreshIntervalMs);}else if(this.logger){this.logger.close();this.logger=null;} +row[col]=val;});self.rows.push(row);},updateFromEventEmitter:function(eventEmitter,fields,event){var self=this;eventEmitter.on(event||'data',function(data){var row={};fields.forEach(function(i){if(data[i]!==undefined){row[i]=data[i];}});self.put(row);});}};var ReportGroup=exports.ReportGroup=function(){this.reports=[];this.logNameOrObject='results-'+START.getTime()+'.html';};ReportGroup.prototype={addReport:function(report){report=(typeof report==='string')?new Report(report):report;this.reports.push(report);return report;},setLogFile:function(logNameOrObject){this.logNameOrObject=logNameOrObject;},setLoggingEnabled:function(enabled){clearTimeout(this.loggingTimeoutId);if(enabled){this.logger=this.logger||(typeof this.logNameOrObject==='string')?new LogFile(this.logNameOrObject):this.logNameOrObject;this.loggingTimeoutId=setTimeout(this.writeToLog_.bind(this),this.refreshIntervalMs);}else if(this.logger){this.logger.close();this.logger=null;} return this;},reset:function(){this.reports={};},getHtml:function(){var self=this,t=template.create(REPORT_SUMMARY_TEMPLATE);return t({DYGRAPH_SOURCE:DYGRAPH_SOURCE,querystring:querystring,refreshPeriodMs:self.refreshIntervalMs,reports:self.reports});},writeToLog_:function(){this.loggingTimeoutId=setTimeout(this.writeToLog_.bind(this),this.refreshIntervalMs);this.logger.clear(this.getHtml());}};function timeFromStart(){return(Math.floor((new Date().getTime()-START)/600)/100);} var BUILD_AS_SINGLE_FILE;if(!BUILD_AS_SINGLE_FILE){var ReportGroup=require('./report').ReportGroup;var config=require('../config');var NODELOAD_CONFIG=config.NODELOAD_CONFIG;var HTTP_SERVER=require('../http').HTTP_SERVER;} var REPORT_MANAGER=exports.REPORT_MANAGER=new ReportGroup();NODELOAD_CONFIG.on('apply',function(){REPORT_MANAGER.refreshIntervalMs=REPORT_MANAGER.refreshIntervalMs||NODELOAD_CONFIG.AJAX_REFRESH_INTERVAL_MS;REPORT_MANAGER.setLoggingEnabled(NODELOAD_CONFIG.LOGS_ENABLED);});HTTP_SERVER.addRoute('^/$',function(url,req,res){var html=REPORT_MANAGER.getHtml();res.writeHead(200,{"Content-Type":"text/html","Content-Length":html.length});res.write(html);res.end();});HTTP_SERVER.addRoute('^/reports$',function(url,req,res){var json=JSON.stringify(REPORT_MANAGER.reports);res.writeHead(200,{"Content-Type":"application/json","Content-Length":json.length});res.write(json);res.end();});var BUILD_AS_SINGLE_FILE;if(!BUILD_AS_SINGLE_FILE){var child_process=require('child_process');}