[host]linux: add alpine linux to detect host.Info().

pull/215/head
Shirou WAKAYAMA 9 years ago
parent 586bb697f3
commit c0d1185809

@ -15,7 +15,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/shirou/gopsutil/internal/common" common "github.com/shirou/gopsutil/internal/common"
) )
type LSB struct { type LSB struct {
@ -256,6 +256,12 @@ func PlatformInformation() (platform string, family string, version string, err
} else if common.PathExists(common.HostEtc("arch-release")) { } else if common.PathExists(common.HostEtc("arch-release")) {
platform = "arch" platform = "arch"
version = lsb.Release version = lsb.Release
} else if common.PathExists(common.HostEtc("alpine-release")) {
platform = "alpine"
contents, err := common.ReadLines(common.HostEtc("alpine-release"))
if err == nil && len(contents) > 0 {
version = contents[0]
}
} else if lsb.ID == "RedHat" { } else if lsb.ID == "RedHat" {
platform = "redhat" platform = "redhat"
version = lsb.Release version = lsb.Release
@ -290,6 +296,8 @@ func PlatformInformation() (platform string, family string, version string, err
family = "arch" family = "arch"
case "exherbo": case "exherbo":
family = "exherbo" family = "exherbo"
case "alpine":
family = "alpine"
} }
return platform, family, version, nil return platform, family, version, nil

Loading…
Cancel
Save