From a2a1174033878687e0e6a9dcd424ae10683af63d Mon Sep 17 00:00:00 2001 From: Aldemir Akpinar Date: Thu, 20 Jul 2017 22:09:33 +0300 Subject: [PATCH] Added log events for jira transport (#7059) * Added log events for jira transport * Resolve jira ticket bug for normal alerts --- includes/alerts/transport.jira.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/alerts/transport.jira.php b/includes/alerts/transport.jira.php index c5152930ee..f891c88b6e 100644 --- a/includes/alerts/transport.jira.php +++ b/includes/alerts/transport.jira.php @@ -22,10 +22,11 @@ */ // Don't create tickets for resolutions -if($obj['status'] == 0 && $obj['msg'] != 'This is a test alert') { +if($obj['severity'] == 'recovery' && $obj['msg'] != 'This is a test alert') { return True; } +$device = device_by_id_cache($obj['device_id']); // for event logging $username = $opts['username']; $password = $opts['password']; @@ -35,7 +36,7 @@ $details = "Librenms alert for: ".$obj['hostname']; $description = $obj['msg']; $url = $opts['url'].'/rest/api/latest/issue'; $curl = curl_init(); - + $data = array("project" => array("key" => $prjkey), "summary" => $details, "description" => $description, @@ -58,7 +59,10 @@ curl_setopt($curl, CURLOPT_POSTFIELDS, $datastring); $ret = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if( $code == 200 ) { - return true; + $jiraout = json_decode($ret, true); + d_echo("Created jira issue ".$jiraout['key']." for ".$device); + return true; } else { + d_echo("Jira connection error: ".serialize($ret)); return false; }