Permalink
Browse files

adding alert threshold

  • Loading branch information...
1 parent d18fccc commit 79601ac8e9a8c518e6ecec7e23942e2bf48058db @greggythefly greggythefly committed with Jan 10, 2013
Showing with 16 additions and 0 deletions.
  1. +16 −0 models/check.js
View
@@ -12,13 +12,16 @@ var CheckMonthlyStat = require('../models/checkMonthlyStat');
var CheckYearlyStat = require('../models/checkYearlyStat');
var Tag = require('../models/tag');
+var statusCounter = 0;
+
// main model
var Check = new Schema({
name : String,
type : String,
url : String,
interval : { type: Number, default: 60000 }, // interval between two pings
maxTime : { type: Number, default: 1500 }, // time under which a ping is considered responsive
+ nbErrors : { type: Number, default: 1 }, // nb of errors from which to trigger a new CheckEvent
tags : [String],
lastChanged : Date,
firstTested : Date,
@@ -77,7 +80,20 @@ Check.methods.setLastTest = function(status, time, error) {
this.firstTested = now;
}
this.lastTested = now;
+
+ // First down check or First up check
if (this.isUp != status) {
+
+ statusCounter = 1;
+
+ // more up checks
+ } else {
+
+ statusCounter++;
+
+ }
+
+ if (statusCounter>2) {
var event = new CheckEvent({
timestamp: now,
check: this,

0 comments on commit 79601ac

Please sign in to comment.