diff --git a/pkg/cmd/formatting.go b/pkg/cmd/formatting.go index 753fe8c..e9426f3 100644 --- a/pkg/cmd/formatting.go +++ b/pkg/cmd/formatting.go @@ -71,7 +71,7 @@ const ( dataSent = "DATA SENT" dataRec = "DATA REC" http200 = "200" - backlogMillis = "BACKLOG MS" + backlogMillis = "BACKLOG" ) var ( @@ -275,7 +275,7 @@ func FormatFederationDetails(federationDetails []config.FederationDescription, t formatLargeInteger(value.ReplicateAllPartitionErrorCount), formatLargeInteger(value.TotalReplicateAllPartitionsUnacked), formatLargeInteger(value.TotalRetryResponses), - formatLargeInteger(value.TransportBackloggedTime), + formatLatency0(float32(value.TransportBackloggedTime)), ) } else { table.AddColumnsToRow( @@ -314,15 +314,15 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar if OutputFormat == constants.TABLE { if target == destinations { - finalAlignment = []string{L, L, R, L, R, R, R, R} + finalAlignment = []string{L, L, R, L, R, R, R, R, R} } else { - finalAlignment = []string{L, L, R, R, R, R} + finalAlignment = []string{L, L, R, R, R, R, R} } } else { // WIDE if target == destinations { - finalAlignment = []string{L, L, R, L, R, R, R, R, R, R, R, R, R, R, R, R} + finalAlignment = []string{L, L, R, L, R, R, R, R, R, R, R, R, R, R, R, R, R} } else { - finalAlignment = []string{L, L, R, R, R, R, R, R} + finalAlignment = []string{L, L, R, R, R, R, R, R, R} } } @@ -339,7 +339,7 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar if target == destinations { table.WithHeader(ServiceColumn, participantCol, memberCol, "STATES", "DATA "+suffix, - "MSG "+suffix, "REC "+suffix, "CURR AVG BWIDTH") + "MSG "+suffix, "REC "+suffix, "TOTAL B/WIDTH", "AVG B/WIDTH") table.AddFormattingFunction(3, federationStateFormatter) } else { table.WithHeader(ServiceColumn, participantCol, memberCol, "DATA "+suffix, @@ -350,20 +350,21 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar if target == destinations { table.AddHeaderColumns(avgApply, "AVG ROUND TRIP", avgBacklogDelay, "REPLICATE", partitions, "ERRORS", "UNACKED", backlogMillis) - table.AddFormattingFunction(13, errorFormatter) table.AddFormattingFunction(14, errorFormatter) table.AddFormattingFunction(15, errorFormatter) + table.AddFormattingFunction(16, errorFormatter) } else { table.AddHeaderColumns(avgApply, avgBacklogDelay) } } var ( - bytes float64 - messages float64 - records float64 - members int32 - bandwidth string + bytes float64 + messages float64 + records float64 + members int32 + bandwidthAvg string + bandwidthTotal string ) for _, value := range federationSummaries { @@ -372,21 +373,23 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar messages = value.TotalMsgSent.Sum records = value.TotalRecordsSent.Sum members = int32(len(value.State)) - bandwidth = formatMbps(float32(value.CurrentBandwidth.Average)) + bandwidthAvg = formatMbps(float32(value.CurrentBandwidth.Average)) + bandwidthTotal = formatMbps(float32(value.CurrentBandwidth.Sum)) } else { bytes = value.TotalBytesReceived.Sum messages = value.TotalMsgReceived.Sum records = value.TotalRecordsReceived.Sum // if each of the members value is "N/A" then none are receiving members = utils.GetMemberCountReceiving(value.Member) - bandwidth = na + bandwidthAvg = na + bandwidthTotal = na } if target == destinations { table.AddRow(value.ServiceName, value.ParticipantName, formatSmallInteger(members), fmt.Sprintf("%v", utils.GetUniqueValues(value.State)), formattingFunction(int64(bytes)), formatLargeInteger(int64(messages)), - formatLargeInteger(int64(records)), bandwidth) + formatLargeInteger(int64(records)), bandwidthTotal, bandwidthAvg) } else { table.AddRow(value.ServiceName, value.ParticipantName, formatSmallInteger(members), @@ -404,7 +407,7 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar formatLargeInteger(int64(value.ReplicateAllPartitionCount.Sum)), formatLargeInteger(int64(value.ReplicateAllPartitionErrorCount.Sum)), formatLargeInteger(int64(value.TotalReplicateAllPartitionsUnacked.Sum)), - formatLargeInteger(int64(value.TransportBackloggedTime.Sum)), + formatLatency0(float32(value.TransportBackloggedTime.Sum)), ) } else { table.AddColumnsToRow( @@ -1926,7 +1929,7 @@ func FormatPersistenceServices(services []config.ServiceSummary, isSummary bool) formattingFunction(max(0, value.PersistenceActiveSpaceUsed)), formattingFunction(max(0, value.PersistenceBackupSpaceUsed)), formatLatency(float32(averageAverageLatency)), - formatLargeInteger(max(value.PersistenceLatencyMax, 0))+"ms") + formatLargeInteger(max(value.PersistenceLatencyMax, 0))+" ms") if isSummary { table.AddColumnsToRow(formatSmallInteger(int32(len(value.Snapshots))), value.OperationStatus) @@ -2221,17 +2224,17 @@ func formatLargeFloat(value float64) string { // formatLatency formats a float latency. func formatLatency(value float32) string { - return printer.Sprintf("%.3fms", value) + return printer.Sprintf("%.3f ms", value) } // formatLatency formats a float latency. func formatLatency0(value float32) string { - return printer.Sprintf("%.0fms", value) + return printer.Sprintf("%.0f ms", value) } // formatMbps formats a Mbps. func formatMbps(value float32) string { - return printer.Sprintf("%.1fMbps", value) + return printer.Sprintf("%.1f Mbps", value) } // formatPublisherReceiver formats a packet publisher/ receiver. diff --git a/pkg/cmd/formatting_test.go b/pkg/cmd/formatting_test.go index 08694ee..d4652bb 100644 --- a/pkg/cmd/formatting_test.go +++ b/pkg/cmd/formatting_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024 Oracle and/or its affiliates. + * Copyright (c) 2021, 2025 Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. */ @@ -28,10 +28,10 @@ func TestCreateCamelCaseLabel(t *testing.T) { func TestFormattingLatency(t *testing.T) { g := gomega.NewGomegaWithT(t) - g.Expect(formatLatency(123.333)).To(gomega.Equal("123.333ms")) - g.Expect(formatLatency(1)).To(gomega.Equal("1.000ms")) - g.Expect(formatLatency0(123)).To(gomega.Equal("123ms")) - g.Expect(formatMbps(123.2)).To(gomega.Equal("123.2Mbps")) + g.Expect(formatLatency(123.333)).To(gomega.Equal("123.333 ms")) + g.Expect(formatLatency(1)).To(gomega.Equal("1.000 ms")) + g.Expect(formatLatency0(123)).To(gomega.Equal("123 ms")) + g.Expect(formatMbps(123.2)).To(gomega.Equal("123.2 Mbps")) } func TestFormatting(t *testing.T) {