-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* SNMP Exporter Scrape Configs (#2071) * Pass along additional scrape parameters for each snmp_target in the v1 integration * Pass along additional scrape parameters for each snmp_target in the v2 integration * Driveby fix for #2017 * Clear the walk_params map on unmarshal to support the config reload case * Update changelog for snmp integration changes * update changelog Co-authored-by: Ryan Geyer <[email protected]>
- Loading branch information
1 parent
02a9c93
commit 914b2a3
Showing
5 changed files
with
65 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package snmp_exporter | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
func TestSnmpConfig(t *testing.T) { | ||
t.Run("reload unmarshals", func(t *testing.T) { | ||
var config Config | ||
|
||
strConfig := `--- | ||
walk_params: | ||
keyone: | ||
auth: | ||
community: foo | ||
` | ||
|
||
// The first time should not return any errors. | ||
require.NoError(t, yaml.UnmarshalStrict([]byte(strConfig), &config), "initial unmarshal") | ||
require.Len(t, config.WalkParams, 1) | ||
|
||
// A second time (executed on reload), the map will already have the specified key(s), but should still succeed | ||
require.NoError(t, yaml.UnmarshalStrict([]byte(strConfig), &config), "reload unmarshal") | ||
require.Len(t, config.WalkParams, 1) | ||
}) | ||
} |