diff --git a/_build/bin/config.json b/_build/bin/config.json index 9477b40..c63cf35 100644 --- a/_build/bin/config.json +++ b/_build/bin/config.json @@ -4,7 +4,7 @@ "apiKey": "52abd6fd57e511e7ac52080027658d13" }, "central": { - "address": "192.168.1.50:19091", + "address": "192.168.1.101:19100", "connector": { "reconnectInterval": 5, "reconnectTryTime": 10, @@ -17,6 +17,5 @@ } }, "probe": { - "key": "730a120349dd11e890a40242ac120004" } } \ No newline at end of file diff --git a/auth/info/info.go b/auth/info/info.go index aa04b13..e9cb4be 100644 --- a/auth/info/info.go +++ b/auth/info/info.go @@ -1,6 +1,8 @@ package info import ( + "bytes" + "compress/gzip" "encoding/base64" "encoding/json" "log" @@ -11,10 +13,7 @@ import ( ocmi "git.loafle.net/overflow/commons-go/model/infra" ocmm "git.loafle.net/overflow/commons-go/model/meta" ocmn "git.loafle.net/overflow/commons-go/model/noauthprobe" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/disk" "github.com/shirou/gopsutil/host" - "github.com/shirou/gopsutil/mem" ) func GetRegistHeader(apiKey string) (string, error) { @@ -32,16 +31,29 @@ func GetRegistHeader(apiKey string) (string, error) { if buf, err = json.Marshal(infraHost); nil != err { return "", err } - nap.InfraHostMeta = string(buf) if buf, err = json.Marshal(nap); nil != err { return "", err } - log.Printf("nap: %s", string(buf)) + var b bytes.Buffer + gz := gzip.NewWriter(&b) + if _, err := gz.Write(buf); err != nil { + return "", err + } + if err := gz.Flush(); err != nil { + return "", err + } + if err := gz.Close(); err != nil { + return "", err + } - enc := base64.StdEncoding.EncodeToString(buf) + gBuf := b.Bytes() + + log.Printf("RegistHeader length: %d", len(gBuf)) + + enc := base64.StdEncoding.EncodeToString(gBuf) return enc, nil } @@ -66,29 +78,25 @@ func getInfraHost() (*ocmi.InfraHost, error) { func getInfraHostMachine() (*ocmi.InfraHostMachine, error) { meta := make(map[string]interface{}) - if i, err := cpu.Info(); nil == err { - meta["CPU"] = i - } + // if i, err := cpu.Info(); nil == err { + // meta["CPU"] = i + // } - if i, err := mem.SwapMemory(); nil == err { - meta["Memory_Swap"] = i - } + // if i, err := mem.SwapMemory(); nil == err { + // meta["Memory_Swap"] = i + // } - if i, err := mem.VirtualMemory(); nil == err { - meta["Memory_Virtual"] = i - } + // if i, err := mem.VirtualMemory(); nil == err { + // meta["Memory_Virtual"] = i + // } - if i, err := mem.VirtualMemory(); nil == err { - meta["Memory_Virtual"] = i - } + // if i, err := disk.Partitions(true); nil == err { + // meta["Partitions"] = i + // } - if i, err := disk.Partitions(true); nil == err { - meta["Partitions"] = i - } - - if i, err := disk.Usage("/"); nil == err { - meta["Disk_Usage"] = i - } + // if i, err := disk.Usage("/"); nil == err { + // meta["Disk_Usage"] = i + // } buf, err := json.Marshal(meta) if nil != err { diff --git a/client/data/data.go b/client/data/data.go index d096050..4298ed0 100644 --- a/client/data/data.go +++ b/client/data/data.go @@ -28,7 +28,7 @@ func New() (csc.Connector, error) { if config.Dev { u := url.URL{ Scheme: "ws", - Host: fmt.Sprintf("%s:%d", strings.Split(_config.Central.Address, ":")[0], 19095), + Host: fmt.Sprintf("%s:%d", strings.Split(_config.Central.Address, ":")[0], 19110), } u.Path = path.Join(u.Path, occp.HTTPEntry_Data) connector.URL = u.String()