diff --git a/collector/edac_linux.go b/collector/edac_linux.go index 318a118d..8f1f8a15 100644 --- a/collector/edac_linux.go +++ b/collector/edac_linux.go @@ -33,14 +33,6 @@ var ( edacMemCsrowRE = regexp.MustCompile(`.*devices/system/edac/mc/mc[0-9]*/csrow([0-9]*)`) ) -type edacMCMetric struct { - metricName string - metricType prometheus.ValueType - metricHelp string - memController string - value float64 -} - type edacCollector struct { ceCount *prometheus.Desc ueCount *prometheus.Desc diff --git a/collector/helper.go b/collector/helper.go index 60168f25..2bf461e7 100644 --- a/collector/helper.go +++ b/collector/helper.go @@ -14,24 +14,11 @@ package collector import ( - "fmt" "io/ioutil" "strconv" "strings" ) -func splitToInts(str, sep string) ([]int, error) { - var ints []int - for _, part := range strings.Split(str, sep) { - i, err := strconv.Atoi(part) - if err != nil { - return nil, fmt.Errorf("could not split '%s' because %s is no int: %s", str, part, err) - } - ints = append(ints, i) - } - return ints, nil -} - func readUintFromFile(path string) (uint64, error) { data, err := ioutil.ReadFile(path) if err != nil { diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index 1bc33676..c1f4ea4c 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -29,10 +29,6 @@ import ( "github.com/prometheus/common/log" ) -const ( - hwMonSubsystem = "hwmon" -) - var ( hwmonInvalidMetricChars = regexp.MustCompile("[^a-z0-9:_]") hwmonFilenameFormat = regexp.MustCompile(`^(?P[^0-9]+)(?P[0-9]*)?(_(?P.+))?$`) diff --git a/collector/ipvs_linux_test.go b/collector/ipvs_linux_test.go index 740b90de..b8f4c72a 100644 --- a/collector/ipvs_linux_test.go +++ b/collector/ipvs_linux_test.go @@ -17,7 +17,6 @@ import ( "flag" "fmt" "io/ioutil" - "net" "net/http" "net/http/httptest" "strings" @@ -25,99 +24,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/prometheus/procfs" -) - -var ( - expectedIPVSStats = procfs.IPVSStats{ - Connections: 23765872, - IncomingPackets: 3811989221, - OutgoingPackets: 0, - IncomingBytes: 89991519156915, - OutgoingBytes: 0, - } - expectedIPVSBackendStatuses = []procfs.IPVSBackendStatus{ - { - LocalAddress: net.ParseIP("192.168.0.22"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.82.22"), - RemotePort: 3306, - Proto: "TCP", - Weight: 100, - ActiveConn: 248, - InactConn: 2, - }, - { - LocalAddress: net.ParseIP("192.168.0.22"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.83.24"), - RemotePort: 3306, - Proto: "TCP", - Weight: 100, - ActiveConn: 248, - InactConn: 2, - }, - { - LocalAddress: net.ParseIP("192.168.0.22"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.83.21"), - RemotePort: 3306, - Proto: "TCP", - Weight: 100, - ActiveConn: 248, - InactConn: 1, - }, - { - LocalAddress: net.ParseIP("192.168.0.57"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.84.22"), - RemotePort: 3306, - Proto: "TCP", - Weight: 0, - ActiveConn: 0, - InactConn: 0, - }, - { - LocalAddress: net.ParseIP("192.168.0.57"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.82.21"), - RemotePort: 3306, - Proto: "TCP", - Weight: 100, - ActiveConn: 1499, - InactConn: 0, - }, - { - LocalAddress: net.ParseIP("192.168.0.57"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.50.21"), - RemotePort: 3306, - Proto: "TCP", - Weight: 100, - ActiveConn: 1498, - InactConn: 0, - }, - { - LocalAddress: net.ParseIP("192.168.0.55"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.50.26"), - RemotePort: 3306, - Proto: "TCP", - Weight: 0, - ActiveConn: 0, - InactConn: 0, - }, - { - LocalAddress: net.ParseIP("192.168.0.55"), - LocalPort: 3306, - RemoteAddress: net.ParseIP("192.168.49.32"), - RemotePort: 3306, - Proto: "TCP", - Weight: 100, - ActiveConn: 0, - InactConn: 0, - }, - } ) func TestIPVSCollector(t *testing.T) { diff --git a/collector/zfs.go b/collector/zfs.go index 7b0b85ae..d534c87a 100644 --- a/collector/zfs.go +++ b/collector/zfs.go @@ -28,18 +28,11 @@ var errZFSNotAvailable = errors.New("ZFS / ZFS statistics are not available") type zfsSysctl string -type zfsMetric struct { - subsystem string // The Prometheus subsystem name. - name string // The Prometheus name of the metric. - sysctl zfsSysctl // The sysctl of the ZFS metric. -} - func init() { Factories["zfs"] = NewZFSCollector } type zfsCollector struct { - zfsMetrics []zfsMetric linuxProcpathBase string linuxZpoolIoPath string linuxPathMap map[string]string @@ -47,19 +40,19 @@ type zfsCollector struct { // NewZFSCollector returns a new Collector exposing ZFS statistics. func NewZFSCollector() (Collector, error) { - var z zfsCollector - z.linuxProcpathBase = "spl/kstat/zfs" - z.linuxZpoolIoPath = "/*/io" - z.linuxPathMap = map[string]string{ - "zfs_arc": "arcstats", - "zfs_dmu_tx": "dmu_tx", - "zfs_fm": "fm", - "zfs_zfetch": "zfetchstats", - "zfs_vdev_cache": "vdev_cache_stats", - "zfs_xuio": "xuio_stats", - "zfs_zil": "zil", - } - return &z, nil + return &zfsCollector{ + linuxProcpathBase: "spl/kstat/zfs", + linuxZpoolIoPath: "/*/io", + linuxPathMap: map[string]string{ + "zfs_arc": "arcstats", + "zfs_dmu_tx": "dmu_tx", + "zfs_fm": "fm", + "zfs_zfetch": "zfetchstats", + "zfs_vdev_cache": "vdev_cache_stats", + "zfs_xuio": "xuio_stats", + "zfs_zil": "zil", + }, + }, nil } func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {