Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Simple Plugin for "Uptime" that send alerts via Pushover. I am not a Node hacker ... I barely understand why this code works .... but it does. I have not tried it with multiple users yet, so dont know if it will work to do multiple notifications. Let me know if you try it.

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 59 60 61 62 63 64 65 66 67 68 69 70
/**
* 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
Something went wrong with that request. Please try again.