master
parent
55724b9eb6
commit
23dde233df
@ -1,22 +1,22 @@ |
|||||||
[server] |
[server] |
||||||
192.168.96.234 |
192.168.96.168 |
||||||
|
|
||||||
[database] |
[database] |
||||||
192.168.96.234 |
192.168.96.168 |
||||||
|
|
||||||
[zabbix-server:children] |
[zabbix-server:children] |
||||||
server |
server |
||||||
database |
database |
||||||
|
|
||||||
[zabbix-server:vars] |
[zabbix-server:vars] |
||||||
dbHost=192.168.96.234 |
dbHost=192.168.96.168 |
||||||
dbUser=remote |
dbUser=remote |
||||||
dbPassword=123456 |
dbPassword=123456 |
||||||
dbName=zabbix |
dbName=zabbix |
||||||
|
|
||||||
[agent] |
[agent] |
||||||
192.168.96.234 Hostname=zabbix-agent |
192.168.96.168 Hostname=zabbix-agent |
||||||
192.168.96.235 Hostname=zabbix-agent |
192.168.96.169 Hostname=zabbix-agent |
||||||
|
|
||||||
[agent:vars] |
[agent:vars] |
||||||
serverHost=192.168.96.234 |
serverHost=192.168.96.168 |
||||||
|
@ -0,0 +1,2 @@ |
|||||||
|
|
||||||
|
UserParameter=redischeck.mode[*],redis-cli info | awk -F ':' '/^$1/{print $$2}' |
@ -0,0 +1,39 @@ |
|||||||
|
#!/usr/bin/python3 |
||||||
|
#-*-coding: utf-8-*- |
||||||
|
# by QianFeng.newrain |
||||||
|
# |
||||||
|
''' |
||||||
|
Welcome QianFeng cloud computing |
||||||
|
''' |
||||||
|
import requests |
||||||
|
import json |
||||||
|
import sys |
||||||
|
import time,hmac,base64,hashlib,urllib.parse |
||||||
|
|
||||||
|
|
||||||
|
headers = {'Content-Type': 'application/json;charset=utf-8'} |
||||||
|
# 需要修改,钉钉群助手中获取 |
||||||
|
timestamp = str(round(time.time() * 1000)) |
||||||
|
secret = {{ secret }} |
||||||
|
secret_enc = secret.encode('utf-8') |
||||||
|
string_to_sign = '{}\n{}'.format(timestamp, secret) |
||||||
|
string_to_sign_enc = string_to_sign.encode('utf-8') |
||||||
|
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest() |
||||||
|
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) |
||||||
|
api_url = f"https://oapi.dingtalk.com/robot/send?access_token=abdec0db67d1ca355b547711f822e0bb60929295cd3c42c1e4c89c7f24b4872e×tamp={timestamp}&sign={sign}" |
||||||
|
def msg(text): |
||||||
|
json_text= { |
||||||
|
"msgtype": "text", |
||||||
|
"at": { |
||||||
|
"atMobiles": [ |
||||||
|
"all" |
||||||
|
], |
||||||
|
"isAtAll": False |
||||||
|
}, |
||||||
|
"text": { |
||||||
|
"content": text |
||||||
|
} |
||||||
|
} |
||||||
|
print(requests.post(api_url,json.dumps(json_text),headers=headers).content.decode()) |
||||||
|
|
||||||
|
msg('\n'+sys.argv[1]) |
@ -0,0 +1,60 @@ |
|||||||
|
#!/usr/bin/python3 |
||||||
|
#-*-coding: utf-8-*- |
||||||
|
# by QianFeng.newrain |
||||||
|
# |
||||||
|
''' |
||||||
|
Welcome QianFeng cloud computing |
||||||
|
''' |
||||||
|
|
||||||
|
import json |
||||||
|
import sys |
||||||
|
import time |
||||||
|
import requests |
||||||
|
|
||||||
|
# 此为企业的ID号 |
||||||
|
CorpID = {{ corpid }} |
||||||
|
|
||||||
|
# 应用的ID |
||||||
|
Agentid = {{ agentid }} |
||||||
|
|
||||||
|
# 认证信息,企业ID+认证信息可获取tokent,获取之后向此tokent发送内容 |
||||||
|
Secret = {{ secret }} |
||||||
|
|
||||||
|
localtime = time.strftime("[%H:%M:%S]", time.localtime()) |
||||||
|
class Tencent(object): |
||||||
|
def __init__(self,user,title, msg): |
||||||
|
# 格式化输出内容:标题+内容 |
||||||
|
self.MSG = f'{title}\n{msg}\n{localtime}' |
||||||
|
self.User = user |
||||||
|
self.url = 'https://qyapi.weixin.qq.com' |
||||||
|
self.send_msg = json.dumps({ |
||||||
|
"touser": self.User, |
||||||
|
"msgtype": 'text', |
||||||
|
"agentid": Agentid, |
||||||
|
"text": {'content': self.MSG}, |
||||||
|
"safe": 0 |
||||||
|
}) |
||||||
|
# 获取tokent |
||||||
|
def get_token(self): |
||||||
|
token_url = '%s/cgi-bin/gettoken?corpid=%s&corpsecret=%s' % (self.url, CorpID, Secret) |
||||||
|
r = requests.get(token_url) |
||||||
|
r = r.json() |
||||||
|
token = r['access_token'] |
||||||
|
return token |
||||||
|
|
||||||
|
# 发送信息 |
||||||
|
def send_message(self): |
||||||
|
send_url = '%s/cgi-bin/message/send?access_token=%s' % (self.url,self.get_token()) |
||||||
|
respone = requests.post(url=send_url, data=self.send_msg) |
||||||
|
respone = respone.json() |
||||||
|
x = respone['errcode'] |
||||||
|
if x == 0: |
||||||
|
print ('Succesfully') |
||||||
|
else: |
||||||
|
print ('Failed') |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
# 创建对象 |
||||||
|
send_obj = Tencent(sys.argv[1],str(sys.argv[2]), str(sys.argv[3])) |
||||||
|
# 调用发送函数 |
||||||
|
send_obj.send_message() |
Loading…
Reference in new issue