diff --git a/assets/header.tmpl b/assets/header.tmpl index a7ac158..cbfa57e 100644 --- a/assets/header.tmpl +++ b/assets/header.tmpl @@ -52,6 +52,10 @@ table { host {{ .Hostname }} + + kernel + {{ .Kernel }} + {{ if (ne .Model "") }} model diff --git a/internal/bundled/GENERATED_bundled.go b/internal/bundled/GENERATED_bundled.go index 2a2211d..2946150 100644 --- a/internal/bundled/GENERATED_bundled.go +++ b/internal/bundled/GENERATED_bundled.go @@ -12,7 +12,7 @@ var assets = map[string][]byte{ "assets/bootstrap-table-1.11.0.min.js": assets_7, "assets/jquery-3.1.1.min.js": assets_8, } -var assets_0 = []byte("\n\n{{ .Hostname }} — gokrazy\n\n\n\n\n \n\n
\n") +var assets_0 = []byte("\n\n{{ .Hostname }} — gokrazy\n\n\n\n\n \n\n
\n") var assets_1 = []byte("\n
\n\n\n\n\n\n") var assets_2 = []byte("{{ template \"header\" . }}\n\n
\n
\n\n

services

\n\n\n\n\n\n\n\n{{ range $idx, $svc := .Services }}\n\n\n\n\n{{ end }}\n\n
pathlast log line
\n{{ $svc.Name }}\n{{ if restarting $svc.Started }}\nrestarting\n{{ end }}\n{{ if $svc.Stopped }}\nstopped\n{{ end }}\n\n{{ last $svc.Stdout.Lines $svc.Stderr.Lines }}\n
\n
\n
\n

memory

\n{{ megabytes (index .Meminfo \"MemTotal\") }} total, {{ megabytes (index .Meminfo \"MemAvailable\") }} available
\nresident set size (RSS) by service:\n
\n\n{{ with $rss := initRss }}\n
\n\ninit\n
\n{{ end }}\n\n{{ range $idx, $svc := .Services }}\n{{ with $rss := $svc.RSS }}\n
\n\n{{ baseName $svc.Name }}\n
\n{{ end }}\n{{ end }}\n
\n\nunaccounted\n
\n
\n
\n\n
\n\n\n

storage

\n\n{{ if eq .PermAvail 0 }}\n\n{{ if ne .PARTUUID \"\" }}\nNo permanent storage mounted. To create a filesystem for permanent storage, plug the SD card into a Linux computer and use mkfs.ext4 /dev/disk/by-partuuid/{{ .PARTUUID }}-04.\n{{ else }}\nNo permanent storage mounted. To create a filesystem for permanent storage, plug the SD card into a Linux computer and, if your SD card is /dev/sdb, use mkfs.ext4 /dev/sdb4.\n{{ end }}\n\n{{ else }}\n{{ .PermDev }}: {{ gigabytes .PermTotal }} total, {{ gigabytes .PermUsed }} used, {{ gigabytes .PermAvail }} avail
\n{{ end }}\n\n

private network addresses

\n
    \n{{ range $idx, $addr := .PrivateAddrs }}\n
  • {{ $addr }}
  • \n{{ end }}\n
\n\n

public network addresses

\n
    \n{{ range $idx, $addr := .PublicAddrs }}\n
  • {{ $addr }}
  • \n{{ end }}\n
\n\n\n
\n
\n\n{{ template \"footer\" . }}\n") var assets_3 = []byte("{{ template \"header\" . }}\n\n
\n
\n\n\n\n\n\n\n\n\n\n\n\n
NameStartedActions
{{ .Service.Name }}{{ .Service.Started }}\n
\n \n \n \n
\n
\n \n \n \n
\n\n

module info

\n
{{ .Service.ModuleInfo }}
\n\n

stdout

\n
\n  {{ range $idx, $line := .Service.Stdout.Lines -}}\n    {{ $line }}\n  {{ end }}\n  
\n\n

stderr

\n
\n  {{ range $idx, $line := .Service.Stderr.Lines -}}\n    {{ $line }}\n  {{ end }}\n  
\n
\n
\n\n{{ template \"footer\" . }}\n") diff --git a/status.go b/status.go index 49619ac..61d3024 100644 --- a/status.go +++ b/status.go @@ -151,6 +151,21 @@ func lastInstalledEepromVersion() (*eepromVersion, error) { return result, nil } +func parseUtsname(u unix.Utsname) string { + if u == (unix.Utsname{}) { + // Empty utsname, no info to parse. + return "unknown" + } + + str := func(b [65]byte) string { + // Trim all trailing NULL bytes. + return string(bytes.TrimRight(b[:], "\x00")) + } + + return fmt.Sprintf("%s %s (%s)", + str(u.Sysname), str(u.Release), str(u.Machine)) +} + func initStatus(services []*service) { model := Model() @@ -159,6 +174,12 @@ func initStatus(services []*service) { log.Printf("getting EEPROM version: %v", err) } + var uname unix.Utsname + if err := unix.Uname(&uname); err != nil { + log.Printf("getting uname: %v", err) + } + kernel := parseUtsname(uname) + commonTmpls := template.New("root").Funcs(map[string]interface{}{ "shortenSHA256": func(hash string) string { if len(hash) > 10 { @@ -251,6 +272,7 @@ func initStatus(services []*service) { Model string XsrfToken int32 EEPROM *eepromVersion + Kernel string }{ Service: svc, BuildTimestamp: buildTimestamp, @@ -258,6 +280,7 @@ func initStatus(services []*service) { Model: model, XsrfToken: token, EEPROM: lastInstalledEepromVersion, + Kernel: kernel, }); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -301,6 +324,7 @@ func initStatus(services []*service) { Model string PARTUUID string EEPROM *eepromVersion + Kernel string }{ Services: services, PermDev: rootdev.Partition(rootdev.Perm), @@ -315,6 +339,7 @@ func initStatus(services []*service) { Model: model, PARTUUID: rootdev.PARTUUID(), EEPROM: lastInstalledEepromVersion, + Kernel: kernel, }); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return