tidying
This commit is contained in:
@ -55,9 +55,34 @@ void list_servers() {
|
||||
auto servers = get_configured_servers();
|
||||
|
||||
tableprint tp("All DropShell Servers");
|
||||
tp.add_row({"Name", "Address"});
|
||||
tp.add_row({"Name", "Address", "Service Health", "Ports"});
|
||||
for (const auto& server : servers) {
|
||||
tp.add_row({server.name, server.ssh_host});
|
||||
std::vector<int> ports_used;
|
||||
std::string serviceticks = "";
|
||||
std::vector<std::string> services = get_server_services(server.name);
|
||||
for (const auto& service : services) {
|
||||
server_service ss;
|
||||
if (ss.init(server.name, service))
|
||||
{
|
||||
if (ss.is_healthy())
|
||||
serviceticks += ":tick: ";
|
||||
else
|
||||
serviceticks += ":cross: ";
|
||||
}
|
||||
std::vector<int> ports = ss.get_ports();
|
||||
ports_used.insert(ports_used.end(), ports.begin(), ports.end());
|
||||
}
|
||||
// convert ports_used to string
|
||||
std::string ports_used_str = "";
|
||||
bool first = true;
|
||||
for (const auto& port : ports_used) {
|
||||
if (!first) {
|
||||
ports_used_str += ", ";
|
||||
}
|
||||
ports_used_str += std::to_string(port);
|
||||
first = false;
|
||||
}
|
||||
tp.add_row({server.name, server.ssh_host, serviceticks, ports_used_str});
|
||||
}
|
||||
tp.print();
|
||||
}
|
||||
|
Reference in New Issue
Block a user