show green and failed indices in status, rename red to failed in index ls (#81)

This commit is contained in:
T. von Dein
2026-07-08 10:23:01 +02:00
parent 03cfeb4336
commit 8614e09004
4 changed files with 36 additions and 17 deletions

View File

@@ -174,11 +174,16 @@ func ClusterStatus(conf *cfg.Config) error {
}
// look for red indices, if any
redindices := 0
failedIndices := 0
greenIndices := 0
for _, index := range *res.indices {
if *index.Health == "red" {
redindices++
switch {
case *index.Health != "green":
failedIndices++
case !strings.HasPrefix(*index.Index, "."):
// don't count internal indices
greenIndices++
}
}
@@ -205,7 +210,8 @@ func ClusterStatus(conf *cfg.Config) error {
{"Unassigned Primary Shards", res.health.UnassignedPrimaryShards},
{"Pending Tasks", res.health.NumberOfPendingTasks},
{"Nodes", res.health.NumberOfNodes},
{"Red Indices", redindices},
{"Green Indices", greenIndices},
{"Failed Indices", failedIndices},
{"Long Running Tasks", longtasks},
}
@@ -233,6 +239,10 @@ func ClusterStatus(conf *cfg.Config) error {
for resource, items := range diag.AffectedResources {
table.Entries = append(table.Entries, []any{" -> affected " + resource, strings.Join(items, ",")})
}
if diag.Action != "" {
table.AddRow(" -> suggested action to fix", diag.Action)
}
}
}
}