45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
devc "git.inspur.com/sbg-jszt/cfn/cfn-schedule/internal/model/device"
|
|
"github.com/goccy/go-json"
|
|
"github.com/golang/glog"
|
|
"github.com/segmentio/ksuid"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
type Acb struct {
|
|
SerialNo string `json:"serialNo"`
|
|
AgentVersion string `json:"agentVersion"`
|
|
IpAddress string `json:"ipAddress"`
|
|
MacAddress string `json:"macAddress"`
|
|
Architecture string `json:"architecture"`
|
|
KernelVersion string `json:"kernel_version"`
|
|
Os string `json:"os"`
|
|
LastStarttime time.Time `json:"lastStarttime"`
|
|
ComInfo []struct {
|
|
LastStarttime time.Time `json:"lastStarttime"`
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
} `json:"comInfo"`
|
|
}
|
|
|
|
func TestJson(t *testing.T) {
|
|
fmt.Println("", time.Now().Unix())
|
|
fmt.Println("", time.Now().UnixMicro())
|
|
fmt.Println("", time.Now().UnixMilli())
|
|
fmt.Println("", time.Now().UnixNano())
|
|
id := ksuid.New()
|
|
fmt.Println("", id.String())
|
|
str := "{\"archType\":\"x86_64\",\"baseboardInfo\":\"\",\"biosInfo\":\"\",\"cpuNo\":\"Intel(R) Xeon(R) Gold 6338 CPU @ 2.00GHz\",\"diskNo\":\"\",\"gpuNo\":\"\",\"memoryNo\":\"\",\"networks\":[{\"ipAddress\":\"10.110.141.41\",\"macAddress\":\"00:0c:29:ee:b5:f6\",\"interface\":\"ens160\",\"networkNo\":\"\"}],\"osInfo\":\"linux ubuntu 20.04.5 LTS (Focal Fossa)\",\"osType\":\"linux\",\"serialNo\":\"DZ210900214\"}"
|
|
device := &devc.DeviceInfo{}
|
|
err := json.Unmarshal([]byte(str), device)
|
|
if err != nil {
|
|
glog.Errorf("%v", err)
|
|
}
|
|
fmt.Println("", time.Unix(0, 22))
|
|
fmt.Println("", device)
|
|
}
|