This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "servers.hpp"
|
||||
#include "tableprint.hpp"
|
||||
#include "transwarp.hpp"
|
||||
#include "server_env_manager.hpp"
|
||||
#include "servers.hpp"
|
||||
#include "services.hpp"
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -81,26 +81,40 @@ void list_servers() {
|
||||
}
|
||||
|
||||
tableprint tp("All DropShell Servers");
|
||||
tp.add_row({"Name", "User", "Address", "Health", "Ports"});
|
||||
tp.add_row({"Name", "Address", "User", "Health", "Ports"});
|
||||
|
||||
info << "Checking "<<servers.size() << " servers: " << std::flush;
|
||||
int checked = 0;
|
||||
|
||||
transwarp::parallel exec{servers.size()};
|
||||
auto task = transwarp::for_each(exec, servers.begin(), servers.end(), [&](const ServerInfo& server) {
|
||||
std::map<std::string, shared_commands::ServiceStatus> status = shared_commands::get_all_services_status(server.name);
|
||||
auto task = transwarp::for_each(exec, servers.begin(), servers.end(), [&](const server_config& server) {
|
||||
|
||||
std::set<int> ports_used;
|
||||
std::string serviceticks = "";
|
||||
for (const auto& [service_name, service_status] : status) {
|
||||
ports_used.insert(service_status.ports.begin(), service_status.ports.end());
|
||||
serviceticks += shared_commands::HealthStatus2String(service_status.health) + " ";
|
||||
server_config server_env(server.get_server_name());
|
||||
if (!server_env.is_valid())
|
||||
{
|
||||
error << "Invalid server environment for " << server.get_server_name() << std::endl;
|
||||
return;
|
||||
}
|
||||
std::string ports_used_str = "";
|
||||
for (const auto& port : ports_used)
|
||||
ports_used_str += std::to_string(port) + " ";
|
||||
|
||||
tp.add_row({server.name, server.ssh_user, server.ssh_host, serviceticks, ports_used_str});
|
||||
|
||||
int first=true;
|
||||
for (const auto &user : server_env.get_users())
|
||||
{
|
||||
std::map<std::string, shared_commands::ServiceStatus> status = shared_commands::get_all_services_status(server.get_server_name());
|
||||
|
||||
std::set<int> ports_used;
|
||||
std::string serviceticks = "";
|
||||
for (const auto& [service_name, service_status] : status) {
|
||||
ports_used.insert(service_status.ports.begin(), service_status.ports.end());
|
||||
serviceticks += shared_commands::HealthStatus2String(service_status.health) + " ";
|
||||
}
|
||||
std::string ports_used_str = "";
|
||||
for (const auto& port : ports_used)
|
||||
ports_used_str += std::to_string(port) + " ";
|
||||
|
||||
tp.add_row({(first ? server.get_server_name() : ""), (first ? server.get_SSH_HOST() : ""), user.user, serviceticks, ports_used_str});
|
||||
first = false;
|
||||
}
|
||||
|
||||
++checked;
|
||||
// print out a tick character for each server checked.
|
||||
info << checked << " ✓ " << std::flush;
|
||||
@@ -114,7 +128,7 @@ void list_servers() {
|
||||
|
||||
|
||||
void show_server_details(const std::string& server_name) {
|
||||
server_env_manager env(server_name);
|
||||
server_config env(server_name);
|
||||
if (!env.is_valid()) {
|
||||
error << "Error: Invalid server environment file: " << server_name << std::endl;
|
||||
return;
|
||||
|
Reference in New Issue
Block a user