maglevt: show FQDN in header instead of config paths; v1.0.1
Replace the cfgPath field in the TUI header with the system's fully-qualified hostname via gethostname + CNAME lookup, matching what `hostname -f` produces. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -15,7 +15,7 @@ FRONTEND_WEB_SRC := $(shell find cmd/frontend/web/src -type f 2>/dev/null) \
|
|||||||
FRONTEND_WEB_DIST := cmd/frontend/web/dist/index.html
|
FRONTEND_WEB_DIST := cmd/frontend/web/dist/index.html
|
||||||
|
|
||||||
NATIVE_ARCH := $(shell go env GOARCH)
|
NATIVE_ARCH := $(shell go env GOARCH)
|
||||||
VERSION := 1.0.0
|
VERSION := 1.0.1
|
||||||
COMMIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
COMMIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
LDFLAGS := -X '$(MODULE)/cmd.version=$(VERSION)' \
|
LDFLAGS := -X '$(MODULE)/cmd.version=$(VERSION)' \
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m := Model{
|
m := Model{
|
||||||
cfgPath: strings.Join(cfgPaths, ", "),
|
host: fqdn(),
|
||||||
vips: vips,
|
vips: vips,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
startAt: time.Now(),
|
startAt: time.Now(),
|
||||||
@@ -158,6 +158,24 @@ func run() error {
|
|||||||
// deterministic TUI layout: within a file, frontends are visited
|
// deterministic TUI layout: within a file, frontends are visited
|
||||||
// in name-sorted order; across files, the first occurrence of each
|
// in name-sorted order; across files, the first occurrence of each
|
||||||
// tuple wins and fixes its slot in the output.
|
// tuple wins and fixes its slot in the output.
|
||||||
|
// fqdn returns the system's fully-qualified hostname: gethostname(2)
|
||||||
|
// via os.Hostname() for the short name, then a CNAME lookup to reach
|
||||||
|
// the canonical form the resolver would hand back — the same two-step
|
||||||
|
// dance `hostname -f` performs. Falls back to the short name when the
|
||||||
|
// resolver has nothing to add, so the TUI header always renders.
|
||||||
|
func fqdn() string {
|
||||||
|
h, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
if cname, err := net.LookupCNAME(h); err == nil {
|
||||||
|
if s := strings.TrimSuffix(cname, "."); s != "" {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
func buildVIPsUnion(cfgs []*config.Config, cfgPaths []string, filterRe *regexp.Regexp, opts probeOpts) []*vipState {
|
func buildVIPsUnion(cfgs []*config.Config, cfgPaths []string, filterRe *regexp.Regexp, opts probeOpts) []*vipState {
|
||||||
_ = cfgPaths // reserved for future diagnostics (e.g. which file this tuple came from)
|
_ = cfgPaths // reserved for future diagnostics (e.g. which file this tuple came from)
|
||||||
type key struct {
|
type key struct {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ type errEvent struct {
|
|||||||
// probeResultMsg handlers can update rolling/tally without copying
|
// probeResultMsg handlers can update rolling/tally without copying
|
||||||
// the whole model.
|
// the whole model.
|
||||||
type Model struct {
|
type Model struct {
|
||||||
cfgPath string
|
host string
|
||||||
vips []*vipState
|
vips []*vipState
|
||||||
opts probeOpts
|
opts probeOpts
|
||||||
startAt time.Time
|
startAt time.Time
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ func (m Model) viewHeader() string {
|
|||||||
}
|
}
|
||||||
line := fmt.Sprintf(
|
line := fmt.Sprintf(
|
||||||
"maglevt — %s — interval: %s timeout: %s header: %s [%s] uptime: %s",
|
"maglevt — %s — interval: %s timeout: %s header: %s [%s] uptime: %s",
|
||||||
m.cfgPath,
|
m.host,
|
||||||
m.opts.Interval,
|
m.opts.Interval,
|
||||||
m.opts.Timeout,
|
m.opts.Timeout,
|
||||||
m.opts.Header,
|
m.opts.Header,
|
||||||
|
|||||||
Reference in New Issue
Block a user