0
我是新學習者在django-project中使用pingdom-api來檢查網站的狀態。 我已經直接在我的views.py進口pingdom library訪問方法Pingdom get_actions_alerts方法返回空列表
我views.py
import datetime
import pingdomlib
api = pingdomlib.Pingdom(username = "[email protected]", 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名單上hiting網址,也不能讀警報
Terminal putput :
pingdomactions= {u'alerts': []}
[21/Jul/2013 05:19:08] "GET /data/actions/ HTTP/1.1" 200 2075
問題空:
什麼是可能的獲取空行爲列表的問題? 。你有這個錯誤的任何解決方案。
我是否正確使用pingdomlib?或者有另一種方式來使用它。
確實在pingdom帳戶中有一些提醒嗎?你可以通過https://api.pingdom.com/api/2.0/actions直接訪問它們嗎? –
上點擊url,它要求輸入用戶名和密碼,並給予http 403禁止的錯誤 –
如何在url中提供app-key? –