[#3c9g25] Add endpoint for returning basic system information

This commit is contained in:
Dane Everitt
2019-12-09 21:05:55 -08:00
parent 89806427f9
commit a1fa876734
3 changed files with 48 additions and 2 deletions

31
system.go Normal file
View File

@@ -0,0 +1,31 @@
package main
import (
"github.com/docker/docker/pkg/parsers/kernel"
"runtime"
)
type SystemInformation struct {
Version string `json:"version"`
KernelVersion string `json:"kernel_version"`
Architecture string `json:"architecture"`
OS string `json:"os"`
CpuCount int `json:"cpu_count"`
}
func GetSystemInformation() (*SystemInformation, error) {
k, err := kernel.GetKernelVersion()
if err != nil {
return nil, err
}
s := &SystemInformation{
Version: Version,
KernelVersion: k.String(),
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
CpuCount: runtime.NumCPU(),
}
return s, nil
}