• zabbix3.4.x添加短信报警


    一、修改zabbix_server.conf

    #vi /etc/zabbix/zabbix_server.conf
    去掉注释:
    
    ### Option: AlertScriptsPath
    #       Full path to location of custom alert scripts.
    #       Default depends on compilation options.
    #
    # Mandatory: no
    # Default:
    # AlertScriptsPath=${datadir}/zabbix/alertscripts
    
    AlertScriptsPath=/usr/lib/zabbix/alertscripts

    二、编写脚本上传到上面的目录

    #!/usr/bin/env python
    # *-* coding:utf-8 *-*
    import hashlib,urllib,urllib2,sys,time,requests
    
    class REST_API:
        def __init__(self):
            self.ip = '118.190.103.79'
            self.user='ld1978'
            self.password = '135246'
            # self.md5_pwd = hashlib.md5(self.password.encode('utf-8')).hexdigest()
            # self.author = base64.b64encode(self.user + ':' + self.md5_pwd)
    
        def msm_sign(self):
    
            return hashlib.md5( "%s%s%s"%(self.user,self.password,time.strftime("%Y%m%d%H%M%S", time.localtime()))).hexdigest()
        def req_url(self,phone, content):
            content = '%s 【glp-zabbix】'%content
    
            data = {
                'userid': 3442,
                'timestamp':time.strftime("%Y%m%d%H%M%S", time.localtime()),
                'content': content,  # yes;内容
                'mobile': phone,  # yes;现只支持sms
                'sendTime': '',  # no;定时发送时间
                'extno': '',
                'sign':self.msm_sign() #sign
            }
    
            #data_re = urllib.urlencode(data)
            url = 'http://%s/v2sms.aspx?action=send' % (self.ip)
            response = requests.get(url, params=data)
    
            data = response.text
    
    
    
            if(data.find('Success') >=0):
                print "Success"
            else:
                print "Faild"
    
    
    
    if __name__ == '__main__':
    
        sms = REST_API()
        send_to = str(sys.argv[1])
        message = str(sys.argv[2])
        print type(send_to)
        sms.msm_sign()
        # 多个号码用,隔开像 189
        sms.req_url(send_to,message)
    sendsms.py

    三、在Administration->Media types下新增Media,并增加两个参数

    四、增加Action

  • 相关阅读:
    ASP.NET Core项目解读之常用概念方法
    ASP.NET Core项目解读之appsettings.json
    ASP.NET Core项目解读之wwwroot
    ASP.NET Core项目解读之launchSettings.json
    理解.NET5
    搜索引擎学习(四)中文分词器
    搜索引擎学习(五)Lucene操作索引
    搜索引擎学习(三)Lucene查询索引
    搜索引擎学习(二)Lucene创建索引
    搜索引擎学习(一)初识Lucene
  • 原文地址:https://www.cnblogs.com/ld1977/p/9402588.html
Copyright © 2020-2023  润新知