URI | /v2/site/create.json | ||||
Method | POST | ||||
参数示例: 创建HTTP监控(外网) data=[ { "task_name": "XXXX", "task_type": "http", "frequency": 2, "retry": 2, "monitors": "1,11,2", "history":"1", "reminds":"", "alert_setting": { "alert": { "email": "283940", "remind""285177" }, "scope":"4", "user_ids":"283940,284480,285177" }, "submit_method":1, "param":"http://www.baidu.com", "url":"http://www.sohu.com" } ]
创建HTTP监控(内网) data=[ { "task_name": "XXXX", "task_type": "http", "frequency": 2, "retry": 2, "monitors": "1,11,2", "history":"1", "reminds":"", "isAgent":1, "plugin_task_uselist_id":[496,528], "alert_setting": { "alert": { "email": "283940", "remind""285177" }, "scope":"4", "user_ids":"283940,284480,285177" }, "submit_method":1, "param":"http://www.baidu.com", "url":"http://www.sohu.com" } ]
创建FTP监控 data=[ { "task_name": "ftp.duke", "task_type": "ftp", "frequency": 2, "retry": 2, "monitors": "1,11,2", "ftp_port": 234, "ftp_anonymous": 0, "ftp_user":"duke", "ftp_pwd":"duke", "host":"ftp://www.sohu.com", "history":"1", "reminds":"10", "alert_setting":{ ……….. } } ]
创建DNS监控 1、当dns_type为1,即为A时 data=[ { "task_name":"test", "domain":"http:jkb.com", "dns_type":"1", "use_dns_ip":"1", "metric_ip":"10.0.1.1,10.0.1.2,10.0.1.3", "use_dns_server":"1", "dns_server":"77.10.3.2", "task_type":"dns", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ……….. } } ] 2、当dns_type为3,即为NS时 data=[ { "task_name":"test", "domain":"http:jkb.com", "dns_type":"3", "use_dns_domain":"1", "metric_domain":"www.baidu.com,www.sina.com", "use_dns_server":"1", "dns_server":"77.10.3.2", "task_type":"dns", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ……….. }
} ] 3、当dns_type为2、4、5或6时 data=[ { "task_name":"test", "domain":"http:jkb.com", "dns_type":"2", "use_dns_server":"1", "dns_server":"77.10.3.2", "task_type":"dns", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ……….. } } ]
创建Ping 监控(外网) data=[ { "task_name":"test", "host":"www.baidu.com", "task_type":"ping", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ……….. } } ]
创建Ping监控 (内网) data=[ { "task_name":"test", "host":"www.baidu.com", "task_type":"ping", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "isAgent":1, "plugin_task_uselist_id":[496,528], "alert_setting":{ ……….. } } ]
创建TCP监控 data=[ { "task_name":"test", "tcp_port":"80", "host":"www.baidu.com", "task_type":"tcp", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ……….. } } ]
创建SMTP监控 data=[ { "task_name":"test", "smtp_port":"25", "host":"www.baidu.com", "task_type":"smtp", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ……….. } } ]
创建UDP监控 data=[ { "task_name":"test", "udp_port":"80", "request_format":0, "request_str":"dfdfd", "pattern_format":0, "pattern_str":"dfsfsfsfsf", "host":"www.baidu.com", "task_type":"udp", "frequency":"5", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ....... } } ]
创建TraceRoute监控 data=[ { "task_name":"test", "host":"jkb.com", "isAgent":"1", "plugin_task_uselist_id":[6712,7142], "task_type":"traceroute", "frequency":"2", "retry":"1", "history":"1", "reminds":"10", "alert_setting":{ ....... } } ] | |||||
参数项 | 必填 | 描述 | 默认值 | ||
access_token | 必填 | ||||
task_name | 必填 | 监控项目名称 | |||
task_type | 必填 | 任务类型[http,dns….] | |||
frequency | 必填 | 监控频率(分钟) | |||
retry | 必填 | 重试几次告警(1-3次) | |||
monitors | 必填 | 使用的监测点(监测点之间以半角逗号隔开,可通过/v2/site/monitors.json接口获得) | |||
class_id | 选填 | 网站分类ID | |||
reminds | 选填 | 连续告警提醒[0-不连续提醒,数字N -“1、2、3、5、10、20、30(分别表示告警频率为监控频率的N倍)”],单位为分钟 | 0 | ||
history | 选填 | 记录节点故障快照[0-关闭,1-开启] | 0 | ||
alert_setting | 选填 | 为任务告警设置 请求不包含此参数时,使用默认告警通知人;请求包含此参数且参数内容为空时,不设置告警通知 | |||
scope | 选填 | 任务公开范围[1-全企业用户,2-指定用户组, 3-仅限本人 ,4-部分用户] 注:企业用户才需要设置 | |||
user_ids | 选填 | 部分企业用户,多个ID之间用半角“,”隔开(只当 ‘scope’设置为4时才需设置),可以通过列出所有用户查找user_ids | |||
选填 | 邮箱号,后面填写用户ID,多个之间用半角“,”隔开,且所填ID值必须在user_ids中 | ||||
sms | 选填 | 手机号,后面填写用户ID,多个之间用半角“,”隔开,且所填ID值必须在user_ids中 | |||
voice | 选填 | 电话语音,后面填写用户ID,多个之间用半角“,”隔开,且所填ID值必须在user_ids中 | |||
push | 选填 | App推送,后面填写用户ID,多个之间用半角“,”隔开,且所填ID值必须在user_ids中 | |||
选填 | 微信,后面填写用户ID,多个之间用半角“,”隔开,且所填ID值必须在user_ids中 | ||||
remind | 选填 | 连续告警,后面填写用户ID,多个之间用半角,隔开 | |||
organization | 选填 | 指定用户组,只当 ‘scope’设置为2时才需设置,可以通过用户分组信息查看所需要的值 | |||
以下为HTTP所选项 | |||||
url | 必填 | 监控URL(创建网址(http/http)任务需要的参数) | |||
pattern_str | 选填 | 匹配响应内容 | |||
pattern_type | 选填 | 匹配方式 [0-包含匹配内容,1-不包含匹配内容] | |||
cookies | 选填 | 可以指定Cookies字符串,比如:token=d906b69209d9de92789fcd65a1a5d210; pvid=954970634; flv=10.0 | |||
http_user | 选填 | 如果需要HTTP身份验证,请填写用户名 | |||
http_pwd | 选填 | 如果需要HTTP身份验证,可以输入密码 | |||
ip | 选填 | 如果您的域名DNS指向多台服务器,您可以指定IP来监控特定的服务器 | |||
submit_method | 选填 | HTTP请求方式[0-GET,1-POST,2-HEAD] | |||
param | 选填 | 提交内容 (submit_method=1,post的时候该参数有效) | |||
redirect | 选填 | 支持301/302重定向[on-勾选,不填-不勾选] | 不勾选 | ||
header | 选填 | 你可以自定义HTTP请求头信息,格式为Name: Value,多个项用换行分隔,比如:User-Agent: Mozilla/4.0 | |||
isAgent | 选填 | 是否使用插件[不填-不使用(外网采集),1-使用(内网采集)] | |||
plugin_task_uselist_id | 选填 | 插件列表ID,数组格式 | |||
以下为Ping所选项 | |||||
host | 必填 | 主机 | |||
isAgent | 选填 | 是否使用插件[不填-不使用(外网采集),1-使用(内网采集)] | |||
plugin_task_uselist_id | 选填 | 插件列表ID,数组格式 | |||
以下为DNS所选项 | |||||
domain | 必填 | 域名 | |||
dns_type | 必填 | DNS查询类型[1-A,2-MX,3-NS,4-CNAME,5-TXT,6-ANY] | |||
use_dns_domain | 选填 | 是否匹配域名地址[不为空-匹配,空-不匹配] | |||
metric_domain | 选填 | 域名输入(多个域名用半角英文“,”隔开,dns_type=3,并且use_dns_domain不为空的时候生效) | |||
use_dns_server | 选填 | 指定DNS服务器[不为空-指定,空-不指定] | |||
dns_server | 选填 | DNS服务器(use_dns_server不为空时生效) | |||
use_dns_ip | 选填 | 是否指定IP地址[不为空-匹配,空-不匹配] | 不指定 | ||
metric_ip | 选填 | IP输入(多个IP用半角英文“,”隔开,当dns_type为1,并且use_dns_ip不为空的时候生效) | |||
以下为FTP所选项 | |||||
host | 必填 | 主机 | |||
ftp_port | 必填 | FTP端口 | 21 | ||
ftp_anonymous | 必填 | FTP身份验证选项[0-需要身份验证,1-匿名登录] | |||
ftp_user | 选填 | FTP用户名(ftp_anonymous为0时为必填) | |||
ftp_pwd | 选填 | FTP密码(ftp_anonymous为0时为必填) | |||
以下为TCP所选项 | |||||
tcp_port | 必填 | TCP端口 | |||
host | 必填 | 主机 | |||
isAgent | 选填 | 是否使用插件[不填-不使用(外网采集),1-使用(内网采集)] | |||
plugin_task_uselist_id | 选填 | 插件列表ID,数组格式 | |||
以下为UDP所选项 | |||||
host | 必填 | 主机 | |||
udp_port | 必填 | UDP端口 | |||
request_format | 必填 | UDP请求内容格式[0-Binary格式,1-文本格式] | |||
request_str | 必填 | UDP请求内容 | |||
pattern_format | 必填 | 匹配响应内容格式[0-Binary格式,1-文本格式] | |||
pattern_str | 必填 | 匹配响应内容 | |||
以下为SMTP所选项 | |||||
host | 必填 | 主机 | |||
smtp_port | 必填 | SMTP端口 | |||
以下为TraceToute所选项 | |||||
host | 必填 | 主机 | |||
isAgent | 选填 | 是否使用采集器插件[不填-不使用,1-使用] | 不使用 | ||
plugin_task_uselist_id | 选填 | 插件ID,多个ID之间用半角逗号”,”隔开(isAgent为1时为必填项) | |||
成功结果: [ { "task_id": 684358 } ] | |||||
返回项 | 类型 | 描述 | |||
task_id | String | 任务ID | |||
失败结果: [ { "error": "非常抱歉,操作失败,请联系管理员" } ] | |||||
返回项 | 类型 | 描述 | |||
error | String | 错误描述 |
调用示例:
curl -H "application/x-www-form-urlencoded" "https://api.jiankongbao.com/v2/site/create.json?access_token= caa49dbf13ce98d5cafb0d490b0ad1a9d982510a" --data 'data=[{"task_name": "二座","task_type":"http","frequency":2,"retry":2,"monitors":"1,11,2", "alert_setting":{"alert":{"email":"283940","remind":"285177"},"scope":"4","user_ids":"283940,284480,285177"}, "submit_method":1,"param":"http://www.baidu.com","url":"http://www.sohu.com"}]'