Skip to content

Commit

Permalink
Add CheckEvent migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Apr 20, 2012
1 parent 8f7968c commit 7208e06
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
33 changes: 33 additions & 0 deletions fixtures/fixEvents.js
Original file line number Diff line number Diff line change
@@ -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.