| 115 | } |
| 116 | |
| 117 | std::string getProcessAddressByServerID(StatusObjectReader processesMap, std::string serverID) { |
| 118 | if (serverID == "") |
| 119 | return "unknown"; |
| 120 | |
| 121 | for (auto proc : processesMap.obj()) { |
| 122 | try { |
| 123 | StatusArray rolesArray = proc.second.get_obj()["roles"].get_array(); |
| 124 | for (StatusObjectReader role : rolesArray) { |
| 125 | if (role["id"].get_str().find(serverID) == 0) { |
| 126 | // If this next line throws, then we found the serverID but the role has no address, so the role is |
| 127 | // skipped. |
| 128 | return proc.second.get_obj()["address"].get_str(); |
| 129 | } |
| 130 | } |
| 131 | } catch (std::exception&) { |
| 132 | // If an entry in the process map is badly formed then something will throw. Since we are |
| 133 | // looking for a positive match, just ignore any read execeptions and move on to the next proc |
| 134 | } |
| 135 | } |
| 136 | return "unknown"; |
| 137 | } |
| 138 | |
| 139 | std::string getWorkloadRates(StatusObjectReader statusObj, |
| 140 | bool unknown, |