mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 06:59:44 -08:00
Merge pull request #483 from prometheus/grobie/more-cleanups
Delete unused code
This commit is contained in:
commit
c6e66756b3
|
@ -33,14 +33,6 @@ var (
|
||||||
edacMemCsrowRE = regexp.MustCompile(`.*devices/system/edac/mc/mc[0-9]*/csrow([0-9]*)`)
|
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 {
|
type edacCollector struct {
|
||||||
ceCount *prometheus.Desc
|
ceCount *prometheus.Desc
|
||||||
ueCount *prometheus.Desc
|
ueCount *prometheus.Desc
|
||||||
|
|
|
@ -14,24 +14,11 @@
|
||||||
package collector
|
package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"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) {
|
func readUintFromFile(path string) (uint64, error) {
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -29,10 +29,6 @@ import (
|
||||||
"github.com/prometheus/common/log"
|
"github.com/prometheus/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
hwMonSubsystem = "hwmon"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
hwmonInvalidMetricChars = regexp.MustCompile("[^a-z0-9:_]")
|
hwmonInvalidMetricChars = regexp.MustCompile("[^a-z0-9:_]")
|
||||||
hwmonFilenameFormat = regexp.MustCompile(`^(?P<type>[^0-9]+)(?P<id>[0-9]*)?(_(?P<property>.+))?$`)
|
hwmonFilenameFormat = regexp.MustCompile(`^(?P<type>[^0-9]+)(?P<id>[0-9]*)?(_(?P<property>.+))?$`)
|
||||||
|
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -25,99 +24,6 @@ import (
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"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) {
|
func TestIPVSCollector(t *testing.T) {
|
||||||
|
|
|
@ -28,18 +28,11 @@ var errZFSNotAvailable = errors.New("ZFS / ZFS statistics are not available")
|
||||||
|
|
||||||
type zfsSysctl string
|
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() {
|
func init() {
|
||||||
Factories["zfs"] = NewZFSCollector
|
Factories["zfs"] = NewZFSCollector
|
||||||
}
|
}
|
||||||
|
|
||||||
type zfsCollector struct {
|
type zfsCollector struct {
|
||||||
zfsMetrics []zfsMetric
|
|
||||||
linuxProcpathBase string
|
linuxProcpathBase string
|
||||||
linuxZpoolIoPath string
|
linuxZpoolIoPath string
|
||||||
linuxPathMap map[string]string
|
linuxPathMap map[string]string
|
||||||
|
@ -47,19 +40,19 @@ type zfsCollector struct {
|
||||||
|
|
||||||
// NewZFSCollector returns a new Collector exposing ZFS statistics.
|
// NewZFSCollector returns a new Collector exposing ZFS statistics.
|
||||||
func NewZFSCollector() (Collector, error) {
|
func NewZFSCollector() (Collector, error) {
|
||||||
var z zfsCollector
|
return &zfsCollector{
|
||||||
z.linuxProcpathBase = "spl/kstat/zfs"
|
linuxProcpathBase: "spl/kstat/zfs",
|
||||||
z.linuxZpoolIoPath = "/*/io"
|
linuxZpoolIoPath: "/*/io",
|
||||||
z.linuxPathMap = map[string]string{
|
linuxPathMap: map[string]string{
|
||||||
"zfs_arc": "arcstats",
|
"zfs_arc": "arcstats",
|
||||||
"zfs_dmu_tx": "dmu_tx",
|
"zfs_dmu_tx": "dmu_tx",
|
||||||
"zfs_fm": "fm",
|
"zfs_fm": "fm",
|
||||||
"zfs_zfetch": "zfetchstats",
|
"zfs_zfetch": "zfetchstats",
|
||||||
"zfs_vdev_cache": "vdev_cache_stats",
|
"zfs_vdev_cache": "vdev_cache_stats",
|
||||||
"zfs_xuio": "xuio_stats",
|
"zfs_xuio": "xuio_stats",
|
||||||
"zfs_zil": "zil",
|
"zfs_zil": "zil",
|
||||||
}
|
},
|
||||||
return &z, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {
|
func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
|
|
Loading…
Reference in a new issue