Ad Widget

Collapse

Creating Slack Webhook media type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmroberts
    Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Jan 2017
    • 73

    #1

    Creating Slack Webhook media type

    Can someone explain in some more detail setting up the Slack Webhook media type as explained here (https://www.zabbix.com/documentation.../media/webhook)? We use slack but we use the slack.sh alert script method (see below for code and attached screen shot) that requires individual webhooks for each user/group being sent to. This method sounds promising, but makes no sense to me at all on how its supposed to be implemented.



    Code:
    #!/bin/bash
    to="$1"
    header=$(echo $2)
    alert_type=$(echo $2|cut -d' ' -f1)
    message="$3"
    server=$(echo $2|cut -d' ' -f3)
    username='Zabbix (AWS)'
    url=$(echo $to | cut -d# -f1)
    channel=$(echo $to| cut -d# -f2)
    
    case $alert_type in
        ACKNOWLEDGED)    color="#FFA500";;
        PROBLEM)        color="#E02020";;
        RECOVERED)        color="#20E020";;
    esac
    
    payload="payload={
            \"channel\": \"#${channel}\",
            \"username\": \"${username}\",
            \"attachments\": [
               {
                    \"title\": \"${header}\",
                    \"fallback\": \"${message}\",
                    \"text\": \"${message}\",
                    \"color\": \"${color}\",
                    \"mrkdwn_in\": [ \"text\" ]
               }
            ] }"
    
    /usr/bin/curl -m 5 --data-urlencode "${payload}" $url
Working...