我是在 django-project 中使用 pingdom-api 来检查网站状态的新手。我已导入 pingdom 库 以直接在我的 views.py 中访问方法
我的意见.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")
但是 pingdomactions 列表在点击 url 时是空的,也没有读取警报
Terminal putput :
pingdomactions= {u'alerts': []}
[21/Jul/2013 05:19:08] "GET /data/actions/ HTTP/1.1" 200 2075
问题:
获取空操作列表可能会出现哪些问题?. 您对此错误有任何解决方案。
我是否正确使用了这个 pingdomlib?或者有另一种使用方式。