Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Campfire plugin for the uptime project - https://github.com/fzaninotto/uptime

View index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/**
* Campfire plugin for the uptime project - https://github.com/fzaninotto/uptime
*
* This index.js files goes to a directory `plugins/campfire` in your installation of uptime.
*
* Notifies all events (up, down, paused, restarted) to campfire
*
* This plugin has a dependency on `ranger`.
* Add this to the "dependencies" object in your `package.json` file :
*
* "ranger": "0.2.4"
*
*
* To enable the plugin, call init() from plugins/index.js
* exports.init = function() {
* require('./campfire').init();
* }
*
* Example configuration
*
* campfire:
* room: 1 # Must be the room id, not it's name
* account: uptime
* token: abcd
*
* event:
* up: true
* down: true
* paused: false
* restarted: false
*/
var config = require('config').campfire;
var CheckEvent = require('../../models/checkEvent');
var ranger = require('ranger');
 
exports.init = function() {
 
CheckEvent.on('afterInsert', function(checkEvent) {
if (!config.event[checkEvent.message])
return;
 
checkEvent.findCheck(function(err, check) {
if (err)
return console.error(err);
 
var message = "[Uptime] The application " + check.name + " just went to status " + checkEvent.message
var room_id = config.room;
var account = config.account;
var token = config.token;
var client = ranger.createClient(account, token);
 
client.room(room_id, function (room) {
room.speak(message);
});
});
});
console.log('Enabled Campfire notifications');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.