将pingom数据导出到csv或数据库
pingdomexport的Python项目详细描述
安装
简单安装
$ pip install pingdomexport
配置访问
pingdom_access:username:dummypassword:dummyaccount_email:dummyapp_key:dummy
用户名、密码和帐户电子邮件应易于填写(是您登录pindcom的凭据)。
若要获取应用程序密钥,请登录pingdom,然后转到“集成”>;“pingdom api”>;“注册应用程序”
配置检查
# the checks that you want to export datachecks:# 3 strategies supported# all: all checks# include: will only include the ids specified# exclude: all checks except the ids specifiedstrategy:allids:[]
PindCom导出允许导出所有支票:
checks:strategy:allids:[]
指定要导出的支票:
checks:strategy:includeids:[12454,32932]
指定要排除的支票(将导出除指定支票以外的所有支票):
checks:strategy:excludeids:[12454]
配置导出
pingdom导出允许将检查和结果导出到mysql、postgres或stdout。
load:# type: output|mysql|postgrestype:outputparameters:[]# if mysql#parameters:# db_url: mysql+pymysql://user:password@host/database# if postgres#parameters:# db_url: postgres://user:password@host/database
如果输出:
load:type:outputparameters:[]
如果mysql:
load:type:mysqlparameters:db_url:mysql+pymysql://user:password@host/database
如果出现错误:
load:type:postgresparameters:db_url:mysql+pymysql://user:password@host/database
数据库特权
mysql和postgres都需要对db具有select、insert、update和delete权限的用户。对于postgres,用户还需要访问序列。
运行
要列出可用的选项:
$ pingdom-run-export --help
仅导出支票信息:
$ pingdom-run-export --config /full/path/to/config.yml --type checks
仅导出检查结果:
$ pingdom-run-export --config /full/path/to/config.yml --type results
导出检查信息和结果:
$ pingdom-run-export --config /full/path/to/config.yml --type all
运行-部分导出
默认情况下,pingdom导出将始终导出完整结果可以使用可选参数指定时间范围,例如:
$ pingdom-run-export --config /full/path/to/config.yml --type results --checks-from 1465071758 --checks-to 1465158158
大数据
如果您有几个月历史的多个检查,那么在一个线程中运行所有内容可能会花费太多时间。
您可以使用多个配置文件,并在每次检查时运行一个pingdom导出然后每天运行一个crontab 使用支票从和支票到