mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
Update github.com/prometheus/procfs dependency
Fix IPVS ipv6 parsing, see also prometheus/procfs#40
This commit is contained in:
parent
d31c29490e
commit
2e9758564e
44
vendor/github.com/prometheus/procfs/ipvs.go
generated
vendored
44
vendor/github.com/prometheus/procfs/ipvs.go
generated
vendored
|
@ -33,6 +33,8 @@ type IPVSBackendStatus struct {
|
|||
LocalAddress net.IP
|
||||
// The local (virtual) port.
|
||||
LocalPort uint16
|
||||
// The local firewall mark
|
||||
LocalMark string
|
||||
// The transport protocol (TCP, UDP).
|
||||
Proto string
|
||||
// The remote (real) IP address.
|
||||
|
@ -142,6 +144,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
|||
status []IPVSBackendStatus
|
||||
scanner = bufio.NewScanner(file)
|
||||
proto string
|
||||
localMark string
|
||||
localAddress net.IP
|
||||
localPort uint16
|
||||
err error
|
||||
|
@ -160,10 +163,19 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
|||
continue
|
||||
}
|
||||
proto = fields[0]
|
||||
localMark = ""
|
||||
localAddress, localPort, err = parseIPPort(fields[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case fields[0] == "FWM":
|
||||
if len(fields) < 2 {
|
||||
continue
|
||||
}
|
||||
proto = fields[0]
|
||||
localMark = fields[1]
|
||||
localAddress = nil
|
||||
localPort = 0
|
||||
case fields[0] == "->":
|
||||
if len(fields) < 6 {
|
||||
continue
|
||||
|
@ -187,6 +199,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
|||
status = append(status, IPVSBackendStatus{
|
||||
LocalAddress: localAddress,
|
||||
LocalPort: localPort,
|
||||
LocalMark: localMark,
|
||||
RemoteAddress: remoteAddress,
|
||||
RemotePort: remotePort,
|
||||
Proto: proto,
|
||||
|
@ -200,22 +213,31 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
|||
}
|
||||
|
||||
func parseIPPort(s string) (net.IP, uint16, error) {
|
||||
tmp := strings.SplitN(s, ":", 2)
|
||||
var (
|
||||
ip net.IP
|
||||
err error
|
||||
)
|
||||
|
||||
if len(tmp) != 2 {
|
||||
return nil, 0, fmt.Errorf("invalid IP:Port: %s", s)
|
||||
}
|
||||
|
||||
if len(tmp[0]) != 8 && len(tmp[0]) != 32 {
|
||||
return nil, 0, fmt.Errorf("invalid IP: %s", tmp[0])
|
||||
}
|
||||
|
||||
ip, err := hex.DecodeString(tmp[0])
|
||||
switch len(s) {
|
||||
case 13:
|
||||
ip, err = hex.DecodeString(s[0:8])
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
case 46:
|
||||
ip = net.ParseIP(s[1:40])
|
||||
if ip == nil {
|
||||
return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40])
|
||||
}
|
||||
default:
|
||||
return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s)
|
||||
}
|
||||
|
||||
port, err := strconv.ParseUint(tmp[1], 16, 16)
|
||||
portString := s[len(s)-4:]
|
||||
if len(portString) != 4 {
|
||||
return nil, 0, fmt.Errorf("unexpected port string format: %s", portString)
|
||||
}
|
||||
port, err := strconv.ParseUint(portString, 16, 16)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
14
vendor/vendor.json
vendored
14
vendor/vendor.json
vendored
|
@ -129,22 +129,22 @@
|
|||
"revisionTime": "2017-02-20T10:38:46Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "dA8hiwcAbubYRxTnpocR5VZkqAY=",
|
||||
"checksumSHA1": "my9sP6myQbSinzWZwxa4Q1V6awU=",
|
||||
"path": "github.com/prometheus/procfs",
|
||||
"revision": "6ac8c5d890d415025dd5aae7595bcb2a6e7e2fad",
|
||||
"revisionTime": "2017-04-24T20:45:52Z"
|
||||
"revision": "d098ca18df8bc825079013daf7bacefbb1ee877e",
|
||||
"revisionTime": "2017-05-01T09:11:53Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "eiBAd4edewJTOtTwxh/ubJdjd+I=",
|
||||
"path": "github.com/prometheus/procfs/sysfs",
|
||||
"revision": "6ac8c5d890d415025dd5aae7595bcb2a6e7e2fad",
|
||||
"revisionTime": "2017-04-24T20:45:52Z"
|
||||
"revision": "d098ca18df8bc825079013daf7bacefbb1ee877e",
|
||||
"revisionTime": "2017-05-01T09:11:53Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "xCiFAAwVTrjsfZT1BIJQ3DgeNCY=",
|
||||
"path": "github.com/prometheus/procfs/xfs",
|
||||
"revision": "6ac8c5d890d415025dd5aae7595bcb2a6e7e2fad",
|
||||
"revisionTime": "2017-04-24T20:45:52Z"
|
||||
"revision": "d098ca18df8bc825079013daf7bacefbb1ee877e",
|
||||
"revisionTime": "2017-05-01T09:11:53Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "uozMgPjB4AggpuuJkGq3FgAs4CA=",
|
||||
|
|
Loading…
Reference in a new issue