This commit is contained in:
Your Name
2025-04-21 21:14:09 +12:00
parent 49948e3b80
commit 5e2e2bc70f
2 changed files with 70 additions and 8 deletions

View File

@ -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();
}