Permalink
Browse files

Add a way to pause polling for a check.

Model-only for now, no GUI yet.
  • Loading branch information...
1 parent 712e865 commit ccb4aa1ecc65bbe11a10d2c4f0bade55cfaa23bf @fzaninotto committed Apr 19, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 models/check.js
View
@@ -21,6 +21,7 @@ var Check = new Schema({
lastChanged : Date,
lastTested : Date,
isUp : Boolean,
+ isPaused : { type:Boolean, default: false },
uptime : { type: Number, default: 0 },
downtime : { type: Number, default: 0 },
qos : {},
@@ -52,7 +53,13 @@ Check.methods.removeStats = function(callback) {
};
Check.methods.needsPoll = function() {
- return !this.lastTested || (Date.now() - this.lastTested.getTime()) > (this.interval || 60000);
+ if (this.isPaused) return false;
+ if (!this.lastTested) return true;
+ return (Date.now() - this.lastTested.getTime()) > (this.interval || 60000);
+}
+
+Check.methods.togglePause = function() {
+ this.isPaused = !this.isPaused;
}
Check.methods.setLastTest = function(status, time) {
@@ -258,9 +265,7 @@ Check.statics.callForChecksNeedingPoll = function(callback) {
}
Check.statics.needingPoll = function() {
- return this.$where(function() {
- return !this.lastTested || (Date.now() - this.lastTested.getTime()) > (this.interval || 60000);
- });
+ return this.$where(Check.methods.needsPoll);
}
Check.statics.updateAllQos = function(callback) {

0 comments on commit ccb4aa1

Please sign in to comment.