rakshazi / fping
此软件包最新版本(1.1.1)没有可用的许可证信息。
简单的微服务/函数,用于检查目标健康状态
1.1.1
2018-04-11 08:34 UTC
Requires
- php: ^7.1
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2024-09-13 21:35:42 UTC
README
简单的微服务/ 函数,用于检查目标服务器、网站等状态。
目录
使用方法
Docker
docker run -d -p 8080:8080 rakshazi/fping curl -X POST -d "type=HTTP&address=https://google.com" localhost:8080 #response {"status_code":200,"time":0.448615,"should_contain":true,"should_not_contain":true,"status":true}
OpenFaaS
即将推出...
Composer(可选)
如果您想直接使用 fping,而不使用 Docker,您可以使用 composer 安装它。
composer require rakshazi/fping
API
请求
fping 基于 OpenFaaS Watchdog 构建,提供简单的 API 和与 OpenFaaS 的集成。
要调用 fping,您应向 fping 地址(例如,上面的 localhost:8080)发送以下结构的 POST 请求
json:
{ "type": "Check type", "address": "Target server/site address", "timeout": 5, //integer timeout in seconds "optional": {} //optional params, specific for each check type }
原始形式:
type=Check type&address=Target address&timeout=5&optional[param1]=val1&optional[param2]=val2
响应
json:
{ "status_code":200, //HTTP response status code "time":448, //response time in ms "should_contain":true, //optional for HTTP "should_not_contain":true, //optional for HTTP "status":true //check status - is target up or down }
检查类型
HTTP
检查 HTTP(-s) 目标。
可选参数:
should_contain
- 检查响应体中是否存在该字符串,如果找到字符串则检查通过should_not_contain
- 检查响应体中是否存在该字符串,如果找到字符串则检查失败
示例
curl -X POST -d "type=HTTP&address=https://example.com&timeout=5&optional[should_contain]=healthy&optional[should_not_contain]=error" localhost:8080