sockstat: add support for RHE4

This commit is contained in:
Michael Gebetsroither 2016-07-05 23:22:26 +02:00
commit 4b820427dd
3 changed files with 17 additions and 5 deletions

View file

@ -117,11 +117,13 @@ func parseSockStats(r io.Reader, fileName string) (map[string]map[string]string,
sockStat["TCP"]["mem_bytes"] = strconv.Itoa(pageCount * pageSize)
// Update the UDP mem from page count to bytes.
pageCount, err = strconv.Atoi(sockStat["UDP"]["mem"])
if err != nil {
return nil, fmt.Errorf("invalid value %s in sockstats: %s", sockStat["UDP"]["mem"], err)
if udpMem := sockStat["UDP"]["mem"]; udpMem != "" {
pageCount, err = strconv.Atoi(udpMem)
if err != nil {
return nil, fmt.Errorf("invalid value %s in sockstats: %s", sockStat["UDP"]["mem"], err)
}
sockStat["UDP"]["mem_bytes"] = strconv.Itoa(pageCount * pageSize)
}
sockStat["UDP"]["mem_bytes"] = strconv.Itoa(pageCount * pageSize)
return sockStat, nil
}