Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add Microsoft Teams Alert Transport (#5023)
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* LibreNMS | ||
* | ||
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@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. Please see LICENSE.txt at the top level of | ||
* the source code distribution for details. | ||
*/ | ||
|
||
$url = $opts['url']; | ||
$color = ($obj['state'] == 0 ? '#00FF00' : '#FF0000'); | ||
$data = array( | ||
'title' => ($obj['name'] ? $obj['name'] . ' on ' . $obj['hostname'] : $obj['title']) , | ||
'themeColor' => $color , | ||
'text' => strip_tags($obj['msg']) | ||
); | ||
$curl = curl_init(); | ||
set_curl_proxy($curl); | ||
curl_setopt($curl, CURLOPT_URL, $url); | ||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($curl, CURLOPT_HTTPHEADER, array( | ||
'Content-type' => 'application/json', | ||
'Expect:' | ||
)); | ||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); | ||
$ret = curl_exec($curl); | ||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE); | ||
|
||
if ($code != 200) { | ||
var_dump("Microsoft Teams returned Error, retry later"); | ||
return false; | ||
} | ||
|
||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSERT INTO config VALUES ('','alert.transports.msteams.url','','','Microsoft Teams Webhook URL','alerting',0, 'transports', 0, 0, 0); |