Merge pull request #718 from prometheus/mdl-netstat-ipv6

netstat: return nothing when /proc/net/snmp6 not found
This commit is contained in:
Julius Volz 2017-10-31 21:01:17 +00:00 committed by GitHub
commit f6556e69ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -121,6 +121,12 @@ func parseNetStats(r io.Reader, fileName string) (map[string]map[string]string,
func getSNMP6Stats(fileName string) (map[string]map[string]string, error) {
file, err := os.Open(fileName)
if err != nil {
// On systems with IPv6 disabled, this file won't exist.
// Do nothing.
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
defer file.Close()