diff --git a/pkg/es/node.go b/pkg/es/node.go index 89ebf0a..14609b8 100644 --- a/pkg/es/node.go +++ b/pkg/es/node.go @@ -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 implemented 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", @@ -134,18 +136,41 @@ func NodeShow(conf *cfg.Config, nodename string) error { stat.Os.Cpu.LoadAverage["1m"], )}, {"Open FD's", *stat.Process.OpenFileDescriptors}, - {"Response time avg", fmt.Sprintf("%dns", *stat.AdaptiveSelection[id].AvgResponseTimeNs)}, + {"HTTP sesssions current/total", fmt.Sprintf("%d/%d", + *stat.Http.CurrentOpen, + *stat.Http.TotalOpened, + )}, + {"Traffic rx/tx", + 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, + )}, + {"Search efficiency", stat.Indices.Search.QueryTimeInMillis / stat.Indices.Search.QueryTotal}, + {"Docs count", stat.Indices.Docs.Count}, + {"Merges current/total", fmt.Sprintf("%d/%d", + stat.Indices.Merges.Current, + stat.Indices.Merges.Total, + )}, + {"Merge docs count current/total", fmt.Sprintf("%d/%d", + stat.Indices.Merges.CurrentDocs, + stat.Indices.Merges.TotalDocs, + )}, + {"Merge size current/total", fmt.Sprintf("%s/%s", + printer.ByteString(stat.Indices.Merges.CurrentSizeInBytes), + printer.ByteString(stat.Indices.Merges.TotalSizeInBytes), + )}, + {"CircuitBreaker trip count", *stat.Breakers["fielddata"].Tripped}, } if len(stat.Fs.Data) > 0 { fs := stat.Fs.Data[0] - table.Entries = append(table.Entries, [][]any{ - {"Storage usage (used/avail)", - humanize.Bytes(uint64(*fs.AvailableInBytes)) + " / " + humanize.Bytes(uint64(*fs.TotalInBytes))}, - {"Storage mount", *fs.Mount}, - }...) + table.AddRow("Storage usage (used/avail)", + printer.ByteString(*fs.AvailableInBytes)+" / "+printer.ByteString(*fs.TotalInBytes)) + table.AddRow("Storage mount", *fs.Mount) } if err := table.Print(); err != nil { diff --git a/pkg/printer/bytes.go b/pkg/printer/bytes.go index cae3c58..39cfcb5 100644 --- a/pkg/printer/bytes.go +++ b/pkg/printer/bytes.go @@ -22,10 +22,16 @@ type ByteSize struct { size uint64 } -func Bytes(size int64) ByteSize { - return ByteSize{size: uint64(size)} -} - func (b *ByteSize) String() string { return humanize.Bytes(b.size) } + +func Bytes(size int64) *ByteSize { + return &ByteSize{size: uint64(size)} +} + +func ByteString(size int64) string { + b := ByteSize{size: uint64(size)} + + return b.String() +} diff --git a/pkg/printer/cast.go b/pkg/printer/cast.go index 8a3c27d..039b90a 100644 --- a/pkg/printer/cast.go +++ b/pkg/printer/cast.go @@ -38,12 +38,16 @@ func any2string(in any) string { return strconv.Itoa(val) case float64: return fmt.Sprintf("%.2f", val) + case float32: + return fmt.Sprintf("%.2f", val) case []string: return strings.Join(val, ",") case ByteSize: return val.String() case time.Time: return val.Format("2006-01-02 15:04:05") + case time.Duration: + return val.String() case []byte: return string(val) case nil: