mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 12:54:18 +02:00
add printer.ByteString() as shortcut
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,15 @@ type ByteSize struct {
|
||||
size uint64
|
||||
}
|
||||
|
||||
func (b *ByteSize) String() string {
|
||||
return humanize.Bytes(b.size)
|
||||
}
|
||||
|
||||
func Bytes(size int64) *ByteSize {
|
||||
return &ByteSize{size: uint64(size)}
|
||||
}
|
||||
|
||||
func (b *ByteSize) String() string {
|
||||
return humanize.Bytes(b.size)
|
||||
func ByteString(size int64) string {
|
||||
b := ByteSize{size: uint64(size)}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user