Skip to content

Commit

Permalink
7714 Windows Agent provides MSI Installation Log for update routine
Browse files Browse the repository at this point in the history
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

[CMK-3834] - log for MSI installation added to the agent

Change-Id: I58a2fbaee933f1ff13623449fc507fe57ab29931
  • Loading branch information
s-kipnis committed Jun 24, 2019
1 parent 4f2c0fa commit 11e568e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .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
17 changes: 16 additions & 1 deletion agents/wnx/src/engine/install_api.cpp
Expand Up @@ -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()));
Expand Down

0 comments on commit 11e568e

Please sign in to comment.