Permalink
Browse files

0.0.3

  • Loading branch information...
1 parent caa4f58 commit 7ad2f30e004a869a6f3c7a9ebe5a54c405b75781 @3rd-Eden committed Apr 4, 2012
Showing with 29 additions and 25 deletions.
  1. +12 −10 lib/cluster.exception.js
  2. +16 −14 lib/history.js
  3. +1 −1 package.json
@@ -1,3 +1,5 @@
+"use strict";
+
/*!
* cluster.exception
* Copyright(c) 2011 > Future Arnout Kazemier <info@3rd-Eden.com>
@@ -19,7 +21,7 @@ var os = require('os')
/**
* Cluster.exception allows you to receive emails of uncaught exceptions in your
- * node.js applications. Not only the error is send but also a history of the
+ * node.js applications. Not only the error is send but also a history of the
* `console` statements, memory, cpu, etc, etc, the whole chabang. This might
* give you a better context on why the error was occuring in the first place.
*
@@ -31,7 +33,7 @@ var os = require('os')
* @api public
*/
-exports = module.exports = function exception (options) {
+exports = module.exports = function exceptions (options) {
options = options || {};
var log = {}
@@ -43,7 +45,7 @@ exports = module.exports = function exception (options) {
, history;
if (!options.to) {
- throw Error("Please specify a e-mail address for the cluster.exception plugin");
+ throw new Error("Please specify a e-mail address for the cluster.exception plugin");
}
Array.prototype.push[Array.isArray(options.to)
@@ -57,7 +59,7 @@ exports = module.exports = function exception (options) {
*
* @param {Error} exception The unchaught exception.
* @param {Cluster} instance A reference to the cluster object.
- *
+ *
* @returns {Object} details about the exception.
* @api private
*/
@@ -148,7 +150,7 @@ exports = module.exports = function exception (options) {
details.cluster['master replacement'] = true;
return details;
- };
+ }
/**
* Simple string based replaces / template system.
@@ -166,7 +168,7 @@ exports = module.exports = function exception (options) {
}
return string;
- };
+ }
/**
* Override the console object and capture the messages so we
@@ -248,10 +250,10 @@ exports = module.exports = function exception (options) {
// report exception
if (instance.master) {
// cluster with server
- instance.master.call('workerException', error)
+ instance.master.call('workerException', error);
} else {
// cluster without server
- instance.call('workerException', error)
+ instance.call('workerException', error);
}
// exit
@@ -260,7 +262,7 @@ exports = module.exports = function exception (options) {
});
}
});
- };
+ }
// Make sure that we also have it called inside the workers
// because we want to gather addional data.
@@ -272,4 +274,4 @@ exports = module.exports = function exception (options) {
* Library version.
*/
-exports.version = '0.0.2';
+exports.version = '0.0.3';
View
@@ -1,3 +1,5 @@
+"use strict";
+
/*!
* cluster.exception
* Copyright(c) 2011 Arnout Kazemier <info@3rd-Eden.com>
@@ -72,12 +74,12 @@ History.prototype.update = function update () {
this.data[key].push( this.stats[key]() );
if (this.data[key].length > this.limit) this.data[key].shift();
- };
+ }
};
/**
* Exports the gathered history as a `Google chart` graph.
- *
+ *
* @param {String} key The stat that needs to be converted to a chart
*
* @returns {Object} Key => url
@@ -103,13 +105,13 @@ History.prototype.toGraph = function toGraph (key) {
while (i--) points.push(History.bytesToMb(data[i][type]));
tmp.sorted = points.sort(function sortTimes (a,b) {
- return b - a
+ return b - a;
});
tmp.high = tmp.sorted[0];
result['mem_' + type] = base + 't:' + points.join(',') + '&chtt=Process+memory+usage+'+ type + '+(MB)' +
- '&chds=0,' + tmp.high +
+ '&chds=0,' + tmp.high +
'&chxr=0,0,' + tmp.high +'&chxt=r';
}
});
@@ -120,13 +122,13 @@ History.prototype.toGraph = function toGraph (key) {
while (i--) points.push(this.totalmem - History.bytesToMb(data[i]));
tmp.sorted = points.sort(function sortTimes (a,b) {
- return b - a
+ return b - a;
});
tmp.high = tmp.sorted[0];
result['mem_' + key] = base + 't:' + points.join(',') + '&chtt=Total+memory+(limit+'+ this.totalmem+'+MB)' +
- '&chds=0,' + this.totalmem +
+ '&chds=0,' + this.totalmem +
'&chxr=0,0,' + this.totalmem +'&chxt=r';
}
break;
@@ -167,24 +169,24 @@ History.prototype.toGraph = function toGraph (key) {
tmp.highest = 0;
for (time in times) {
- if( time == 'nice' || time == 'irq') continue;
+ if (time === 'nice' || time === 'irq') continue;
tmp.sorted = times[time].sort(function sortTimes (a,b) {
- return b - a
+ return b - a;
});
tmp.high = tmp.sorted[0];
tmp.low = tmp.sorted[ tmp.sorted.length - 1 ];
- tmp.low = tmp.low == tmp.high ? 0 : tmp.low;
+ tmp.low = tmp.low === tmp.high ? 0 : tmp.low;
tmp.lowest = tmp.lowest > tmp.low ? tmp.low : tmp.lowest;
tmp.highest = tmp.highest > tmp.high ? tmp.highest : tmp.high;
- tmp.counts.push(times[time].join(','))
+ tmp.counts.push(times[time].join(','));
tmp.labels.push(time);
}
- result['cpu_' + cpu ] = url + '&chd=t:' + tmp.counts.join('|') + '&chdl=' + tmp.labels.join('|') +
+ result['cpu_' + cpu ] = url + '&chd=t:' + tmp.counts.join('|') + '&chdl=' + tmp.labels.join('|') +
'&chco=DA3B15,F7A10A,4582E7,579F3A,9100E5&chxt=r&chdlp=t&chtt=' + cpu.split(' ').join('+') +
'&chds=' + tmp.lowest + ',' + tmp.highest +
'&chxr=0,' + tmp.lowest + ',' + tmp.highest;
@@ -197,7 +199,7 @@ History.prototype.toGraph = function toGraph (key) {
'0': 'Server load 1 minute interval'
, '1': 'Server load 5 minutes interval'
, '2': 'Server load 15 minutes interval'
- }
+ };
Object.keys(tmp.labels).forEach(function (key) {
points = [];
@@ -208,13 +210,13 @@ History.prototype.toGraph = function toGraph (key) {
}
tmp.sorted = points.sort(function sortTimes (a,b) {
- return b - a
+ return b - a;
});
tmp.high = tmp.sorted[0];
result['load_' + key] = base + 't:' + points.join(',') + '&chtt='+ tmp.labels[key] +
- '&chds=0,' + tmp.high +
+ '&chds=0,' + tmp.high +
'&chxr=0,0,' + tmp.high +'&chxt=r';
});
}
View
@@ -1,6 +1,6 @@
{
"name": "cluster.exception"
- , "version": "0.0.2"
+ , "version": "0.0.3"
, "description": "Exception handling for cluster.js"
, "keywords": ["cluster", "mail", "exception", "error"]
, "author": "Arnout Kazemier <info@3rd-Eden.com>"

0 comments on commit 7ad2f30

Please sign in to comment.