mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #3852 from pblasquez/patch-7
Change slack format to attachment style
This commit is contained in:
@ -268,7 +268,7 @@ $config['alert']['transports']['irc'] = true;
|
||||
|
||||
> You can configure these options within the WebUI now, please avoid setting these options within config.php
|
||||
|
||||
The Slack transport will POST the alert message to your Slack Incoming WebHook, you are able to specify multiple webhooks along with the relevant options to go with it. All options are optional, the only required value is for url, without this then no call to Slack will be made. Below is an example of how to send alerts to two channels with different customised options:
|
||||
The Slack transport will POST the alert message to your Slack Incoming WebHook using the [attachments](https://api.slack.com/docs/message-attachments) option, you are able to specify multiple webhooks along with the relevant options to go with it. Simple html tags are stripped from the message. All options are optional, the only required value is for url, without this then no call to Slack will be made. Below is an example of how to send alerts to two channels with different customised options:
|
||||
|
||||
~~
|
||||
```php
|
||||
|
@ -24,8 +24,17 @@
|
||||
foreach( $opts as $tmp_api ) {
|
||||
$host = $tmp_api['url'];
|
||||
$curl = curl_init();
|
||||
$slack_msg = strip_tags($obj['msg']);
|
||||
$color = ($obj['state'] == 0 ? '#00FF00' : '#FF0000');
|
||||
$data = array(
|
||||
'text' => $obj['msg'],
|
||||
'attachments' => array(
|
||||
0 => array(
|
||||
'fallback' => $slack_msg,
|
||||
'color' => $color,
|
||||
'title' => $obj['title'],
|
||||
'text' => $slack_msg,
|
||||
)
|
||||
),
|
||||
'channel' => $tmp_api['channel'],
|
||||
'username' => $tmp_api['username'],
|
||||
'icon_url' => $tmp_api['icon_url'],
|
||||
|
Reference in New Issue
Block a user