add more important node stats

This commit is contained in:
2026-07-08 11:47:07 +02:00
parent 8614e09004
commit b20f3b39a3
3 changed files with 35 additions and 8 deletions

View File

@@ -134,18 +134,41 @@ func NodeShow(conf *cfg.Config, nodename string) error {
stat.Os.Cpu.LoadAverage["1m"], stat.Os.Cpu.LoadAverage["1m"],
)}, )},
{"Open FD's", *stat.Process.OpenFileDescriptors}, {"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.Bytes(*stat.Transport.RxSizeInBytes).String() + " / " + printer.Bytes(*stat.Transport.TxSizeInBytes).String()},
{"Response time avg", time.Duration(*stat.AdaptiveSelection[id].AvgResponseTimeNs)},
{"Memory usage (used/avail)", {"Memory usage (used/avail)",
humanize.Bytes(uint64(*stat.Os.Mem.UsedInBytes)) + " / " + humanize.Bytes(uint64(*stat.Os.Mem.TotalInBytes))}, humanize.Bytes(uint64(*stat.Os.Mem.UsedInBytes)) + " / " + humanize.Bytes(uint64(*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.Bytes(stat.Indices.Merges.CurrentSizeInBytes).String(),
printer.Bytes(stat.Indices.Merges.TotalSizeInBytes).String(),
)},
{"CircuitBreaker trip count", *stat.Breakers["fielddata"].Tripped},
} }
if len(stat.Fs.Data) > 0 { if len(stat.Fs.Data) > 0 {
fs := stat.Fs.Data[0] fs := stat.Fs.Data[0]
table.Entries = append(table.Entries, [][]any{ table.AddRow("Storage usage (used/avail)",
{"Storage usage (used/avail)", printer.Bytes(*fs.AvailableInBytes).String()+" / "+printer.Bytes(*fs.TotalInBytes).String())
humanize.Bytes(uint64(*fs.AvailableInBytes)) + " / " + humanize.Bytes(uint64(*fs.TotalInBytes))}, table.AddRow("Storage mount", *fs.Mount)
{"Storage mount", *fs.Mount},
}...)
} }
if err := table.Print(); err != nil { if err := table.Print(); err != nil {

View File

@@ -22,8 +22,8 @@ type ByteSize struct {
size uint64 size uint64
} }
func Bytes(size int64) ByteSize { func Bytes(size int64) *ByteSize {
return ByteSize{size: uint64(size)} return &ByteSize{size: uint64(size)}
} }
func (b *ByteSize) String() string { func (b *ByteSize) String() string {

View File

@@ -38,12 +38,16 @@ func any2string(in any) string {
return strconv.Itoa(val) return strconv.Itoa(val)
case float64: case float64:
return fmt.Sprintf("%.2f", val) return fmt.Sprintf("%.2f", val)
case float32:
return fmt.Sprintf("%.2f", val)
case []string: case []string:
return strings.Join(val, ",") return strings.Join(val, ",")
case ByteSize: case ByteSize:
return val.String() return val.String()
case time.Time: case time.Time:
return val.Format("2006-01-02 15:04:05") return val.Format("2006-01-02 15:04:05")
case time.Duration:
return val.String()
case []byte: case []byte:
return string(val) return string(val)
case nil: case nil: