From f2c5f43b1f1d1ec144ec14a18621657f270c81a9 Mon Sep 17 00:00:00 2001 From: boyce Date: Sun, 28 Apr 2019 15:55:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sysservice/pprofservice.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sysservice/pprofservice.go b/sysservice/pprofservice.go index 4fda723..bb41eee 100644 --- a/sysservice/pprofservice.go +++ b/sysservice/pprofservice.go @@ -4,12 +4,14 @@ import ( "encoding/json" "fmt" "runtime/pprof" + "time" "github.com/duanhf2012/origin/service" ) type PProfService struct { service.BaseService + fisttime int } type ProfileData struct { @@ -18,11 +20,19 @@ type ProfileData struct { } type Profilestruct struct { + Fisttime int ProfileList []ProfileData } +func (slf *PProfService) OnInit() error { + slf.fisttime = (int)(time.Now().UnixNano()) + return nil +} + func (slf *PProfService) GetPprof() ([]byte, error) { var pfiles Profilestruct + pfiles.Fisttime = slf.fisttime + for _, p := range pprof.Profiles() { pfiles.ProfileList = append(pfiles.ProfileList, ProfileData{ Name: p.Name(), From 529ba2248a8c4cbefe08f79682f73494c2cf3cc8 Mon Sep 17 00:00:00 2001 From: boyce Date: Mon, 29 Apr 2019 15:23:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E8=BF=87nodeid?= =?UTF-8?q?=E8=8E=B7=E5=8F=96nodename=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/cluster.go | 5 +++++ cluster/config.go | 9 +++++++++ sysservice/pprofservice.go | 1 + 3 files changed, 15 insertions(+) diff --git a/cluster/cluster.go b/cluster/cluster.go index f6bfff7..5a03777 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -494,3 +494,8 @@ func (slf *CCluster) AddLocalService(iservice service.IService) { servicename = parts[1] slf.innerLocalServiceList[servicename] = true } + +func GetNodeName(nodeid int) string { + // + return _self.cfg.GetNodeNameByNodeId(nodeid) +} diff --git a/cluster/config.go b/cluster/config.go index 1758c88..3828483 100644 --- a/cluster/config.go +++ b/cluster/config.go @@ -156,3 +156,12 @@ func IsExistsNode(nodelist []CNode, pNode *CNode) bool { return false } + +func (slf *ClusterConfig) GetNodeNameByNodeId(nodeid int) string { + node, ok := slf.mapIdNode[nodeid] + if ok == false { + return "" + } + + return node.NodeName +} diff --git a/sysservice/pprofservice.go b/sysservice/pprofservice.go index bb41eee..d341644 100644 --- a/sysservice/pprofservice.go +++ b/sysservice/pprofservice.go @@ -54,6 +54,7 @@ func (slf *PProfService) HTTP_DebugPProf(request *HttpRequest, resp *HttpRespone func (slf *PProfService) RPC_DebugPProf(arg *string, ret *Profilestruct) error { + ret.Fisttime = slf.fisttime for _, p := range pprof.Profiles() { ret.ProfileList = append(ret.ProfileList, ProfileData{ Name: p.Name(),