In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Configure Wechat alarms:
Preparation:
Wechat enterprise account
The Enterprise has been paid attention to by the members of the department.
Enterprise has an application that can send messages, an authorized administrator, and can use the application to send messages to members.
The information you need to get
Member account number
Organizational department ID
Apply ID
CorpID and Secret
First, let's log in to WeCom-→ and apply it to Mini Program to create our zabbix alarm.
Click the Mini Program we created to get the corresponding ID information:
Get our corporate corpid:
Add wechat alarm scripts and alarm media to zabbix_server:
Copy the script to the / usr/lib/zabbix/alertscripts default script storage path with any name.
#! / usr/bin/python2.7
# _ * _ coding:utf-8 _ * _
Import requests,sys,json
Import urllib3
Urllib3.disable_warnings ()
Reload (sys)
Sys.setdefaultencoding ('utf-8')
Def GetToken (Corpid,Secret):
Url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
Data = {
"corpid": Corpid
"corpsecret": Secret
}
R = requests.get (url=Url,params=Data,verify=False)
Token = r.json () ['access_token']
Return Token
Def SendMessage (Token,User,Agentid,Subject,Content):
Url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s"% Token
Data = {
"touser": the user account in User, # Enterprise ID, which is configured in zabbix user Media. If the configuration is abnormal, it will be sent by department.
# "totag": Tagid, the department id in # Enterprise account, which is used when sending messages in groups.
"msgtype": "text", # message type
"agentid": application id in Agentid, # Enterprise.
"text": {
"content": Subject +'\ n' + Content
}
"safe": "0"
}
R = requests.post (url=Url,data=json.dumps (Data), verify=False)
Return r.text
If _ _ name__ = ='_ _ main__':
User = sys.argv [1] # the first parameter passed by zabbix
Subject = sys.argv [2] # the second parameter passed by zabbix
Content = sys.argv [3] # the third parameter passed by zabbix
Corpid = "XXXXXXXXXXXXXXf" # CorpID is the logo of the enterprise number
Secret = "XXXXXXXXXXXXXXXXXX" # Secret is the administrative group credential key
# Tagid = "1" # address book label ID
Agentid = "xxxxxx" # apply ID
Token = GetToken (Corpid, Secret)
Status = SendMessage (Token,User,Agentid,Subject,Content)
Print Status
New alarm media:
Add alarm information template: the content can be filled in according to your own needs.
Enterprise address book: add all the people who want to receive alarms to the enterprise address book.
Finally, the test alarm can be sent:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.