Pingdom get_actions_alerts方法返回空的lis

2024-10-01 09:15:53 发布

您现在位置:Python中文网/ 问答频道 /正文

使用新的django学习者网站的django状态。 我已导入pingdom library以直接访问我的视图.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列表在hiting url上为空,也不读取警报

^{pr2}$

问题:

  1. 获取空操作列表可能存在哪些问题。你有解决这个错误的办法吗。

  2. 我正确地使用了这个pingdomalib吗?或者有其他的方法来使用它。


Tags: todjango视图apifordatetimetimecheck
1条回答
网友
1楼 · 发布于 2024-10-01 09:15:53

在api.操作()将传递PingDomAPI返回的警报,如果pingdom没有对警报采取任何操作,则它将为空。通常,我从actions中看到的是pingdom作为对downs的响应而发出的电子邮件警报的列表,所以如果您没有收到任何来自pingdom的邮件/短信/其他警报,那么它很可能是空的。在

总的来说,看起来你是在按计划使用我的lib,请让我知道,如果它仍然给你任何困难!在

相关问题 更多 >