@@ -881,8 +881,8 @@ std::map<std::string, int64_t> AgentEnsemble::getFb303CountersByRegex(
881881 client->getChannelShared ()};
882882 monitoringClient.sync_getRegexCounters (counters, regex);
883883#else
884- // TODO: This needs to be updated to support multi-switch.
885- counters = facebook::fb303::fbData-> getRegexCounters ( regex);
884+ auto switchID = scopeResolver (). scope (portId). switchId ();
885+ counters = queryHwAgentFb303RegexCounters (switchID, regex);
886886#endif
887887 return counters;
888888}
@@ -908,8 +908,7 @@ int64_t AgentEnsemble::getFb303Counter(
908908 client->getChannelShared ()};
909909 counter = monitoringClient.sync_getCounter (key);
910910#else
911- // TODO: This needs to be updated to support multi-switch.
912- counter = facebook::fb303::fbData->getCounter (key);
911+ counter = queryHwAgentFb303Counter (switchID, key);
913912#endif
914913 return counter;
915914}
@@ -959,12 +958,51 @@ std::map<std::string, int64_t> AgentEnsemble::getFb303RegexCounters(
959958 client->getChannelShared ()};
960959 monitoringClient.sync_getRegexCounters (counters, regex);
961960#else
962- // TODO: This needs to be updated to support multi-switch.
963- counters = facebook::fb303::fbData->getRegexCounters (regex);
961+ counters = queryHwAgentFb303RegexCounters (switchID, regex);
964962#endif
965963 return counters;
966964}
967965
966+ std::map<std::string, int64_t > AgentEnsemble::queryHwAgentFb303RegexCounters (
967+ const SwitchID& switchID,
968+ const std::string& regex) {
969+ std::map<std::string, int64_t > counters;
970+ if (!getSw ()->isRunModeMultiSwitch ()) {
971+ counters = facebook::fb303::fbData->getRegexCounters (regex);
972+ } else {
973+ try {
974+ auto hwTestClient = getHwAgentTestClient (switchID);
975+ hwTestClient->sync_getFb303RegexCounters (counters, regex);
976+ } catch (const std::exception& ex) {
977+ XLOG (ERR )
978+ << " Failed to fetch remote fb303 counters via HwTestCtrl for switch "
979+ << switchID << " : " << ex.what ();
980+ throw ;
981+ }
982+ }
983+ return counters;
984+ }
985+
986+ int64_t AgentEnsemble::queryHwAgentFb303Counter (
987+ const SwitchID& switchID,
988+ const std::string& key) {
989+ int64_t counter{0 };
990+ if (!getSw ()->isRunModeMultiSwitch ()) {
991+ counter = facebook::fb303::fbData->getCounter (key);
992+ } else {
993+ try {
994+ auto hwTestClient = getHwAgentTestClient (switchID);
995+ counter = hwTestClient->sync_getFb303Counter (key);
996+ } catch (const std::exception& ex) {
997+ XLOG (ERR )
998+ << " Failed to fetch remote fb303 counter via HwTestCtrl for switch "
999+ << switchID << " : " << ex.what ();
1000+ throw ;
1001+ }
1002+ }
1003+ return counter;
1004+ }
1005+
9681006std::string AgentEnsemble::getHwDebugDump () {
9691007 std::string out{};
9701008 ThriftHandler (getSw ()).getHwDebugDump (out);
0 commit comments