forked from prometheus/snmp_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
76 lines (63 loc) · 1.81 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import "github.com/prometheus/snmp_exporter/config"
// The generator config.
type Config struct {
Modules map[string]*ModuleConfig `yaml:"modules"`
XXX map[string]interface{} `yaml:",inline"`
}
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
type plain Config
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if err := config.CheckOverflow(c.XXX, "module"); err != nil {
return err
}
return nil
}
type MetricOverrides struct {
RegexpExtracts map[string][]config.RegexpExtract `yaml:"regex_extracts,omitempty"`
XXX map[string]interface{} `yaml:",inline"`
}
func (c *MetricOverrides) UnmarshalYAML(unmarshal func(interface{}) error) error {
type plain MetricOverrides
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if err := config.CheckOverflow(c.XXX, "overrides"); err != nil {
return err
}
return nil
}
type ModuleConfig struct {
Walk []string `yaml:"walk"`
Lookups []*Lookup `yaml:"lookups"`
WalkParams config.WalkParams `yaml:",inline"`
Overrides map[string]MetricOverrides `yaml:"overrides"`
XXX map[string]interface{} `yaml:",inline"`
}
func (c *ModuleConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
type plain ModuleConfig
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if err := config.CheckOverflow(c.XXX, "module"); err != nil {
return err
}
return nil
}
type Lookup struct {
OldIndex string `yaml:"old_index"`
NewIndex string `yaml:"new_index"`
XXX map[string]interface{} `yaml:",inline"`
}
func (c *Lookup) UnmarshalYAML(unmarshal func(interface{}) error) error {
type plain Lookup
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if err := config.CheckOverflow(c.XXX, "module"); err != nil {
return err
}
return nil
}