mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add support for using Markdown for the Ciscospark transport (#10442)
* Add support for using Markdown. Alert templates can be written using Webex Teams (i.e., Spark) Markdown, which makes for some richer alerts. This option defaults to false to maintain Principle of Least Astonishment. * Update Cisco Spark docs. * Mention that Cisco Spark is now called Webex Teams * Add support for Markdown * Refactor text. Do not exceed 80 characters per line. * Refactor code to meet style guidelines. * Remove errant tabs and use spaces instead * Correct type check * Remove use of 'else'
This commit is contained in:
@@ -31,10 +31,15 @@ class Ciscospark extends Transport
|
|||||||
{
|
{
|
||||||
$text = strip_tags($obj['msg']);
|
$text = strip_tags($obj['msg']);
|
||||||
$data = array (
|
$data = array (
|
||||||
'roomId' => $room_id,
|
'roomId' => $room_id
|
||||||
'text' => $text
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$akey = 'text';
|
||||||
|
if ($this->config['use-markdown'] === 'on') {
|
||||||
|
$akey = 'markdown';
|
||||||
|
}
|
||||||
|
$data[$akey] = $text;
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
set_curl_proxy($curl);
|
set_curl_proxy($curl);
|
||||||
curl_setopt($curl, CURLOPT_URL, 'https://api.ciscospark.com/v1/messages');
|
curl_setopt($curl, CURLOPT_URL, 'https://api.ciscospark.com/v1/messages');
|
||||||
@@ -70,6 +75,13 @@ class Ciscospark extends Transport
|
|||||||
'name' => 'room-id',
|
'name' => 'room-id',
|
||||||
'descr' => 'CiscoSpark Room ID',
|
'descr' => 'CiscoSpark Room ID',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'title' => 'Use Markdown?',
|
||||||
|
'name' => 'use-markdown',
|
||||||
|
'descr' => 'Use Markdown when sending the alert',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'default' => false,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'validation' => [
|
'validation' => [
|
||||||
|
@@ -117,10 +117,13 @@ which are then converted to canopsis events.
|
|||||||
| Password | my_password |
|
| Password | my_password |
|
||||||
| Vhost | canopsis |
|
| Vhost | canopsis |
|
||||||
|
|
||||||
## Cisco Spark
|
## Cisco Spark (aka Webex Teams)
|
||||||
|
|
||||||
Cisco Spark. LibreNMS can send alerts to a Cisco Spark room. To make
|
Cisco Spark (now known as Webex Teams). LibreNMS can send alerts to a Cisco
|
||||||
this possible you need to have a RoomID and a token.
|
Spark room. To make this possible you need to have a RoomID and a token.
|
||||||
|
You can also choose to send alerts using Markdown syntax. Enabling this
|
||||||
|
option provides for more richly formatted alerts, but be sure to adjust your
|
||||||
|
alert template to account for the Markdown syntax.
|
||||||
|
|
||||||
For more information about Cisco Spark RoomID and token, take a look here :
|
For more information about Cisco Spark RoomID and token, take a look here :
|
||||||
|
|
||||||
@@ -133,6 +136,7 @@ For more information about Cisco Spark RoomID and token, take a look here :
|
|||||||
| ------ | ------- |
|
| ------ | ------- |
|
||||||
| API Token | ASd23r23edewda |
|
| API Token | ASd23r23edewda |
|
||||||
| RoomID | 34243243251 |
|
| RoomID | 34243243251 |
|
||||||
|
| Use Markdown? | x |
|
||||||
|
|
||||||
## Clickatell
|
## Clickatell
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user