diff --git a/.werks/7714 b/.werks/7714 new file mode 100644 index 0000000000000..e91a491b53e51 --- /dev/null +++ b/.werks/7714 @@ -0,0 +1,18 @@ +Title: Windows Agent provides MSI Installation Log for update routine +Level: 1 +Component: checks +Compatible: compat +Edition: cre +Version: 1.6.0b3 +Date: 1561390579 +Class: feature + +Now Windows Agent creates MSI Installation Log file for every +automatically installed check_mk_agent.msi. + +Automatical Installation is performed by Update Plugin or it may be performed +manually if check_mk_agent.msi is copied to c:\ProgramData\CheckMK\Agent +\update folder + +The name of the log file is C:\Users\Public\agent_msi.log +Previous log file is backed up in C:\Users\Public\agent_msi.log.bak diff --git a/agents/wnx/src/engine/install_api.cpp b/agents/wnx/src/engine/install_api.cpp index 0a2a79a65b711..33d715deaae51 100644 --- a/agents/wnx/src/engine/install_api.cpp +++ b/agents/wnx/src/engine/install_api.cpp @@ -181,8 +181,23 @@ bool CheckForUpdateFile(std::wstring_view Name, std::wstring_view DirWithMsi, // is not a special standard command += L" /i " + msi_to_install.wstring(); + std::wstring log_file_name = cma::cfg::GetLogDir(); + log_file_name += L"\\agent_msi.log"; + if (fs::exists(log_file_name, ec)) { + XLOG::l.i("File '{0}' exists, backing up to '{0}.bak'", + wtools::ConvertToUTF8(log_file_name)); + + auto success = MvFile(log_file_name, log_file_name + L".bak"); + + if (!success) XLOG::d("Backing up failed"); + } + if (Update == UpdateType::exec_quiet) // this is only normal method - command += L" /qn"; // but MS doesn't care at all :) + { + command += L" /qn"; // but MS doesn't care at all :) + command += L" /L*V "; + command += log_file_name; + } XLOG::l.i("File '{}' exists\n Command is '{}'", msi_to_install.u8string(), wtools::ConvertToUTF8(command.c_str()));