-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[snmp] Add agent_group tag for snmp integration (#32004)
- Loading branch information
1 parent
7c5ac02
commit bbbad32
Showing
11 changed files
with
152 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2024-present Datadog, Inc. | ||
|
||
// Package haagenthelpers provides helpers for haagent component | ||
package haagenthelpers | ||
|
||
import ( | ||
"github.com/DataDog/datadog-agent/pkg/config/model" | ||
) | ||
|
||
// IsEnabled returns true if HA Agent is enabled | ||
func IsEnabled(agentConfig model.Reader) bool { | ||
return agentConfig.GetBool("ha_agent.enabled") | ||
} | ||
|
||
// GetGroup returns HA Agent group | ||
func GetGroup(agentConfig model.Reader) string { | ||
return agentConfig.GetString("ha_agent.group") | ||
} | ||
|
||
// GetHaAgentTags returns HA Agent related tags | ||
func GetHaAgentTags(agentConfig model.Reader) []string { | ||
return []string{"agent_group:" + GetGroup(agentConfig)} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2024-present Datadog, Inc. | ||
|
||
package haagenthelpers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/DataDog/datadog-agent/comp/core/config" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsEnabled(t *testing.T) { | ||
cfg := config.NewMock(t) | ||
assert.False(t, IsEnabled(cfg)) | ||
|
||
cfg.SetWithoutSource("ha_agent.enabled", true) | ||
assert.True(t, IsEnabled(cfg)) | ||
} | ||
|
||
func TestGetGroup(t *testing.T) { | ||
cfg := config.NewMock(t) | ||
cfg.SetWithoutSource("ha_agent.group", "my-group") | ||
assert.Equal(t, "my-group", GetGroup(cfg)) | ||
} | ||
|
||
func TestGetHaAgentTags(t *testing.T) { | ||
cfg := config.NewMock(t) | ||
cfg.SetWithoutSource("ha_agent.group", "my-group") | ||
assert.Equal(t, []string{"agent_group:my-group"}, GetHaAgentTags(cfg)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.