From 813702976257292f1a87e42b4d88a99997e9dfd8 Mon Sep 17 00:00:00 2001 From: xc Date: Tue, 2 Sep 2025 10:29:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?=E5=8F=AF=E6=89=A7=E8=A1=8C=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aufs/core/dtmem.go | 18 ++++++++++++++++++ scagent/.gitignore | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/aufs/core/dtmem.go b/aufs/core/dtmem.go index 5232862..d4bb01f 100644 --- a/aufs/core/dtmem.go +++ b/aufs/core/dtmem.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/rpc/jsonrpc" "runtime" ) @@ -17,6 +18,23 @@ func Dtmem(w http.ResponseWriter, r *http.Request) { var m runtime.MemStats runtime.ReadMemStats(&m) + // 测试JSONRPC + service := "192.168.66.16:9098" + client, err := jsonrpc.Dial("tcp", service) + if err != nil { + fmt.Fprintf(w, "jsonrpc dial faild %v", err) + return + } + // 调用远程方法 + var reply int + err = client.Call("Service.GetFilePath", "hello", &reply) + if err != nil { + fmt.Fprintf(w, "jsonrpc call faild %v", err) + return + } + // 打印返回值 + fmt.Fprintf(w, "jsonrpc call success, reply: %d", reply) + dtm := Dtm{ TotalAlloc: fmt.Sprintf("%d", m.TotalAlloc), diff --git a/scagent/.gitignore b/scagent/.gitignore index 5292519..c914a0b 100644 --- a/scagent/.gitignore +++ b/scagent/.gitignore @@ -1 +1,2 @@ -logs/ \ No newline at end of file +logs/ +scagent \ No newline at end of file