diff --git a/includes/alerts/transport.pushover.php b/includes/alerts/transport.pushover.php index 7d49e10b98..6495ae5515 100644 --- a/includes/alerts/transport.pushover.php +++ b/includes/alerts/transport.pushover.php @@ -39,20 +39,46 @@ foreach( $opts as $api ) { $data = array(); $data['token'] = $api['appkey']; $data['user'] = $api['userkey']; - if( $obj['severity'] == "critical" ) { - if( !empty($api['sound_critical']) ) { - $data['sound'] = $api['sound_critical']; - } - $severity = "Critical"; - $data['priority'] = 1; - } - elseif( $obj['severity'] == "warning" ) { - $severity = "Warning"; - $data['priority'] = 0; - } - $curl = curl_init(); - $data['title'] = $severity." - ".$obj['hostname']; - $data['message'] = $obj['name']; + 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; 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);