I'm using node as a http server with the following code:
http.createServer(function(req, res) {}).listen(8181);
I'm looking for a simple way to monitor a node js http server from within the same process. For me it would be enough to have a own function which just outputs the current resource usage and connection count as json. For now I don't need deep measuring or real time performance monitoring.
What are the key performance indicators for a node http server and is it possible to get them from node? If yes how? What you think of the folling kpi's:
Just need to know which variables/functions I need to get the data?
Thx I really appreciate your help
You need something like this:
var count = 0;
http.createServer(function(req, res) {
count++;
res.on('finish', function () {
//setTimeout(function () {
count--;
//}, 60000);
}).on('close', function () {
count--;
});
}).listen(8181);
With setTimeout() you can get the active connections in the last 1 minute.
see http://nodejs.org/api/os.html#os_os_cpus for CPU usage
see http://nodejs.org/api/process.html#process_process_memoryusage for memory usage