我是一个新的学习者,使用pingdom在django-项目检查网站的状态。我已经将pingdom库导入到直接访问views.py中的方法
我的views.py
import datetime
import pingdomlib
api = pingdomlib.Pingdom( username = "anilxxxx@gmail.com", password = "xxxxxx", apikey = "xf8xyxxxxxxxxxxxxxxxxxxxxxxx")
def get_actions_alerts(request):
pingdomactions=api.actions()
print "pingdomactions=", pingdomactions
for alert in api.alerts(limit=10):
time = datetime.datetime.fromtimestamp(alert['time'])
timestamp = time.strftime('%Y-%m-%d %H:%M:%S')
print timestamp
print "[%s] %s is %s" % (time, alert['name'], alert['status'])
return render_to_response("base_audit_template.html") #need to render data to this page
def get_checks(request):
pingdomchecks = api.getChecks()
print "pingdomchecks" , pingdomchecks
for check in pingdomchecks:
# See pingdomlib.check documentation for information on PingdomCheck class
if check.status != 'up':
print check
else :
print "status up:" , check
return render_to_response("base_audit_template.html")但是pingdomaction列表在hiting url上是空的,也没有读取警报。
Terminal putput :
pingdomactions= {u'alerts': []}
[21/Jul/2013 05:19:08] "GET /data/actions/ HTTP/1.1" 200 2075问题:
发布于 2013-08-16 17:44:12
api.action()将传递由pingdom返回的警报,如果pingdom没有对警报采取任何行动,它将是空的。通常,我从行动中看到的是,pingdom发送的电子邮件通知列表,作为对下降的响应,所以如果您没有从pingdom发送任何邮件/sms/其他警告,那么这很可能是空的原因。
总的来说,你好像在按我的意思使用我的库,如果它还在给你任何挣扎,请告诉我!
https://stackoverflow.com/questions/17771723
复制相似问题