@cryptotaxi247 / infra-1 / commits / 93f42d6a

tf: add diagnostic script to the repo

Amend the original diagnostic script to make it more generic, and copy that into this repo so that everybody can propose changes to it.

zimbatm committed Sep 3, 2021 at 10:49 UTC 93f42d6a4a1aec223c223834aba640aa8a73cf49
2 files changed +58 -2
terraform/cache/diagnostic.sh new
+54
@@ -0,0 +1,54 @@
1 +#!/usr/bin/env nix-shell
2 +#!nix-shell -i bash -p bind.dnsutils -p mtr -p curl
3 +# shellcheck shell=bash
4 +# impure: needs ping
5 +#
6 +# Run this script if you are having issues with cache.nixos.org and paste the
7 +# output URL in a new issue in the same repo.
8 +#
9 +
10 +domain=${1:-cache.nixos.org}
11 +
12 +run() {
13 + echo "> $*"
14 + "$@" |& sed -e "s/^/ /"
15 + printf "Exit: %s\n\n\n" "$?"
16 +}
17 +
18 +curl_w="
19 +time_namelookup: %{time_namelookup}
20 +time_connect: %{time_connect}
21 +time_appconnect: %{time_appconnect}
22 +time_pretransfer: %{time_pretransfer}
23 +time_redirect: %{time_redirect}
24 +time_starttransfer: %{time_starttransfer}
25 +time_total: %{time_total}
26 +"
27 +
28 +curl_test() {
29 + curl -w "$curl_w" -v -o /dev/null "$@"
30 +}
31 +
32 +ix() {
33 + url=$(cat | curl -F 'f:1=<-' ix.io 2> /dev/null)
34 + echo "Pasted at: $url"
35 +}
36 +
37 +(
38 + echo "domain=$domain"
39 + run dig -t A "$domain"
40 + run ping -c1 "$domain"
41 + run ping -4 -c1 "$domain"
42 + run ping -6 -c1 "$domain"
43 + run mtr -c 20 -w -r "$domain"
44 + run curl_test -4 "http://$domain/"
45 + run curl_test -6 "http://$domain/"
46 + run curl_test -4 "https://$domain/"
47 + run curl_test -6 "https://$domain/"
48 + run curl -I -4 "https://$domain/"
49 + run curl -I -4 "https://$domain/"
50 + run curl -I -4 "https://$domain/"
51 + run curl -I -6 "https://$domain/"
52 + run curl -I -6 "https://$domain/"
53 + run curl -I -6 "https://$domain/"
54 +) | tee /dev/stderr | ix
terraform/cache/index.html
+4 -2
@@ -44,8 +44,10 @@
44 <hr />
45 <div class="help">
46 <p>
47 - If you are having trouble, please reach out through one of the <a href="https://nixos.org/nixos/support.html">support channels</a>
48 - with the results of <a href="https://gist.github.com/grahamc/df1bb806eb3552650d03eef7036a72ba">this diagnostics script</a>
47 + If you are having trouble, please reach out through one of the
48 + <a href="https://nixos.org/nixos/support.html">support channels</a>
49 + with the results of
50 + <a href="https://github.com/NixOS/nixos-org-configurations/blob/master/terraform/cache/diagnostic.sh">this diagnostics script</a>
51 which will help us figure out where the issue lies.
52 </p>
53 <p>