Created Pushover transport, requires testing
Moved print_r references to top for debug
Modified Pushover transport, testing required
Pushover transport, fixed syntax issue
Pushover transport, fixed another syntax issue
Pushover transport, added debug
Pushover transport, updated message code
Pushover transport, debug
Pushover transport, testing new code
Pushover transport, adding more parameters
and adding debug parameters
Pushover transport, added severity level support
Pushover transport, modified severity level code
Pushover transport, updated severity code
Pushover transport, debugging severity level
Pushover transport, more debugging
Pushover transport, debugging sound
Pushover transport, fixed sound syntax issue
Pushover transport, debugging sound API
Pushover transport, adjusted sound code
Updated contributors file to add myself
Updated Alerting doc to include Pushover
Pushover transport, modified code
Pushover transport, fixed syntax error
Pushover transport, removed debug code
Ready for deployment
Pushover transport, updated copyright
2015-06-01 21:41:55 +10:00
|
|
|
/* Copyright (C) 2015 James Campbell <neokjames@gmail.com>
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pushover API Transport
|
|
|
|
* @author neokjames <neokjames@gmail.com>
|
|
|
|
* @copyright 2015 neokjames, f0o, LibreNMS
|
|
|
|
* @license GPL
|
|
|
|
* @package LibreNMS
|
|
|
|
* @subpackage Alerts
|
|
|
|
*/
|
|
|
|
|
|
|
|
foreach( $opts as $api ) {
|
|
|
|
$data = array();
|
|
|
|
$data['token'] = $api['appkey'];
|
|
|
|
$data['user'] = $api['userkey'];
|
2015-06-03 21:03:27 +10:00
|
|
|
switch( $obj['severity'] ) {
|
|
|
|
case "critical":
|
|
|
|
$severity = "Critical";
|
|
|
|
$data['priority'] = 1;
|
|
|
|
if( !empty( $api['sound_critical'] ) ) {
|
|
|
|
$data['sound'] = $api['sound_critical'];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "warning":
|
|
|
|
$severity = "Warning";
|
|
|
|
$data['priority'] = 0;
|
|
|
|
if( !empty( $api['sound_warning'] ) ) {
|
|
|
|
$data['sound'] = $api['sound_warning'];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$curl = curl_init();
|
|
|
|
switch( $obj['state'] ) {
|
|
|
|
case 0:
|
|
|
|
$title_text = "OK";
|
|
|
|
if( !empty( $api['sound_ok'] ) ) {
|
|
|
|
$data['sound'] = $api['sound_ok'];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$title_text = $severity;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
$title_text = "Acknowledged";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$data['title'] = $title_text." - ".$obj['hostname']." - ".$obj['name'];
|
|
|
|
$message_text = "Timestamp: ".$obj['timestamp'];
|
|
|
|
if( !empty( $obj['faults'] ) ) {
|
|
|
|
$message_text .= "\n\nFaults:\n";
|
|
|
|
foreach($obj['faults'] as $k => $faults) {
|
|
|
|
$message_text .= "#".$k." ".$faults['string']."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data['message'] = $message_text;
|
Created Pushover transport, requires testing
Moved print_r references to top for debug
Modified Pushover transport, testing required
Pushover transport, fixed syntax issue
Pushover transport, fixed another syntax issue
Pushover transport, added debug
Pushover transport, updated message code
Pushover transport, debug
Pushover transport, testing new code
Pushover transport, adding more parameters
and adding debug parameters
Pushover transport, added severity level support
Pushover transport, modified severity level code
Pushover transport, updated severity code
Pushover transport, debugging severity level
Pushover transport, more debugging
Pushover transport, debugging sound
Pushover transport, fixed sound syntax issue
Pushover transport, debugging sound API
Pushover transport, adjusted sound code
Updated contributors file to add myself
Updated Alerting doc to include Pushover
Pushover transport, modified code
Pushover transport, fixed syntax error
Pushover transport, removed debug code
Ready for deployment
Pushover transport, updated copyright
2015-06-01 21:41:55 +10:00
|
|
|
curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json');
|
|
|
|
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
|
|
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
|
$ret = curl_exec($curl);
|
|
|
|
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|
|
|
if( $code != 200 ) {
|
|
|
|
var_dump("Pushover returned error"); //FIXME: proper debugging
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|