feat: Update 7 files
This commit is contained in:
@@ -171,6 +171,13 @@ namespace dropshell
|
||||
// Run all_status.sh on the remote server to get all service statuses in one call
|
||||
std::string agent_path = remotepath(server_name, user).agent();
|
||||
std::string script_path = agent_path + "/all_status.sh";
|
||||
|
||||
// Pass expected agent hash as argument for version checking
|
||||
std::string expected_hash = get_local_agent_hash();
|
||||
if (!expected_hash.empty()) {
|
||||
script_path += " " + expected_hash;
|
||||
}
|
||||
|
||||
std::string output;
|
||||
|
||||
sCommand cmd(agent_path, script_path, {});
|
||||
@@ -185,6 +192,17 @@ namespace dropshell
|
||||
try {
|
||||
nlohmann::json json_response = nlohmann::json::parse(output);
|
||||
|
||||
// Check agent hash match
|
||||
if (json_response.contains("agent_match") && json_response["agent_match"].is_boolean()) {
|
||||
if (!json_response["agent_match"].get<bool>()) {
|
||||
std::string remote_hash = json_response.contains("agent_hash") ?
|
||||
json_response["agent_hash"].get<std::string>() : "unknown";
|
||||
warning << "Agent mismatch on " << server_name << " (remote: " << remote_hash.substr(0, 8)
|
||||
<< "..., expected: " << expected_hash.substr(0, 8) << "...)" << std::endl;
|
||||
warning << "Run 'ds install " << server_name << "' to update the agent" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (!json_response.contains("services") || !json_response["services"].is_array()) {
|
||||
debug << "Invalid JSON response from all_status.sh" << std::endl;
|
||||
return status;
|
||||
|
||||
Reference in New Issue
Block a user