add printer.ByteString() as shortcut

This commit is contained in:
2026-07-08 13:44:45 +02:00
parent b20f3b39a3
commit 56c636fa2a
2 changed files with 15 additions and 8 deletions

View File

@@ -26,7 +26,6 @@ import (
"codeberg.org/scip/esctl/pkg/cfg"
"codeberg.org/scip/esctl/pkg/printer"
"github.com/dustin/go-humanize"
)
func NodeList(conf *cfg.Config) error {
@@ -126,6 +125,9 @@ func NodeShow(conf *cfg.Config, nodename string) error {
{"OS", info.Os.PrettyName + " " + info.Os.Version},
{"Node roles", roles},
{"Node version", info.Version},
// FIXME: not implementet upstream
// see: https://github.com/elastic/go-elasticsearch/issues/1526
//{"Allocated shards", stat.Allocations.XXX},
{"HTTP clients", *stat.Http.CurrentOpen},
{"CPUs", *info.Os.AllocatedProcessors},
{"Load 15m/5m/1m", fmt.Sprintf("%.2f/%.2f/%.2f",
@@ -139,10 +141,10 @@ func NodeShow(conf *cfg.Config, nodename string) error {
*stat.Http.TotalOpened,
)},
{"Traffic rx/tx",
printer.Bytes(*stat.Transport.RxSizeInBytes).String() + " / " + printer.Bytes(*stat.Transport.TxSizeInBytes).String()},
printer.ByteString(*stat.Transport.RxSizeInBytes) + " / " + printer.ByteString(*stat.Transport.TxSizeInBytes)},
{"Response time avg", time.Duration(*stat.AdaptiveSelection[id].AvgResponseTimeNs)},
{"Memory usage (used/avail)",
humanize.Bytes(uint64(*stat.Os.Mem.UsedInBytes)) + " / " + humanize.Bytes(uint64(*stat.Os.Mem.TotalInBytes))},
printer.ByteString(*stat.Os.Mem.UsedInBytes) + " / " + printer.ByteString(*stat.Os.Mem.TotalInBytes)},
{"Search queries current/total", fmt.Sprintf("%d/%d",
stat.Indices.Search.QueryCurrent,
stat.Indices.Search.QueryTotal,
@@ -158,8 +160,8 @@ func NodeShow(conf *cfg.Config, nodename string) error {
stat.Indices.Merges.TotalDocs,
)},
{"Merge size current/total", fmt.Sprintf("%s/%s",
printer.Bytes(stat.Indices.Merges.CurrentSizeInBytes).String(),
printer.Bytes(stat.Indices.Merges.TotalSizeInBytes).String(),
printer.ByteString(stat.Indices.Merges.CurrentSizeInBytes),
printer.ByteString(stat.Indices.Merges.TotalSizeInBytes),
)},
{"CircuitBreaker trip count", *stat.Breakers["fielddata"].Tripped},
}
@@ -167,7 +169,7 @@ func NodeShow(conf *cfg.Config, nodename string) error {
if len(stat.Fs.Data) > 0 {
fs := stat.Fs.Data[0]
table.AddRow("Storage usage (used/avail)",
printer.Bytes(*fs.AvailableInBytes).String()+" / "+printer.Bytes(*fs.TotalInBytes).String())
printer.ByteString(*fs.AvailableInBytes)+" / "+printer.ByteString(*fs.TotalInBytes))
table.AddRow("Storage mount", *fs.Mount)
}