2020-04-06 01:00:33 +00:00
|
|
|
package system
|
2019-12-10 05:05:55 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
2020-04-06 01:00:33 +00:00
|
|
|
type Information struct {
|
2019-12-10 05:05:55 +00:00
|
|
|
Version string `json:"version"`
|
|
|
|
KernelVersion string `json:"kernel_version"`
|
|
|
|
Architecture string `json:"architecture"`
|
|
|
|
OS string `json:"os"`
|
|
|
|
CpuCount int `json:"cpu_count"`
|
|
|
|
}
|
|
|
|
|
2020-04-06 01:00:33 +00:00
|
|
|
func GetSystemInformation() (*Information, error) {
|
2019-12-10 05:05:55 +00:00
|
|
|
k, err := kernel.GetKernelVersion()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-04-06 01:00:33 +00:00
|
|
|
s := &Information{
|
2019-12-10 05:05:55 +00:00
|
|
|
Version: Version,
|
|
|
|
KernelVersion: k.String(),
|
|
|
|
Architecture: runtime.GOARCH,
|
|
|
|
OS: runtime.GOOS,
|
|
|
|
CpuCount: runtime.NumCPU(),
|
|
|
|
}
|
|
|
|
|
|
|
|
return s, nil
|
|
|
|
}
|