项目作者: ggiamarchi

项目描述 :
Run system commands through HTTP
高级语言: Go
项目地址: git://github.com/ggiamarchi/http-check.git
创建时间: 2017-04-13T15:03:29Z
项目社区:https://github.com/ggiamarchi/http-check

开源协议:MIT License

下载


HTTP Check

Build Status

HTTP Check is a simple tool that exposes any system command with a single HTTP endpoint. HTTP response code
differs depending command status code.

Configuration

Here is an sample configuration file :

  1. ---
  2. checks:
  3. - name: "ping-10.1.1.2"
  4. command:
  5. executable: "/sbin/ping %s %d %s"
  6. args: ["-c", 2, "10.100.0.1"]
  7. status:
  8. failure: 223
  9. success: 200
  10. - name: "ping-google"
  11. command:
  12. executable: "/sbin/ping %s %d %s"
  13. args: ["-c", 2, "8.8.8.8"]
  14. status:
  15. failure: 503
  16. success: 204
  17. server:
  18. port: 2323

Installation

  1. Download http-check binary from github release
  2. Create configuration file. Default location is /etc/http-check/http-check.yml. You can specificy custom location on the command line when running the server

Run the server

Basically run the binary

  1. $ http-check server

Or, with a custom configuration file location

  1. $ http-check server --config /etc/http-check.yml

Run checks

Clients use a single endpoint to run any check.

Request

  1. GET /v1/check/{name}

Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=utf-8
  3. Date: Wed, 29 Aug 2018 13:18:13 GMT
  4. Content-Length: 350
  5. {
  6. "error":"",
  7. "stderr":"",
  8. "stdout":"PING 8.8.8.8 (8.8.8.8): 56 data bytes\n64 bytes from 8.8.8.8: icmp_seq=0 ttl=121 time=12.676 ms\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=121 time=20.267 ms\n\n--- 8.8.8.8 ping statistics ---\n2 packets transmitted, 2 packets received, 0.0% packet loss\nround-trip min/avg/max/stddev = 12.676/16.471/20.267/3.796 ms\n"
  9. }

NB. Status code depends the YAML check configuration.

License

Everything in this repository is published under the MIT license.