Skip to content

Tracker Checker: Ouput in JSON #674

@josecelano

Description

@josecelano

Parent issue: #669

Currently, the Tracker Checker output is a text like this:

TORRUST_CHECKER_CONFIG='{
    "udp_trackers": ["144.126.245.19:6969"],
    "http_trackers": ["https://tracker.torrust-demo.com"],
    "health_checks": ["https://tracker.torrust-demo.com/health_check"]
}' cargo run --bin tracker_checker

Running checks for trackers ...
UDP trackers ...
✓ - Announce at 144.126.245.19:6969 is OK
✓ - Announce at 144.126.245.19:6969 is OK
HTTP trackers ...
✓ - Announce at https://tracker.torrust-demo.com/ is OK
✓ - Scrape at https://tracker.torrust-demo.com/ is OK
Health checks ...
✓ - Health API at https://tracker.torrust-demo.com/health_check is OK

The UDP and HTTP clients use JSON. I should have implemented also this output in JSON because:

  • It's also easy to read.
  • It can be used for automation.

We could implement the new format in JSON and make it the default one. And remove the current text format.

The new format could be:

{
  "udp_trackers": [
    {
      "url": "127.0.0.1:6969",
      "status": {
        "code": "ok",
        "message": "",
      }
    },
    {
      "url": "127.0.0.1:6868",
      "status": {
        "code": "error",
        "message": "Can't connect to the UDP server.",
      }
    },
  ],
  "http_trackers": [
    {
      "url": "http://127.0.0.1:7070",
      "status": {
        "code": "ok",
        "message": "",
      }
    },
    {
      "url": "http:://127.0.0.1:7171",
      "status": {
        "code": "error",
        "message": "Can't connect to the HTTP server. Connection rejected.";
      }
    },
  ],
  "health_checks": [
    {
      "url": "http://127.0.0.1:1313/health_check",
      "status": {
        "code": "ok",
        "message": "",
      }
    },
    {
      "url": "http:://127.0.0.1:1414/health_check",
      "status": {
        "code": "error",
        "message": "Can't connect to the HTTP server. Connection rejected.",
      }
    },
  ]
}

cc @da2ce7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions