Permalink
Browse files

Add CheckEvent migration script

  • Loading branch information...
1 parent 8f7968c commit 7208e06153dc6d02449a7f9adab87fd71da24474 @fzaninotto committed Apr 20, 2012
Showing with 41 additions and 2 deletions.
  1. +8 −2 CHANGELOG.md
  2. +33 −0 fixtures/fixEvents.js
View
@@ -1,9 +1,10 @@
Uptime Changelog
================
-To be released, V1.2
+To be released, v1.2
--------------------
+* Changed the CheckEvent format for better extensibility (use the fixtures/fixEvents.js fix to migrate existing events)
* Fix polling interval to mimic the behavior of a cron
* Add a way to pause checks in the dashboard GUI, in the API, and in the model
* Split Monitor class and configuration, to fix polling when `autoStartMonitor` is false
@@ -15,4 +16,9 @@ To be released, V1.2
* Add support for HTTPS checks
* Refactor poller class to allow adapter pattern. Opens the door for UDP, FTP, complete page... check types.
-* Removed proxy configuration (now uses environment variables)
+* Removed proxy configuration (now uses environment variables)
+
+2012-03-28, v1.0
+----------------
+
+* Initial version
View
@@ -0,0 +1,33 @@
+var config = require('config').mongodb;
+var mongoose = require('mongoose');
+var Schema = mongoose.Schema;
+
+var CheckEvent = new Schema({
+ timestamp : { type: Date, default: Date.now },
+ check : { type: Schema.ObjectId, ref: 'Check' },
+ tags : [String],
+ message : String,
+ isGoDown : Boolean,
+ details : String,
+ // for error events, more details need to be persisted
+ downtime : Number
+});
+
+mongoose.model('CheckEvent', CheckEvent);
+
+mongoose.connect('mongodb://' + config.user + ':' + config.password + '@' + config.server +'/' + config.database);
+mongoose.connection.on('error', function (err) {
+ console.error('MongoDB error: ' + err.message);
+ console.error('Make sure a mongoDB server is running and accessible by this application')
+});
+
+var Event = mongoose.model('CheckEvent');
+Event.find({ message: { $exists: false }}).each(function(err, event) {
+ if (err) {
+ console.log(err.message);
+ return;
+ }
+ if (!event) process.exit();
+ event.message = event.isGoDown ? 'down' : 'up';
+ event.save();
+})

0 comments on commit 7208e06

Please sign in to comment.