ZabbixからSlackに通知を送る

Standard

関連かんれんリソース:
https://github.com/ericoc/zabbix-slack-alertscript
を使います。基本的きほんてきにはこちらのreadme通りに設定せっていします。

Slack側の設定
https://yemaosheng.slack.com/services/new/incoming-webhook
からincoming web hookを作成さくせいし、”Webhook URL”を確認かくにんしておきます。

テストURL:

curl -X POST --data-urlencode 'payload={"channel": "#alert", "username": "webhookbot", "text": "This is posted to #alert and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/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

SMS and phone call from Zabbix using Twilio

Standard


vim /etc/zabbix/alert.d/zabbix-alert-sms-twilio.sh

#!/usr/bin/python
import sys
from twilio.rest import TwilioRestClient
 
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "AC0axxxxxxxxxxxxxxxxxxxx296ae"
auth_token  = "93e4xxxxxxxxxxxxxxxxxxx63e9"
client = TwilioRestClient(account_sid, auth_token)
 
message = client.messages.create(body=sys.argv[2],
    to=sys.argv[1],
    from_="+16572338xx8") # Replace with your Twilio number
print message.sid

vim /etc/zabbix/alert.d/zabbix-alert-call-twilio.sh

#!/usr/bin/python
import sys
import urllib
from twilio.rest import TwilioRestClient
 
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "AC0axxxxxxxxxxxxxxxxxxxx296ae"
auth_token  = "93e4xxxxxxxxxxxxxxxxxxx63e9"
client = TwilioRestClient(account_sid, auth_token)
 
TwiML="http://yemaosheng.com/getTwiML.php?say="+urllib.quote(sys.argv[2])
 
call = client.calls.create(to=sys.argv[1],
    from_="+16572338xx8",
    url=TwiML)
print call.sid

vim /var/www/html/getTwiML.php

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="woman"><?php echo htmlspecialchars($_GET['say']); ?></Say>
    <Hangup/>
</Response>