summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/app/store.go7
-rw-r--r--internal/config/config.go20
-rw-r--r--internal/display/display.go59
-rw-r--r--internal/version/version.go2
4 files changed, 43 insertions, 45 deletions
diff --git a/internal/app/store.go b/internal/app/store.go
index 9e046a4..ffe00c8 100644
--- a/internal/app/store.go
+++ b/internal/app/store.go
@@ -21,6 +21,10 @@ type hostData struct {
cpu map[string]collector.CPULine
}
+// Compile-time interface satisfaction checks.
+var _ stats.Source = (*Store)(nil)
+var _ collector.StatsStore = (*Store)(nil)
+
// NewStore creates an empty store.
func NewStore() *Store {
return &Store{hosts: make(map[string]*hostData)}
@@ -98,6 +102,3 @@ func (s *Store) getOrCreate(host string) *hostData {
}
return s.hosts[host]
}
-
-var _ stats.Source = (*Store)(nil)
-var _ collector.StatsStore = (*Store)(nil)
diff --git a/internal/config/config.go b/internal/config/config.go
index 1b4c9e1..9daf6d2 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -24,14 +24,14 @@ type Config struct {
MaxWidth int
NetAverage int
NetLink string
- ShowAvgLine bool
- ShowIOAvgLine bool
- ShowCores bool
- ShowMem bool
+ ShowAvgLine bool
+ ShowIOAvgLine bool
+ ShowCores bool
+ ShowMem bool
ShowNet bool
ShowSeparators bool
SSHOpts string
- Cluster string
+ Cluster string
}
// Default returns a Config with default values.
@@ -182,11 +182,6 @@ func (c *Config) set(key, val string) {
}
}
-func parseBool(s string) bool {
- s = strings.TrimSpace(strings.ToLower(s))
- return s == "1" || s == "true" || s == "yes"
-}
-
func (c *Config) writeTo(f *os.File) error {
w := bufio.NewWriter(f)
writeInt := func(key string, v int) { fmt.Fprintf(w, "%s=%d\n", key, v) }
@@ -217,6 +212,11 @@ func (c *Config) writeTo(f *os.File) error {
return w.Flush()
}
+func parseBool(s string) bool {
+ s = strings.TrimSpace(strings.ToLower(s))
+ return s == "1" || s == "true" || s == "yes"
+}
+
func getClusterHostsRec(cluster, path string, depth int, seen map[string]bool) ([]string, error) {
if depth > constants.CSSHMaxRecursion {
return nil, fmt.Errorf("cluster recursion limit reached in %s (possible cycle)", path)
diff --git a/internal/display/display.go b/internal/display/display.go
index d3f27ca..d31bdcb 100644
--- a/internal/display/display.go
+++ b/internal/display/display.go
@@ -19,43 +19,47 @@ import (
const smoothFactor = 0.12 // blend toward target each frame; lower = smoother
+// linkScales lists the supported network link speeds in ascending order,
+// used by the f/v hotkeys to cycle through link scale values.
+var linkScales = []string{"mbit", "10mbit", "100mbit", "gbit", "10gbit"}
+
// runState holds mutable state across the display loop (hotkeys, window size, smoothed data).
type runState struct {
- showAvgLine bool
- showIOAvgLine bool
- showCores bool
- showMem bool
+ showAvgLine bool
+ showIOAvgLine bool
+ showCores bool
+ showMem bool
showNet bool
showSeparators bool
extended bool
- winW int32
- winH int32
- prevCPU map[string]collector.CPULine
- smoothedCPU map[string]*[10]float64
- smoothedMem map[string]*struct{ ramUsed, swapUsed float64 }
- smoothedNet map[string]*struct{ rxPct, txPct float64 }
- prevNet map[string]stats.NetStamp // aggregated (summed) previous net stamp per host
- peakHistory map[string][]float64
+ winW int32
+ winH int32
+ prevCPU map[string]collector.CPULine
+ smoothedCPU map[string]*[10]float64
+ smoothedMem map[string]*struct{ ramUsed, swapUsed float64 }
+ smoothedNet map[string]*struct{ rxPct, txPct float64 }
+ prevNet map[string]stats.NetStamp // aggregated (summed) previous net stamp per host
+ peakHistory map[string][]float64
}
// newRunState builds initial run state from config.
func newRunState(cfg *config.Config, winW, winH int32) *runState {
return &runState{
- showAvgLine: cfg.ShowAvgLine,
- showIOAvgLine: cfg.ShowIOAvgLine,
- showCores: cfg.ShowCores,
- showMem: cfg.ShowMem,
+ showAvgLine: cfg.ShowAvgLine,
+ showIOAvgLine: cfg.ShowIOAvgLine,
+ showCores: cfg.ShowCores,
+ showMem: cfg.ShowMem,
showNet: cfg.ShowNet,
showSeparators: cfg.ShowSeparators,
extended: cfg.Extended,
- winW: winW,
- winH: winH,
- prevCPU: make(map[string]collector.CPULine),
- smoothedCPU: make(map[string]*[10]float64),
- smoothedMem: make(map[string]*struct{ ramUsed, swapUsed float64 }),
- smoothedNet: make(map[string]*struct{ rxPct, txPct float64 }),
- prevNet: make(map[string]stats.NetStamp),
- peakHistory: make(map[string][]float64),
+ winW: winW,
+ winH: winH,
+ prevCPU: make(map[string]collector.CPULine),
+ smoothedCPU: make(map[string]*[10]float64),
+ smoothedMem: make(map[string]*struct{ ramUsed, swapUsed float64 }),
+ smoothedNet: make(map[string]*struct{ rxPct, txPct float64 }),
+ prevNet: make(map[string]stats.NetStamp),
+ peakHistory: make(map[string][]float64),
}
}
@@ -633,13 +637,6 @@ func printHotkeys() {
fmt.Println("=> Hotkeys: 1=cores 2/m=mem 3/n=net e=extended g=avg line i=io avg s=separators h=help q=quit w=write config a/y=cpu avg d/c=net avg f/v=link scale arrows=resize")
}
-
-// netLinkBytesPerSec returns link speed in bytes/sec from cfg.NetLink (e.g. "gbit", "10gbit", "100mbit", or numeric mbit).
-
-// linkScales lists the supported network link speeds in ascending order,
-// used by the f/v hotkeys to cycle through link scale values.
-var linkScales = []string{"mbit", "10mbit", "100mbit", "gbit", "10gbit"}
-
// scaleLinkUp moves cfg.NetLink to the next higher link speed in linkScales.
// Clamps at the maximum (10gbit).
func scaleLinkUp(cfg *config.Config) {
diff --git a/internal/version/version.go b/internal/version/version.go
index 1cb63c3..bc3d485 100644
--- a/internal/version/version.go
+++ b/internal/version/version.go
@@ -1,4 +1,4 @@
package version
// Version is the application version (set at build time or here for development).
-const Version = "0.10.0"
+const Version = "0.10.1"