#!/usr/bin/env python
#coding:utf-8
import urllib2
import os,time,urllib2,urllib
test = "test"
password = "1234@DJ"
webserver = "xx.xx.xx.xx"
def work():
#构建一个密码管理对象,可以用来保存和http请求相关的授权账户信息
passwordMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
#添加授权账户信息,第一个参数realm如果没有指定就写None,后三个分别是站点IP,账户和密码
passwordMgr.add_password(None,webserver, test, password)
httpauth_handler = urllib2.HTTPBasicAuthHandler(passwordMgr)
opener = urllib2.build_opener(httpauth_handler)
request = urllib2.Request("http://xx.xx.xx.xx/app/kibana/")
#response = opener.open(request)
try:
opener.open(request)
except urllib2.URLError,e:
msg1="ELK is down"
return msg1
def Send_Sms(mobile,msg):
# f = file('d:/testlist.txt','w+')
for phone in mobile:
sms_url = 'http://xx.xx.xx.xx:xx/api/sms?mobiles=%s&content=' %(phone) + urllib.quote(msg)
print sms_url
urllib2.urlopen(sms_url)
if __name__ == '__main__':
msg = work()
#print msg
Pho_Num = ['XXXXXXXXXXX']
if not msg is None:
#print msg
Send_Sms(Pho_Num,msg)
python监控ELK kibana 页面是否正常的脚本
最新推荐文章于 2021-03-27 21:45:04 发布