Skip to content

Commit

Permalink
17300 Windows agent do not use timeout on fail for section CpuLoad a…
Browse files Browse the repository at this point in the history
…nd DotNetClr

Previously, after a WMI error occurred during the generation of
specific WMI sections, particularly the CpuLoad and DotNetClr sections,
the agent would stop creating these sections for a period of one
hour. This was done to reduce noise in the log file. However,
this approach led to situations where a random WMI failure could
prevent data collection for an hour.

Since this release the delay for the CpuLoad and DotNetclr sections is
eliminated thus making monitoring more smooth.

Change-Id: I12f92a5a8d7a517e91f75d7c07f523917df33aae
  • Loading branch information
s-kipnis committed Jan 15, 2025
1 parent 0a50b26 commit 19a0003
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
19 changes: 19 additions & 0 deletions .werks/17300
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Title: Windows agent do not use timeout on fail for section CpuLoad and DotNetClr
Class: feature
Compatible: compat
Component: checks
Date: 1736870131
Edition: cre
Level: 1
Version: 2.2.0p39


Previously, after a WMI error occurred during the generation of
specific WMI sections, particularly the CpuLoad and DotNetClr sections,
the agent would stop creating these sections for a period of one
hour. This was done to reduce noise in the log file. However,
this approach led to situations where a random WMI failure could
prevent data collection for an hour.

Since this release, the delay on fail or the CpuLoad and DotNetClr
sections is eliminated thus making monitoring more smooth.
11 changes: 6 additions & 5 deletions agents/wnx/src/engine/providers/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const std::unordered_map<std::string_view, std::chrono::seconds>
&GetDelaysOnFail() {
const static std::unordered_map<std::string_view, std::chrono::seconds>
delays_on_fail = {
{kDotNetClrMemory, cfg::G_DefaultDelayOnFail}, //
{kWmiWebservices, cfg::G_DefaultDelayOnFail}, //
{kWmiCpuLoad, cfg::G_DefaultDelayOnFail}, //
{kMsExch, cfg::G_DefaultDelayOnFail}, //
{kDotNetClrMemory, 0s}, //
{kWmiWebservices, cfg::G_DefaultDelayOnFail}, //
{kWmiCpuLoad, 0s}, //
{kMsExch, cfg::G_DefaultDelayOnFail}, //
{kOhm, cfg::G_DefaultDelayOnFail},

// end of the real sections
Expand Down Expand Up @@ -129,7 +129,8 @@ void Basic::setupDelayOnFail() noexcept {
const auto &delay_in_seconds = GetDelaysOnFail().at(uniq_name_);
delay_on_fail_ = delay_in_seconds;
} catch (const std::out_of_range &) {
// do nothing here
XLOG::l.crit("Unsupported section name {}", uniq_name_);
delay_on_fail_ = std::chrono::seconds(0);
}
}

Expand Down
15 changes: 9 additions & 6 deletions agents/wnx/watest/test-section_wmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,11 @@ TEST(WmiProviderTest, SimulationIntegration) {
{
Wmi dotnet_clr(kDotNetClrMemory, wmi::kSepChar);
EXPECT_EQ(dotnet_clr.subsectionMode(), SubSection::Mode::standard);
EXPECT_EQ(dotnet_clr.delayOnFail(), cma::cfg::G_DefaultDelayOnFail);
EXPECT_EQ(dotnet_clr.delayOnFail(), 0s);
EXPECT_EQ(dotnet_clr.object(),
L"Win32_PerfRawData_NETFramework_NETCLRMemory");
EXPECT_TRUE(dotnet_clr.isAllowedByCurrentConfig());
EXPECT_TRUE(dotnet_clr.isAllowedByTime());
EXPECT_EQ(dotnet_clr.delayOnFail(), 3600s);

EXPECT_EQ(dotnet_clr.nameSpace(), L"Root\\Cimv2");
std::string body;
Expand Down Expand Up @@ -383,7 +382,7 @@ TEST(WmiProviderTest, SimulationIntegration) {
Wmi cpu(kWmiCpuLoad, wmi::kSepChar);
EXPECT_EQ(cpu.subsectionMode(), SubSection::Mode::standard);
ASSERT_FALSE(cpu.headerless());
EXPECT_EQ(cpu.delayOnFail(), cma::cfg::G_DefaultDelayOnFail);
EXPECT_EQ(cpu.delayOnFail(), 0s);

// this is empty section
EXPECT_EQ(cpu.object(), L"");
Expand All @@ -403,7 +402,7 @@ TEST(WmiProviderTest, SimulationIntegration) {
// other:
EXPECT_TRUE(cpu.isAllowedByCurrentConfig());
EXPECT_TRUE(cpu.isAllowedByTime());
EXPECT_EQ(cpu.delayOnFail(), 3600s);
EXPECT_EQ(cpu.delayOnFail(), 0s);
}
{
Wmi msexch(kMsExch, wmi::kSepChar);
Expand Down Expand Up @@ -518,12 +517,16 @@ TEST(WmiProviderTest, BasicWmi) {
}

TEST(WmiProviderTest, DelayOnFailDefault) {
for (const auto name :
{kOhm, kWmiCpuLoad, kWmiWebservices, kDotNetClrMemory, kMsExch}) {
for (const auto name : {kOhm, kWmiWebservices, kMsExch}) {
Wmi b(name, ',');
EXPECT_EQ(b.delayOnFail(), 3600s)
<< "bad delay for section by default " << name;
}
for (const auto name : {kWmiCpuLoad, kDotNetClrMemory}) {
Wmi b(name, ',');
EXPECT_EQ(b.delayOnFail(), 0s)
<< "bad delay for section by default " << name;
}
}

TEST(WmiProviderTest, DelayOnFailShift) {
Expand Down

0 comments on commit 19a0003

Please sign in to comment.