|
49 | 49 | "default-members": "members:machines,departed-members:network-stats", |
50 | 50 | } |
51 | 51 | errSelectService = errors.New("you must provide a service name via -S option") |
| 52 | + errSelectParticipant = errors.New("you must provide a participant name via -p option") |
52 | 53 | errSelectCache = errors.New("you must provide a cache using the -C option") |
53 | 54 | errSelectTopic = errors.New("you must provide a topic using the -T option") |
54 | 55 | errSelectSubscriber = errors.New("you must provide a subscriber using the -B option") |
@@ -183,6 +184,10 @@ var validPanels = []panelImpl{ |
183 | 184 | createContentPanel(4, "federation-all", "Federation All", "show all federation details", federationAllContent, federationPanelData), |
184 | 185 | createContentPanel(3, "federation-dest", "Federation Destinations", "show federation destinations", federationDestinationsContent, federationPanelData), |
185 | 186 | createContentPanel(3, "federation-origins", "Federation Origins", "show federation origins", federationOriginsContent, federationPanelData), |
| 187 | + createContentPanel(7, "federation-con-outgoing", "Federation Connections Outgoing (%SERVICE)", "show federation connections outgoing", federationOutgoing), |
| 188 | + createContentPanel(7, "federation-con-incoming", "Federation Connections Incoming (%SERVICE)", "show federation connections incoming", federationIncoming), |
| 189 | + createContentPanel(7, "federation-outgoing", "Federation Details Outgoing (%SERVICE)", "show federation details outgoing", federationDetailsOutgoing), |
| 190 | + createContentPanel(7, "federation-incoming", "Federation Details Incoming (%SERVICE)", "show federation details incoming", federationDetailsIncoming), |
186 | 191 | createContentPanel(7, "http-servers", "HTTP Servers", "show HTTP servers", httpServersContent, proxiesPanelData), |
187 | 192 | createContentPanel(7, "http-sessions", "HTTP Sessions", "show HTTP sessions", httpSessionsContent, httpSessionsPanelData), |
188 | 193 | createContentPanel(7, "machines", "Machines", "show machines", machinesContent, memberPanelData, storagePanelData), |
@@ -1049,6 +1054,70 @@ var federationAllContent = func(_ fetcher.Fetcher, clusterSummary clusterSummary |
1049 | 1054 | return noContentArray, nil |
1050 | 1055 | } |
1051 | 1056 |
|
| 1057 | +var federationOutgoing = func(dataFetcher fetcher.Fetcher, _ clusterSummaryInfo) ([]string, error) { |
| 1058 | + return federationOutgoingAndIncoming(dataFetcher, outgoing) |
| 1059 | +} |
| 1060 | + |
| 1061 | +var federationIncoming = func(dataFetcher fetcher.Fetcher, _ clusterSummaryInfo) ([]string, error) { |
| 1062 | + return federationOutgoingAndIncoming(dataFetcher, incoming) |
| 1063 | +} |
| 1064 | + |
| 1065 | +func federationOutgoingAndIncoming(dataFetcher fetcher.Fetcher, federationDirection string) ([]string, error) { |
| 1066 | + if serviceName == "" { |
| 1067 | + return emptyStringArray, errSelectService |
| 1068 | + } |
| 1069 | + if participant == all { |
| 1070 | + return emptyStringArray, errSelectParticipant |
| 1071 | + } |
| 1072 | + |
| 1073 | + results, err := retrieveFederationDetails(dataFetcher, serviceName, federationDirection) |
| 1074 | + if err != nil { |
| 1075 | + return noContentArray, nil |
| 1076 | + } |
| 1077 | + |
| 1078 | + output, err2 := getFederationConnectionData(results, serviceName, federationDirection, participant) |
| 1079 | + if err2 != nil { |
| 1080 | + return noContentArray, nil |
| 1081 | + } |
| 1082 | + |
| 1083 | + return strings.Split(output, "\n"), nil |
| 1084 | +} |
| 1085 | + |
| 1086 | +func federationDetailsOutgoingAndIncoming(dataFetcher fetcher.Fetcher, federationDirection string) ([]string, error) { |
| 1087 | + if serviceName == "" { |
| 1088 | + return emptyStringArray, errSelectService |
| 1089 | + } |
| 1090 | + if participant == all { |
| 1091 | + return emptyStringArray, errSelectParticipant |
| 1092 | + } |
| 1093 | + |
| 1094 | + results, err := retrieveFederationDetails(dataFetcher, serviceName, federationDirection) |
| 1095 | + if err != nil { |
| 1096 | + return noContentArray, nil |
| 1097 | + } |
| 1098 | + |
| 1099 | + var sb strings.Builder |
| 1100 | + |
| 1101 | + sb.WriteString(getDescribeFederationHeader(serviceName, federationDirection, participant)) |
| 1102 | + |
| 1103 | + federationData, err := decodeFederationData(results) |
| 1104 | + if err != nil { |
| 1105 | + return noContentArray, nil |
| 1106 | + } |
| 1107 | + |
| 1108 | + sb.WriteString(FormatFederationDetails(federationData, describeFederationType)) |
| 1109 | + |
| 1110 | + return strings.Split(sb.String(), "\n"), nil |
| 1111 | +} |
| 1112 | + |
| 1113 | +var federationDetailsOutgoing = func(dataFetcher fetcher.Fetcher, _ clusterSummaryInfo) ([]string, error) { |
| 1114 | + return federationDetailsOutgoingAndIncoming(dataFetcher, outgoing) |
| 1115 | +} |
| 1116 | + |
| 1117 | +var federationDetailsIncoming = func(dataFetcher fetcher.Fetcher, _ clusterSummaryInfo) ([]string, error) { |
| 1118 | + return federationDetailsOutgoingAndIncoming(dataFetcher, incoming) |
| 1119 | +} |
| 1120 | + |
1052 | 1121 | var federationDestinationsContent = func(_ fetcher.Fetcher, clusterSummary clusterSummaryInfo) ([]string, error) { |
1053 | 1122 | if len(clusterSummary.finalSummariesDestinations) > 0 { |
1054 | 1123 | return strings.Split(FormatFederationSummary(clusterSummary.finalSummariesDestinations, destinations), "\n"), nil |
@@ -1669,12 +1738,12 @@ func getValidPanelTypes() string { |
1669 | 1738 | var sb strings.Builder |
1670 | 1739 | sb.WriteString("Default panels\n--------------\n") |
1671 | 1740 | for k, v := range defaultMap { |
1672 | | - sb.WriteString(fmt.Sprintf("%-22s: %s\n", k, v)) |
| 1741 | + sb.WriteString(fmt.Sprintf("%-25s: %s\n", k, v)) |
1673 | 1742 | } |
1674 | 1743 |
|
1675 | 1744 | sb.WriteString("\nIndividual panels\n-----------------\n") |
1676 | 1745 | for _, p := range validPanels { |
1677 | | - sb.WriteString(fmt.Sprintf("%-22s: %s\n", p.GetPanelName(), p.GetDescription())) |
| 1746 | + sb.WriteString(fmt.Sprintf("%-25s: %s\n", p.GetPanelName(), p.GetDescription())) |
1678 | 1747 | } |
1679 | 1748 |
|
1680 | 1749 | return sb.String() |
@@ -1705,6 +1774,7 @@ func init() { |
1705 | 1774 | monitorClusterCmd.Flags().BoolVarP(&ignoreRESTErrors, "ignore-errors", "I", false, "ignore errors after initial refresh") |
1706 | 1775 | monitorClusterCmd.Flags().BoolVarP(&disablePadding, "disable-padding", "D", false, "disable padding of panels by default") |
1707 | 1776 | monitorClusterCmd.Flags().StringVarP(&serviceName, serviceNameOption, "S", "", serviceNameDescription) |
| 1777 | + monitorClusterCmd.Flags().StringVarP(&participant, "participant", "p", all, participantMessage) |
1708 | 1778 | monitorClusterCmd.Flags().StringVarP(&selectedCache, "cache-name", "C", "", "cache name") |
1709 | 1779 | monitorClusterCmd.Flags().StringVarP(&selectedTopic, "topic-name", "T", "", "topic name") |
1710 | 1780 | monitorClusterCmd.Flags().StringVarP(&colorStyleParam, "style", "", "", "color style") |
|
0 commit comments