Skip to content

Instantly share code, notes, and snippets.

@modulexcite
Forked from xphyr/index.js
Last active August 29, 2015 14:23
Show Gist options
  • Save modulexcite/f39e5e4ab6034def5091 to your computer and use it in GitHub Desktop.
Save modulexcite/f39e5e4ab6034def5091 to your computer and use it in GitHub Desktop.
/**
* Pushover plugin for the uptime project - https://github.com/fzaninotto/uptime
* Thanks to DMathieu for the Campfire plugin which I basically hacked up to make this
* work: https://gist.github.com/dmathieu/5592418
*
* This index.js files goes to a directory `plugins/pushover` in your installation of uptime.
*
* Notifies all events (up, down, paused, restarted) to pushover
*
* This plugin has a dependency on `pushover-notifications`.
* Add this to the "dependencies" object in your `package.json` file :
*
* "pushover-notifications": "0.1.5"
*
*
* To enable the plugin, add the following line to the plugins section of your config file
* plugins:
* - ./plugins/pushover
*
* Example configuration
*
* pushover:
* token: 8973lkhjfdso8y3 # Authentication token from pushover for app
* user: 09r4ljfdso98r # This is the user token you want to send to
*
* event:
* up: true
* down: true
* paused: false
* restarted: false
*/
var config = require('config').pushover;
var CheckEvent = require('../../models/checkEvent');
var pushover = require('pushover-notifications');
exports.initWebApp = function() {
CheckEvent.on('afterInsert', function(checkEvent) {
if (!config.event[checkEvent.message])
return;
checkEvent.findCheck(function(err, check) {
if (err)
return console.error(err);
var msg = {
message: "The application " + check.name + " just went to status " + checkEvent.message,
title: "Uptime Status",
sound: 'magic', // optional
priority: 1 // optional
};
var push = new pushover({
token: config.token
});
push.user = config.user;
push.send( msg, function( err, result ) {
if ( err ) {
throw err;
}
console.log( result );
});
});
});
console.log('Enabled Pushover notifications');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment