mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-03-05 21:00:12 -08:00
Merge refactor changes merge
This commit is contained in:
commit
33af25f572
|
@ -93,13 +93,16 @@ func newDiskstatsDeviceFilter(config DiskstatsDeviceFilterConfig, logger log.Log
|
||||||
|
|
||||||
if *config.DeviceExclude != "" {
|
if *config.DeviceExclude != "" {
|
||||||
level.Info(logger).Log("msg", "Parsed flag --collector.diskstats.device-exclude", "flag", *config.DeviceExclude)
|
level.Info(logger).Log("msg", "Parsed flag --collector.diskstats.device-exclude", "flag", *config.DeviceExclude)
|
||||||
} else {
|
|
||||||
*config.DeviceExclude = diskstatsDefaultIgnoredDevices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *config.DeviceInclude != "" {
|
if *config.DeviceInclude != "" {
|
||||||
level.Info(logger).Log("msg", "Parsed Flag --collector.diskstats.device-include", "flag", *config.DeviceInclude)
|
level.Info(logger).Log("msg", "Parsed Flag --collector.diskstats.device-include", "flag", *config.DeviceInclude)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !config.DeviceExcludeSet { // use default exclude devices if flag is not set
|
||||||
|
devices := diskstatsDefaultIgnoredDevices
|
||||||
|
config.DeviceExclude = &devices
|
||||||
|
}
|
||||||
|
|
||||||
return newDeviceFilter(*config.DeviceExclude, *config.DeviceInclude), nil
|
return newDeviceFilter(*config.DeviceExclude, *config.DeviceInclude), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,14 @@ func NewFilesystemCollector(config *NodeCollectorConfig, logger log.Logger) (Col
|
||||||
return nil, errors.New("--collector.filesystem.ignored-mount-points and --collector.filesystem.mount-points-exclude are mutually exclusive")
|
return nil, errors.New("--collector.filesystem.ignored-mount-points and --collector.filesystem.mount-points-exclude are mutually exclusive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *config.Filesystem.MountPointsExclude != "" {
|
if *config.Filesystem.MountPointsExclude != "" {
|
||||||
level.Info(logger).Log("msg", "Parsed flag --collector.filesystem.mount-points-exclude", "flag", *config.Filesystem.MountPointsExclude)
|
level.Info(logger).Log("msg", "Parsed flag --collector.filesystem.mount-points-exclude", "flag", *config.Filesystem.MountPointsExclude)
|
||||||
} else {
|
}
|
||||||
*config.Filesystem.MountPointsExclude = defMountPointsExcluded
|
|
||||||
|
if !config.Filesystem.MountPointsExcludeSet { // use default mount points if flag is not set
|
||||||
|
mountPoints := defMountPointsExcluded
|
||||||
|
config.Filesystem.MountPointsExclude = &mountPoints
|
||||||
}
|
}
|
||||||
|
|
||||||
if *config.Filesystem.OldFSTypesExcluded != "" {
|
if *config.Filesystem.OldFSTypesExcluded != "" {
|
||||||
|
@ -84,11 +88,14 @@ func NewFilesystemCollector(config *NodeCollectorConfig, logger log.Logger) (Col
|
||||||
return nil, errors.New("--collector.filesystem.ignored-fs-types and --collector.filesystem.fs-types-exclude are mutually exclusive")
|
return nil, errors.New("--collector.filesystem.ignored-fs-types and --collector.filesystem.fs-types-exclude are mutually exclusive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *config.Filesystem.FSTypesExclude != "" {
|
if *config.Filesystem.FSTypesExclude != "" {
|
||||||
level.Info(logger).Log("msg", "Parsed flag --collector.filesystem.fs-types-exclude", "flag", *config.Filesystem.FSTypesExclude)
|
level.Info(logger).Log("msg", "Parsed flag --collector.filesystem.fs-types-exclude", "flag", *config.Filesystem.FSTypesExclude)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
if !config.Filesystem.FSTypesExcludeSet { // use default fs types if flag is not set
|
||||||
*config.Filesystem.FSTypesExclude = defFSTypesExcluded
|
fsTypes := defFSTypesExcluded
|
||||||
|
config.Filesystem.FSTypesExclude = &fsTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
subsystem := "filesystem"
|
subsystem := "filesystem"
|
||||||
|
|
|
@ -82,8 +82,9 @@ func newIPVSCollector(config *NodeCollectorConfig, logger log.Logger) (*ipvsColl
|
||||||
subsystem = "ipvs"
|
subsystem = "ipvs"
|
||||||
)
|
)
|
||||||
|
|
||||||
if *config.IPVS.Labels == "" {
|
if !config.IPVS.LabelsSet { // use default labels if flag is not set
|
||||||
*config.IPVS.Labels = strings.Join(fullIpvsBackendLabels, ",")
|
labels := strings.Join(fullIpvsBackendLabels, ",")
|
||||||
|
config.IPVS.Labels = &labels
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.backendLabels, err = c.parseIpvsLabels(*config.IPVS.Labels); err != nil {
|
if c.backendLabels, err = c.parseIpvsLabels(*config.IPVS.Labels); err != nil {
|
||||||
|
|
|
@ -110,8 +110,8 @@ func TestIPVSCollector(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, test := range testcases {
|
for _, test := range testcases {
|
||||||
t.Run(test.labels, func(t *testing.T) {
|
t.Run(test.labels, func(t *testing.T) {
|
||||||
config.IPVS.Labels = new(string)
|
|
||||||
if test.labels != "<none>" {
|
if test.labels != "<none>" {
|
||||||
|
config.IPVS.LabelsSet = true
|
||||||
config.IPVS.Labels = &test.labels
|
config.IPVS.Labels = &test.labels
|
||||||
}
|
}
|
||||||
collector, err := newIPVSCollector(config, log.NewNopLogger())
|
collector, err := newIPVSCollector(config, log.NewNopLogger())
|
||||||
|
@ -179,8 +179,8 @@ func TestIPVSCollectorResponse(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, test := range testcases {
|
for _, test := range testcases {
|
||||||
t.Run(test.labels, func(t *testing.T) {
|
t.Run(test.labels, func(t *testing.T) {
|
||||||
config.IPVS.Labels = new(string)
|
|
||||||
if test.labels != "<none>" {
|
if test.labels != "<none>" {
|
||||||
|
config.IPVS.LabelsSet = true
|
||||||
config.IPVS.Labels = &test.labels
|
config.IPVS.Labels = &test.labels
|
||||||
}
|
}
|
||||||
collector, err := NewIPVSCollector(config, log.NewNopLogger())
|
collector, err := NewIPVSCollector(config, log.NewNopLogger())
|
||||||
|
|
|
@ -83,7 +83,10 @@ func AddFlags(a *kingpin.Application) *collector.NodeCollectorConfig {
|
||||||
config.HwMon.ChipInclude = a.Flag("collector.hwmon.chip-include", "Regexp of hwmon chip to include (mutually exclusive to device-exclude).").String()
|
config.HwMon.ChipInclude = a.Flag("collector.hwmon.chip-include", "Regexp of hwmon chip to include (mutually exclusive to device-exclude).").String()
|
||||||
config.HwMon.ChipExclude = a.Flag("collector.hwmon.chip-exclude", "Regexp of hwmon chip to exclude (mutually exclusive to device-include).").String()
|
config.HwMon.ChipExclude = a.Flag("collector.hwmon.chip-exclude", "Regexp of hwmon chip to exclude (mutually exclusive to device-include).").String()
|
||||||
|
|
||||||
config.IPVS.Labels = a.Flag("collector.ipvs.backend-labels", "Comma separated list for IPVS backend stats labels.").String()
|
config.IPVS.Labels = a.Flag("collector.ipvs.backend-labels", "Comma separated list for IPVS backend stats labels.").PreAction(func(c *kingpin.ParseContext) error {
|
||||||
|
config.IPVS.LabelsSet = true
|
||||||
|
return nil
|
||||||
|
}).String()
|
||||||
|
|
||||||
config.NetClass.IgnoredDevices = a.Flag("collector.netclass.ignored-devices", "Regexp of net devices to ignore for netclass collector.").Default("^$").String()
|
config.NetClass.IgnoredDevices = a.Flag("collector.netclass.ignored-devices", "Regexp of net devices to ignore for netclass collector.").Default("^$").String()
|
||||||
config.NetClass.InvalidSpeed = a.Flag("collector.netclass.ignore-invalid-speed", "Ignore devices where the speed is invalid. This will be the default behavior in 2.x.").Bool()
|
config.NetClass.InvalidSpeed = a.Flag("collector.netclass.ignore-invalid-speed", "Ignore devices where the speed is invalid. This will be the default behavior in 2.x.").Bool()
|
||||||
|
|
Loading…
Reference in a new issue