reorx/httpstat

Detecting connectivity Issues to the destination

atibdialpad opened this issue · 3 comments

I have a networking solution which probes the destination with http, mtr, ping etc and collect metrics. Often I see when MTR, Ping return 100% packet loss, httpstat report a very large value of latency. Is it possible to put a time out in the code (preferably configurable) ?

reorx commented

It is possible to use curl's timout option -m, --max-time after the URL parameter, like this:

❯ httpstat http://web.localhost:20443/wait -m 2
> curl -w <output-format> -D <tempfile> -o <tempfile> -s -S -m 2 http://web.localhost:20443/wait
curl error: curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received

but curl returns non-zero code when timeout, thus httpstat cannot show the stat result. Is it helpful to your situation?

awesome. Yeah that helps.

reorx commented

Glad to know it helps, and in case you need, I just released a new version to add the metrics only output ability. If you add environment variable HTTPSTAT_METRICS_ONLY=true for httpstat, it will only output json format metrics for easier parsing:

❯ HTTPSTAT_METRICS_ONLY=true httpstat https://reorx.com
{
  "time_namelookup": 520,
  "time_connect": 528,
  "time_appconnect": 1311,
  "time_pretransfer": 1311,
  "time_redirect": 0,
  "time_starttransfer": 1419,
  "time_total": 1419,
  "speed_download": 2901.0,
  "speed_upload": 0.0,
  "remote_ip": "172.104.82.25",
  "remote_port": "443",
  "local_ip": "192.168.50.125",
  "local_port": "63096",
  "range_dns": 520,
  "range_connection": 8,
  "range_ssl": 783,
  "range_server": 108,
  "range_transfer": 0
}