I am new learner to use pingdom-api in django-project to check the status of website. I have imported pingdom library to access methods directly in my views.py
my 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")
But pingdomactions list is empty on hiting url, also not reading alerts
Terminal putput :
pingdomactions= {u'alerts': []}
[21/Jul/2013 05:19:08] "GET /data/actions/ HTTP/1.1" 200 2075
Questions:
What are the possible problems for getting empty action list ? . Do you have any solutions for this error.
Am i using this pingdomlib correctly? or there is another-way to use it.
The api.action() will pass up the alerts returned by the pingdom api, it'll be empty if pingdom has taken no actions in response to alerts. Typically what I've seen from actions is a list of the email alerts pingdom has sent out as a response to downs, so if you haven't had any downs or any email/sms/other alerts sent out from pingdom that's most likely why it is empty.
Overall it looks like you are using my lib as intended, please let me know if it's still giving you any struggles!