From beac005a449932c8734ceec0007272a45c3ea564 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 1 Oct 2020 20:56:09 +0200 Subject: [PATCH] RC1 pandoraFMS windows agent with omnishell reference --- .../win32/pandora_windows_service.cc | 22 ++++++++++++++----- .../win32/pandora_windows_service.h | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 3dd80d2a15..86ee82a3a0 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -1704,7 +1704,7 @@ Pandora_Windows_Service::checkConfig (string file) { } int -Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) { +Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) { int rc = 0, rc_sec = 0, xml_buffer; string data_xml; string xml_filename, random_integer; @@ -1785,10 +1785,13 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) { modules->goNext (); } } - + + /* Write extra content (omnishell, for instance) */ + data_xml += extra; + /* Close the XML header */ data_xml += ""; - + /* Generate temporal filename */ random_integer = inttostr (rand()); tmp_filename = conf->getValue ("agent_name"); @@ -2018,7 +2021,7 @@ Pandora_Windows_Service::pandora_run () { void Pandora_Windows_Service::pandora_run (int forced_run) { Pandora_Agent_Conf *conf = NULL; - string server_addr, conf_file, *all_conf; + string server_addr, conf_file, *all_conf, omnishell_output, omnishell_path; int startup_delay = 0; int i, num; static bool startup = true; @@ -2055,6 +2058,15 @@ Pandora_Windows_Service::pandora_run (int forced_run) { this->checkCollections (); } + + /* Execute omnishell commands */ + omnishell_path = Pandora::getPandoraInstallDir (); + omnishell_path += "util\\omnishell_client.exe \"" + conf_file+"\""; + if (getPandoraDebug () != false) { + pandoraLog ("Omnishell: Running"); + } + omnishell_output = getValueFromCmdExec(omnishell_path.c_str(), 6000000); + server_addr = conf->getValue ("server_ip"); execution_number++; @@ -2126,7 +2138,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { // Send the XML if (!server_addr.empty ()) { - this->sendXml (this->modules); + this->sendXml (this->modules, omnishell_output); } } diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index 3f9a89d685..aa5427ab8c 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -117,7 +117,7 @@ namespace Pandora { const char *svc_description); void start (); - int sendXml (Pandora_Module_List *modules); + int sendXml (Pandora_Module_List *modules, string extra = ""); void sendBufferedXml (string path, copy_func_p copy_func, bool secondary_buffer); Pandora_Agent_Conf *getConf (); string getEHKey (string ehorus_conf);