Integrate in agent.
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "utils/directories.hpp"
|
||||
#include "services.hpp"
|
||||
#include "config.hpp"
|
||||
#include "templates.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@ -58,28 +59,19 @@ void list_servers() {
|
||||
tp.add_row({"Name", "Address", "Health", "Ports"});
|
||||
|
||||
std::for_each(std::execution::par, servers.begin(), servers.end(), [&](const ServerInfo& server) {
|
||||
std::vector<int> ports_used;
|
||||
std::string serviceticks = "";
|
||||
std::vector<ServiceInfo> services = get_server_services_info(server.name);
|
||||
|
||||
std::for_each(std::execution::par, services.begin(), services.end(), [&](const ServiceInfo& service) {
|
||||
service_runner ss;
|
||||
if (ss.init(server.name, service.service_name))
|
||||
serviceticks += ss.healthmark() + " ";
|
||||
else std::cout<<"Error: Failed to initialise service runner for server: ["<<server.name<<"] and service: ["<<service.service_name<<"]"<<std::endl;
|
||||
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;
|
||||
std::map<std::string, ServiceStatus> status = service_runner::get_all_services_status(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 += service_runner::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({server.name, server.ssh_host, serviceticks, ports_used_str});
|
||||
});
|
||||
tp.print();
|
||||
@ -161,5 +153,4 @@ void show_server_details(const std::string& server_name) {
|
||||
} // end of list services
|
||||
} // end of show_server_details
|
||||
|
||||
|
||||
} // namespace dropshell
|
||||
} // namespace dropshell
|
Reference in New Issue
Block a user