Ensure no negative padding

This commit is contained in:
Dionysus 2024-11-29 02:56:56 -05:00
parent dc52d4e862
commit e18be60221
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
2 changed files with 8 additions and 7 deletions

BIN
elastop

Binary file not shown.

View File

@ -691,11 +691,15 @@ func main() {
// Update header with dynamic padding
header.Clear()
latestVer := getLatestVersion()
padding := 0
if maxNodeNameLen > len(clusterStats.ClusterName) {
padding = maxNodeNameLen - len(clusterStats.ClusterName)
}
fmt.Fprintf(header, "[#00ffff]Cluster:[white] %s [%s]%s[-]%s[#00ffff]Latest: [white]%s\n",
clusterStats.ClusterName,
statusColor,
strings.ToUpper(clusterStats.Status),
strings.Repeat(" ", maxNodeNameLen-len(clusterStats.ClusterName)), // Dynamic padding
strings.Repeat(" ", padding),
latestVer)
fmt.Fprintf(header, "[#00ffff]Nodes:[white] %d Total, [green]%d[white] Successful, [#ff5555]%d[white] Failed\n",
clusterStats.Nodes.Total,
@ -939,12 +943,9 @@ func main() {
// Search metrics
fmt.Fprint(metricsPanel, formatMetric("Search Queries", formatNumber(int(totalQueries))))
fmt.Fprint(metricsPanel, formatMetric("Query Rate",
fmt.Sprintf("%s/s", formatNumber(int(float64(totalQueries)/time.Since(startTime).Seconds())))))
fmt.Fprint(metricsPanel, formatMetric("Total Query Time",
fmt.Sprintf("%.1fs", totalQueryTime)))
fmt.Fprint(metricsPanel, formatMetric("Avg Query Latency",
fmt.Sprintf("%.2fms", totalQueryTime*1000/float64(totalQueries+1))))
fmt.Fprint(metricsPanel, formatMetric("Query Rate", fmt.Sprintf("%s/s", formatNumber(int(float64(totalQueries)/time.Since(startTime).Seconds())))))
fmt.Fprint(metricsPanel, formatMetric("Total Query Time", fmt.Sprintf("%.1fs", totalQueryTime)))
fmt.Fprint(metricsPanel, formatMetric("Avg Query Latency", fmt.Sprintf("%.2fms", totalQueryTime*1000/float64(totalQueries+1))))
// Indexing metrics
fmt.Fprint(metricsPanel, formatMetric("Index Operations", formatNumber(int(totalIndexing))))