@@ -881,8 +881,20 @@ 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+ if (!getSw ()->isRunModeMultiSwitch ()) {
885+ counters = facebook::fb303::fbData->getRegexCounters (regex);
886+ } else {
887+ try {
888+ auto switchID = scopeResolver ().scope (portId).switchId ();
889+ auto hwTestClient = getHwAgentTestClient (switchID);
890+ hwTestClient->sync_getFb303RegexCounters (counters, regex);
891+ } catch (const std::exception& ex) {
892+ XLOG (WARNING )
893+ << " Failed to fetch remote fb303 counters via HwTestCtrl for port "
894+ << portId << " : " << ex.what ();
895+ counters = facebook::fb303::fbData->getRegexCounters (regex);
896+ }
897+ }
886898#endif
887899 return counters;
888900}
@@ -908,8 +920,19 @@ int64_t AgentEnsemble::getFb303Counter(
908920 client->getChannelShared ()};
909921 counter = monitoringClient.sync_getCounter (key);
910922#else
911- // TODO: This needs to be updated to support multi-switch.
912- counter = facebook::fb303::fbData->getCounter (key);
923+ if (!getSw ()->isRunModeMultiSwitch ()) {
924+ counter = facebook::fb303::fbData->getCounterIfExists (key).value_or (0 );
925+ } else {
926+ try {
927+ auto hwTestClient = getHwAgentTestClient (switchID);
928+ counter = hwTestClient->sync_getFb303Counter (key);
929+ } catch (const std::exception& ex) {
930+ XLOG (WARNING )
931+ << " Failed to fetch remote fb303 counter via HwTestCtrl for switch "
932+ << switchID << " : " << ex.what ();
933+ counter = facebook::fb303::fbData->getCounterIfExists (key).value_or (0 );
934+ }
935+ }
913936#endif
914937 return counter;
915938}
@@ -959,8 +982,19 @@ std::map<std::string, int64_t> AgentEnsemble::getFb303RegexCounters(
959982 client->getChannelShared ()};
960983 monitoringClient.sync_getRegexCounters (counters, regex);
961984#else
962- // TODO: This needs to be updated to support multi-switch.
963- counters = facebook::fb303::fbData->getRegexCounters (regex);
985+ if (!getSw ()->isRunModeMultiSwitch ()) {
986+ counters = facebook::fb303::fbData->getRegexCounters (regex);
987+ } else {
988+ try {
989+ auto hwTestClient = getHwAgentTestClient (switchID);
990+ hwTestClient->sync_getFb303RegexCounters (counters, regex);
991+ } catch (const std::exception& ex) {
992+ XLOG (WARNING )
993+ << " Failed to fetch remote fb303 counters via HwTestCtrl for switch "
994+ << switchID << " : " << ex.what ();
995+ counters = facebook::fb303::fbData->getRegexCounters (regex);
996+ }
997+ }
964998#endif
965999 return counters;
9661000}
0 commit comments