|
|
|
@ -3,11 +3,11 @@
|
|
|
|
|
package host
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"fmt"
|
|
|
|
|
"time"
|
|
|
|
|
"os"
|
|
|
|
|
"runtime"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/StackExchange/wmi"
|
|
|
|
|
|
|
|
|
@ -17,26 +17,25 @@ import (
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
procGetSystemTimeAsFileTime = common.Modkernel32.NewProc("GetSystemTimeAsFileTime")
|
|
|
|
|
osInfo *Win32_OperatingSystem
|
|
|
|
|
osInfo *Win32_OperatingSystem
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Win32_OperatingSystem struct {
|
|
|
|
|
Version string
|
|
|
|
|
Caption string
|
|
|
|
|
ProductType uint32
|
|
|
|
|
BuildNumber string
|
|
|
|
|
Version string
|
|
|
|
|
Caption string
|
|
|
|
|
ProductType uint32
|
|
|
|
|
BuildNumber string
|
|
|
|
|
LastBootUpTime time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func HostInfo() (*HostInfoStat, error) {
|
|
|
|
|
hostname, err := os.Hostname()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
ret := &HostInfoStat{
|
|
|
|
|
OS: runtime.GOOS,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret := &HostInfoStat{
|
|
|
|
|
Hostname: hostname,
|
|
|
|
|
OS: runtime.GOOS,
|
|
|
|
|
hostname, err := os.Hostname()
|
|
|
|
|
if err == nil {
|
|
|
|
|
ret.Hostname = hostname
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
platform, family, version, err := GetPlatformInformation()
|
|
|
|
@ -44,8 +43,6 @@ func HostInfo() (*HostInfoStat, error) {
|
|
|
|
|
ret.Platform = platform
|
|
|
|
|
ret.PlatformFamily = family
|
|
|
|
|
ret.PlatformVersion = version
|
|
|
|
|
} else {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret.Uptime, err = BootTime()
|
|
|
|
|