Skip to content

Commit

Permalink
17300 Windows agent do not use timeout on fail for section CpuLoad an…
Browse files Browse the repository at this point in the history
…d 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: I4fc70c6aa4d9b5a13442d4d6ea8eafc3e4248ed6
  • Loading branch information
s-kipnis committed Jan 15, 2025
1 parent 574231b commit 61793d7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
23 changes: 23 additions & 0 deletions .werks/17300.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[//]: # (werk v2)
# Windows agent do not use timeout on fail for section CpuLoad and DotNetClr

key | value
---------- | ---
date | 2025-01-14T15:55:31+00:00
version | 2.4.0b1
class | feature
edition | cre
component | checks
level | 1
compatible | yes


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 @@ -37,10 +37,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 @@ -145,7 +145,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 @@ -324,12 +324,11 @@ TEST(WmiProviderTest, SimulationComponent) {
{
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 @@ -378,7 +377,7 @@ TEST(WmiProviderTest, SimulationComponent) {
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 @@ -398,7 +397,7 @@ TEST(WmiProviderTest, SimulationComponent) {
// 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 @@ -513,12 +512,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 61793d7

Please sign in to comment.