使用完整pingdom api的python库
PingdomLib3的Python项目详细描述
作者:kenneth wilke<;kenneth.wilke@gmail.com>;
这是一个python库,提供对pingdom api的完全访问,以及 一些额外的特性使api的使用变得更容易和更像pythonic。
用法示例
连接到pingdom
importpingdomlibapi=pingdomlib.Pingdom(username,password,apikey)
显示所有未处于“上升”状态的检查
# See pingdomlib.pingdom documentation to see available calls and settingspingdomchecks=api.getChecks()forcheckinpingdomchecks:# See pingdomlib.check documentation for information on PingdomCheck classifcheck.status!='up':printcheck
创建新支票
newcheck=api.newCheck("New check name","www.hostnametocheck.com")
更新支票
# Updates to check objects are pushed immediately to pingdomnewcheck.paused=True
禁用更改推送检查
api.pushChanges=False
发送最近10个pingdom警报
importdatetimeforalertinapi.alerts(limit=10):time=datetime.datetime.fromtimestamp(alert['time'])timestamp=time.strftime('%Y-%m-%d %H:%M:%S')print"[%s] %s is %s"%(time,alert['name'],alert['status'])
因特定检查而停机
importdatetimecheck=api.getCheck(227878)foroutageincheck.outages():# timestamp conversiontime_start=datetime.datetime.fromtimestamp(outage['timefrom'])timestamp_start=time_start.strftime('%Y-%m-%d %H:%M:%S')time_end=datetime.datetime.fromtimestamp(outage['timeto'])timestamp_end=time_end.strftime('%Y-%m-%d %H:%M:%S')print"%s: %s from %s to %s [%dm]"%(check.name,outage['status'],timestamp_start,timestamp_end,(outage['timeto']-outage['timefrom'])/60)
贡献者
- wil clouser
- 柏林灰烬
- 吴江
- 格特詹·欧德·洛伊斯
- 本杰明·鲍德劳
- 布里特·格雷沙姆
- 阿拉德·霍夫
- 威廉·德格罗特
- 阿伦·费伊
- 里克范德洛
- 库什琴科
- 史蒂文·贝利
特别感谢
anders ekman,pingdom,为api提供热情而有用的支持
待办事项列表
计划改进
- 可选的gzip压缩
- 在禁用pushchanges的情况下改进检查更新过程