feat: traceroute card and a journalctl line for current activity
This commit is contained in:
1 parent
772ec6233d
commit
f848489ae2
3 files changed
+89
-12
No files matched your search
@@ -5,10 +5,17 @@ Jonathan Branan — <span style="color:#f59e0b">technical support engineer</span
|
||||
<span style="color:#22c55e">jonathan@core</span>:<span style="color:#38bdf8">~</span><span style="color:#7c8798">$</span> uptime
|
||||
up <span style="color:#f59e0b">7</span> hosts · <span style="color:#f59e0b">76</span> stacks · <span style="color:#f59e0b">1</span> very patient wife
|
||||
|
||||
<span style="color:#22c55e">jonathan@core</span>:<span style="color:#38bdf8">~</span><span style="color:#7c8798">$</span> cat how-it-gets-here.txt
|
||||
internet → <span style="color:#38bdf8">Cloudflare</span> → <span style="color:#38bdf8">Pangolin</span> (VPS) → <span style="color:#38bdf8">newt</span> tunnel → <span style="color:#38bdf8">core</span> → container
|
||||
<span style="color:#22c55e">jonathan@core</span>:<span style="color:#38bdf8">~</span><span style="color:#7c8798">$</span> traceroute jonb.io
|
||||
<span style="color:#7c8798">traceroute to jonb.io (198.23.237.22), 30 hops max, 60 byte packets</span>
|
||||
<span style="color:#7c8798"> 1</span> <span style="color:#38bdf8">internet </span><span style="color:#7c8798"> 0.412 ms 0.388 ms 0.401 ms</span>
|
||||
<span style="color:#7c8798"> 2</span> <span style="color:#38bdf8">cloudflare </span><span style="color:#7c8798"> 1.204 ms 1.188 ms 1.231 ms</span>
|
||||
<span style="color:#7c8798"> 3</span> <span style="color:#38bdf8">pangolin (vps) </span><span style="color:#7c8798"> 8.771 ms 8.640 ms 8.902 ms</span>
|
||||
<span style="color:#7c8798"> 4</span> <span style="color:#38bdf8">newt tunnel </span><span style="color:#7c8798"> 12.338 ms 12.201 ms 12.455 ms</span>
|
||||
<span style="color:#7c8798"> 5</span> <span style="color:#38bdf8">core </span><span style="color:#7c8798"> 12.902 ms 12.744 ms 12.988 ms</span>
|
||||
<span style="color:#7c8798"> 6</span> <span style="color:#38bdf8">container </span><span style="color:#7c8798"> 13.115 ms 13.002 ms 13.240 ms</span>
|
||||
|
||||
<span style="color:#22c55e">jonathan@core</span>:<span style="color:#38bdf8">~</span><span style="color:#7c8798">$</span> <span style="color:#22c55e">_</span></pre>
|
||||
<span style="color:#22c55e">jonathan@core</span>:<span style="color:#38bdf8">~</span><span style="color:#7c8798">$</span> journalctl -u jonathan -n 1 -o cat
|
||||
ci: deploy via Komodo stack webhook, tag images with commit sha</pre>
|
||||
<!-- terminal:end -->
|
||||
|
||||
<!-- status:start -->
|
||||
@@ -21,7 +28,7 @@ internet → <span style="color:#38bdf8">Cloudflare</span> → <span style="colo
|
||||
|
||||
<!-- working-on:start -->
|
||||
- [**qbit-maid**](https://git.jonb.io/jblu/qbit-maid) — Qbittorrent cleaner that deletes torrents based on age, categories, domains and tags. · `v3.0.0`
|
||||
- [**jonbio**](https://git.jonb.io/jblu/jonbio) — TypeScript · updated 18m ago
|
||||
- [**jonbio**](https://git.jonb.io/jblu/jonbio) — TypeScript · updated 27m ago
|
||||
- [**crane**](https://git.jonb.io/jblu/crane) — App to make sure specified containers are running in portainer
|
||||
<!-- working-on:end -->
|
||||
|
||||
@@ -36,7 +43,7 @@ internet → <span style="color:#38bdf8">Cloudflare</span> → <span style="colo
|
||||
## Recent pull requests
|
||||
|
||||
<!-- prs:start -->
|
||||
- [ci: deploy via Komodo stack webhook, tag images with commit sha](https://git.jonb.io/jblu/jonbio/pulls/3) — jonbio · 18m ago
|
||||
- [ci: deploy via Komodo stack webhook, tag images with commit sha](https://git.jonb.io/jblu/jonbio/pulls/3) — jonbio · 27m ago
|
||||
- [fix: resolve the seven bugs pinned by the test audit](https://git.jonb.io/jblu/qbit-maid/pulls/67) — qbit-maid · 15d ago
|
||||
- [test: audit suite for meaningfulness, reach 100% coverage](https://git.jonb.io/jblu/qbit-maid/pulls/66) — qbit-maid · 15d ago
|
||||
<!-- prs:end -->
|
||||
|
||||
+65
-7
@@ -161,13 +161,14 @@ def vikunja_done(cfg):
|
||||
# ---------------------------------------------------------------- blocks
|
||||
|
||||
|
||||
def terminal_block(cfg, stacks, hosts):
|
||||
def terminal_block(cfg, stacks, hosts, journal):
|
||||
p = cfg["palette"]
|
||||
|
||||
def c(key, text):
|
||||
return f'<span style="color:{p[key]}">{text}</span>'
|
||||
|
||||
prompt = f'{c("prompt", "jonathan@core")}:{c("path", "~")}{c("muted", "$")}'
|
||||
tr = cfg["traceroute"]
|
||||
lines = [
|
||||
f"{prompt} whoami",
|
||||
f'Jonathan Branan — {c("value", "technical support engineer")} at Teramind',
|
||||
@@ -175,15 +176,62 @@ def terminal_block(cfg, stacks, hosts):
|
||||
f"{prompt} uptime",
|
||||
f'up {c("value", hosts)} hosts · {c("value", stacks)} stacks · {c("value", "1")} very patient wife',
|
||||
"",
|
||||
f"{prompt} cat how-it-gets-here.txt",
|
||||
f'internet → {c("path", "Cloudflare")} → {c("path", "Pangolin")} (VPS) → '
|
||||
f'{c("path", "newt")} tunnel → {c("path", "core")} → container',
|
||||
"",
|
||||
f'{prompt} {c("prompt", "_")}',
|
||||
f"{prompt} traceroute {tr['target']}",
|
||||
c("muted", f"traceroute to {tr['target']} ({tr['target_ip']}), 30 hops max, 60 byte packets"),
|
||||
]
|
||||
for i, hop in enumerate(tr["hops"], 1):
|
||||
a, b, d = hop["ms"]
|
||||
lines.append(
|
||||
f'{c("muted", f"{i:2d}")} {c("path", f"{hop["name"]:<18}")}'
|
||||
f'{c("muted", f"{a:>7.3f} ms {b:>7.3f} ms {d:>7.3f} ms")}'
|
||||
)
|
||||
lines += ["", f"{prompt} journalctl -u jonathan -n 1 -o cat"]
|
||||
if journal:
|
||||
lines.append(journal)
|
||||
return "<pre>" + "\n".join(lines) + "</pre>"
|
||||
|
||||
|
||||
def current_activity(cfg, tok):
|
||||
"""Newest signal of what he is doing: an open Vikunja task or a real commit."""
|
||||
cands = []
|
||||
vtok = os.environ.get("VIKUNJA_TOKEN", "").strip()
|
||||
if vtok:
|
||||
base = cfg["vikunja"]["base"]
|
||||
for proj in cfg["vikunja"].get("activity_projects", [cfg["vikunja"]["project"]]):
|
||||
try:
|
||||
tasks = http_json(
|
||||
f"{base}/api/v1/projects/{proj}/tasks?per_page=100",
|
||||
headers={"Authorization": "Bearer " + vtok},
|
||||
)
|
||||
except Exception:
|
||||
continue
|
||||
for t in tasks:
|
||||
if not t.get("done") and t.get("updated"):
|
||||
cands.append((t["updated"], t["title"]))
|
||||
for name in cfg["featured_repos"]:
|
||||
try:
|
||||
commits = gitea(f"/repos/jblu/{name}/commits?limit=5&stat=false", tok)
|
||||
except Exception:
|
||||
continue
|
||||
for c in commits:
|
||||
msg = c["commit"]["message"].strip()
|
||||
if msg.startswith(("Merge pull request", "Merge PR", "chore: refresh profile README")):
|
||||
continue # merges duplicate the PR block; the refresh is self-referential
|
||||
cands.append((c["commit"]["author"]["date"], msg.splitlines()[0]))
|
||||
if not cands:
|
||||
return None
|
||||
cands.sort(key=lambda x: x[0], reverse=True)
|
||||
return cands[0]
|
||||
|
||||
|
||||
def journal_line(cfg, activity):
|
||||
"""`-o cat` prints the message only, so the line fits the card without wrapping."""
|
||||
if not activity:
|
||||
return ""
|
||||
_, msg = activity
|
||||
return one_line(msg, 70)
|
||||
|
||||
|
||||
def status_block(cfg, up, total):
|
||||
p = cfg["palette"]
|
||||
ok = up == total
|
||||
@@ -279,7 +327,17 @@ def build():
|
||||
if hosts is None:
|
||||
hosts = previous_int(text, r"up (\d+) hosts")
|
||||
|
||||
apply("terminal", lambda: terminal_block(cfg, stacks, hosts))
|
||||
activity = None
|
||||
try:
|
||||
activity = current_activity(cfg, tok)
|
||||
except Exception as exc:
|
||||
errors.append(f"activity: {type(exc).__name__}: {exc}")
|
||||
if activity is None:
|
||||
# no signal at all: keep the previous card rather than print a stale lie
|
||||
errors.append("activity: no signal, keeping the previous terminal card")
|
||||
else:
|
||||
journal = journal_line(cfg, activity)
|
||||
apply("terminal", lambda: terminal_block(cfg, stacks, hosts, journal))
|
||||
|
||||
try:
|
||||
up, total = kuma_counts(cfg)
|
||||
|
||||
@@ -13,6 +13,18 @@
|
||||
"accent": "#a78bfa",
|
||||
"bad": "#ef4444"
|
||||
},
|
||||
"traceroute": {
|
||||
"target": "jonb.io",
|
||||
"target_ip": "198.23.237.22",
|
||||
"hops": [
|
||||
{"name": "internet", "ms": [0.412, 0.388, 0.401]},
|
||||
{"name": "cloudflare", "ms": [1.204, 1.188, 1.231]},
|
||||
{"name": "pangolin (vps)", "ms": [8.771, 8.640, 8.902]},
|
||||
{"name": "newt tunnel", "ms": [12.338, 12.201, 12.455]},
|
||||
{"name": "core", "ms": [12.902, 12.744, 12.988]},
|
||||
{"name": "container", "ms": [13.115, 13.002, 13.240]}
|
||||
]
|
||||
},
|
||||
"kuma": {
|
||||
"base": "https://up.jonb.io/api",
|
||||
"page": "homelab"
|
||||
|
||||
Reference in new issue
Block a user