2017-09-18 09:21:58 +00:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/shirou/gopsutil/host"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Host struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
OS string `json:"os"`
|
|
|
|
Platform string `json:"paltform"`
|
|
|
|
PlatformFamily string `json:"platformFamily"`
|
|
|
|
PlatformVersion string `json:"platformVersion"`
|
|
|
|
KernelVersion string `json:"kernelVersion"`
|
|
|
|
HostID string `json:"hostID"`
|
|
|
|
}
|
|
|
|
|
2017-09-21 11:04:30 +00:00
|
|
|
func getHost(h *Host) error {
|
2017-09-18 09:21:58 +00:00
|
|
|
if i, err := host.Info(); nil == err {
|
|
|
|
h.Name = i.Hostname
|
|
|
|
h.OS = i.OS
|
|
|
|
h.Platform = i.Platform
|
|
|
|
h.PlatformFamily = i.PlatformFamily
|
|
|
|
h.KernelVersion = i.KernelVersion
|
|
|
|
h.HostID = i.HostID
|
|
|
|
} else {
|
2017-09-21 11:04:30 +00:00
|
|
|
return err
|
2017-09-18 09:21:58 +00:00
|
|
|
}
|
|
|
|
|
2017-09-21 11:04:30 +00:00
|
|
|
return nil
|
2017-09-18 09:21:58 +00:00
|
|
|
}
|