Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:zabbix [2024/09/16 19:25] – created 5.152.82.90wiki:zabbix [2025/02/11 16:11] (current) – [Slack Notification] 5.152.82.90
Line 49: Line 49:
     connectionState = 0     connectionState = 0
 print(connectionState) print(connectionState)
 +</code>
 +=====Slack Notification=====
 +<code bash notify_slack.sh>
 +#!/bin/bash
 +
 +url='https://hooks.slack.com/services/xxxxxxxx/xxxxxxx/xxxxxxxxxxxx'
 +username='Zabbix'
 +
 +to="$1"
 +subject="$2"
 +message="$3"
 +
 +recoversub='^RECOVER(Y|ED)?$|^OK$|^Resolved.*'
 +problemsub='^PROBLEM.*|^Problem.*'
 +
 +if [[ "$subject" =~ $recoversub ]]; then
 +    emoji=':white_check_mark:'
 +    color='#00ff40'
 +elif [[ "$subject" =~ $problemsub ]]; then
 +    emoji=':exclamation:'
 +    color='#ff0a0a'
 +else
 +    emoji=':question:'
 +    color='#0ac2ff'
 +fi
 +
 +payload="payload={\"channel\": \"${to}\", \"username\": \"${username}\", \"attachments\": [{\"fallback\": \"${subject}\", \"title\": \"${subject}\", \"text\": \"${message}\", \"color\": \"${color}\"}], \"icon_emoji\": \"${emoji}\"}"
 +
 +return=$(curl -s -m 5 --data-urlencode "${payload}" "$url")
 +
 +if [[ "$return" != 'ok' ]]; then
 +    >&2 echo "$return"
 +    exit 1
 +fi
 +</code>
 +==Message Templates==
 +<code>
 +Problem:  {EVENT.NAME} Host: {HOST.NAME}\nTime: {EVENT.TIME} on {EVENT.DATE}\n{EVENT.OPDATA}
 +Resolved: {EVENT.NAME} Host: {HOST.NAME}\nDuration: {EVENT.DURATION}\n{EVENT.OPDATA}
 </code> </code>
Navigation
Print/export
QR Code
QR Code wiki:zabbix (generated for current page)