Permalink
Browse files

Remove ICMP poller

Nobody can make the ICMP poller to work, for a good reason:
The ICMP poller requires Uptime to be launched with root
permissions to work. This is too much to ask.
  • Loading branch information...
1 parent 1c65756 commit 7a76ef8b283c2d92780acab23f535027696cebe8 @fzaninotto committed Jul 21, 2013
Showing with 1 addition and 104 deletions.
  1. +1 −0 CHANGELOG.md
  2. +0 −103 lib/pollers/icmp/icmpPoller.js
  3. +0 −1 lib/pollers/pollerCollection.js
View
@@ -4,6 +4,7 @@ Uptime Changelog
To be released
--------------
+* Remove ICMP poller as it requires Uptime to be launched with root permissions to work
* Add basicAuth plugin to restrict access to the API and dashboard apps using Basic Authentication
* Upgrade moment.js to version 2.1
* Add httpOptions plugin to allow setting custom headers or HTTP options to a check
@@ -1,103 +0,0 @@
-/**
- * Module dependencies.
- */
-
-var util = require('util');
-var dns = require('dns');
-var net = require('net');
-var ping = require('net-ping');
-var BasePoller = require ('../basePoller');
-
-/**
- * ICMP Poller, to check servers via ping
- *
- * @param {Mixed} Poller Target (e.g. URL)
- * @param {Number} Poller timeout in milliseconds. Without response before this duration, the poller stops and executes the error callback.
- * @param {Function} Error/success callback
- * @api public
- */
-function IcmpPoller(target, timeout, callback) {
- this.target = target;
- this.timeout = timeout || 5000;
- this.callback = callback;
- this.isDebugEnabled = false;
- this.initialize();
-}
-
-util.inherits(IcmpPoller, BasePoller);
-
-IcmpPoller.type = 'icmp';
-
-IcmpPoller.validateTarget = function(target) {
- var reg = new RegExp('icmp:\/\/(.*)');
- return reg.test(target);
-};
-
-/**
- * Initializer method
- *
- * @api public
- */
-IcmpPoller.prototype.initialize = function() {
- var reg = new RegExp('icmp:\/\/(.*)');
-
- if(!reg.test(this.target)) {
- console.log(this.target + ' does not seem to be a valid ICMP URL');
- }
-
- this.target = reg.exec(this.target)[1];
-
- this.session = ping.createSession({
- networkProtocol: ping.NetworkProtocol.IPV4,
- timeout: this.timeout
- });
-};
-
-/**
- * Launch the actual polling
- *
- * @api public
- */
-IcmpPoller.prototype.poll = function() {
- IcmpPoller.super_.prototype.poll.call(this);
-
- if(net.isIP(this.target) == 0) {
- var icmp = this;
-
- dns.lookup(this.target, function(error, address, family) {
- if (error) {
- icmp.onErrorCallback(error);
- } else {
- icmp.session.pingHost(address, icmp.onResponseCallback.bind(icmp));
- }
- });
- } else {
- this.session.pingHost(this.target, this.onResponseCallback.bind(this));
- }
-};
-
-/**
- * Response callback
- * @api private
- */
-IcmpPoller.prototype.onResponseCallback = function(error, target) {
- this.timer.stop();
-
- if(error) {
- this.onErrorCallback(error);
- } else {
- this.callback(null, this.getTime());
- }
-};
-
-/**
- * Error callback
- * @api private
- */
-IcmpPoller.prototype.onErrorCallback = function(err) {
- this.timer.stop();
- this.debug(this.getTime() + "ms - Got error: " + err.message);
- this.callback(err, this.getTime());
-};
-
-module.exports = IcmpPoller;
@@ -6,7 +6,6 @@ var PollerCollection = function(pollers) {
PollerCollection.prototype.addDefaultPollers = function() {
this.add(require('./http/httpPoller.js'));
this.add(require('./https/httpsPoller.js'));
- this.add(require('./icmp/icmpPoller.js'));
this.add(require('./udp/udpPoller.js'));
};

0 comments on commit 7a76ef8

Please sign in to comment.