溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

zabbix報(bào)警方式

發(fā)布時(shí)間:2020-07-20 10:55:38 來(lái)源:網(wǎng)絡(luò) 閱讀:734 作者:itstrong 欄目:安全技術(shù)

1、郵件報(bào)警

使用mutt工具,腳本:

echo "$3" | mutt -s "$2" $1


注:python腳本可參考:http://strongit.github.io/2016/05/01/zabbix-email/


2、短信報(bào)警

python腳本調(diào)用短信接口:

# -*- coding: utf-8 -*-"""    send_sms_notify~~~~~~~~~~~~~~~

   調(diào)用短信網(wǎng)關(guān)接口發(fā)送告警短信。"""import sys
import json
import requests


SMS_GATE_URL = '短信網(wǎng)關(guān)接口'def send_sms_notify(to, params):
    data = {'to': to,'type': 'warn_notify','params': params
    }
    headers = {'Content-Type': 'application/json'}
    requests.post(SMS_GATE_URL, data=json.dumps(data), headers=headers)if __name__ == '__main__':if not len(sys.argv) == 4:
        print 'Usage: python send_sms_notify.py "phone" "ip" "host" "msg"'sys.exit(-1)

    to = sys.argv[1]
    params = {'ip': sys.argv[2],'host': sys.argv[2],'msg': sys.argv[3]
    }
    send_sms_notify(to, params)

3、微信報(bào)警

git地址:https://github.com/strongit/WeiXin-Private-API  php寫的,親測(cè)。

python腳本:

import sys
import json
import urllib2
import requests

CorpID = "*******"Secret = "密鑰"Access_token_url = "https://**api.weixin.qq.com/*******"req_token = urllib2.Request(Access_token_url)
response = urllib2.urlopen(req_token)
access_token = json.load(response)['access_token']
post_url = "https://**8api.weixin.qq.com/******"%access_token

def send_wechat(msg):
    data = {               "touser": "@all",               "toparty": "2",               "totag": " ",               "msgtype": "text",               "agentid": 1,               "text": {                   "content": msg
               },               "safe":"0"}

    headers = {'Connection': 'keep-alive','Content-Type': 'application/json; charset=utf-8'}        
            
    requests.post(post_url,data=json.dumps(data),headers=headers)if __name__ == '__main__':if not len(sys.argv) == 4:
        print "Usage: python wechat.py 'wechat_id' 'title' 'context'"sys.exit(-1)

    wechat = sys.argv[1]
    title = sys.argv[2]
    msg = sys.argv[3]

    send_wechat(msg)

4、電話報(bào)警

還未用到

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI