From 169865a7e4f981cadb28253b6e53af79021a9471 Mon Sep 17 00:00:00 2001 From: naiba Date: Mon, 10 May 2021 18:04:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20=E5=BC=80=E5=90=AF=20pprof?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=20agent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- cmd/agent/main.go | 5 ++--- cmd/dashboard/controller/controller.go | 4 +++- go.mod | 1 + go.sum | 3 +++ script/config.yaml | 2 +- service/dao/dao.go | 2 +- service/rpc/auth.go | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8f7aa9a..d38bff2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@


-    +   

:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。

diff --git a/cmd/agent/main.go b/cmd/agent/main.go index fb374e3..215fdf7 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -62,10 +62,9 @@ func doSelfUpdate() { return } if latest.Version.Equals(v) { - // latest version is the same as current version. It means current binary is up to date. - println("Current binary is the latest version", version) + println("Current binary is up to date", version) } else { - println("Successfully updated to version", latest.Version) + println("Upgrade successfully", latest.Version) os.Exit(1) } } diff --git a/cmd/dashboard/controller/controller.go b/cmd/dashboard/controller/controller.go index 282d6f8..3d2a811 100644 --- a/cmd/dashboard/controller/controller.go +++ b/cmd/dashboard/controller/controller.go @@ -7,6 +7,7 @@ import ( "time" "code.cloudfoundry.org/bytefmt" + "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" "github.com/naiba/nezha/pkg/mygin" @@ -15,10 +16,11 @@ import ( func ServeWeb(port uint) { gin.SetMode(gin.ReleaseMode) + r := gin.Default() if dao.Conf.Debug { gin.SetMode(gin.DebugMode) + pprof.Register(r) } - r := gin.Default() r.Use(mygin.RecordPath) r.SetFuncMap(template.FuncMap{ "tf": func(t time.Time) string { diff --git a/go.mod b/go.mod index 5963823..66b7cef 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/blang/semver v3.5.1+incompatible github.com/fsnotify/fsnotify v1.4.9 github.com/genkiroid/cert v0.0.0-20191007122723-897560fbbe50 + github.com/gin-contrib/pprof v1.3.0 github.com/gin-gonic/gin v1.6.3 github.com/go-ping/ping v0.0.0-20210407214646-e4e642a95741 github.com/golang/protobuf v1.4.2 diff --git a/go.sum b/go.sum index 7ddd570..37484d2 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,11 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/genkiroid/cert v0.0.0-20191007122723-897560fbbe50 h1:vLwmYBduhnWWqShoUGbVgDulhcLdanoYtCQxYMzwaqQ= github.com/genkiroid/cert v0.0.0-20191007122723-897560fbbe50/go.mod h1:Pb7nyGYAfDyE/IkU6AJeRshIFko0wJC9cOqeYzYQffk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9K0= +github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= diff --git a/script/config.yaml b/script/config.yaml index 45c0bff..60b6d4d 100644 --- a/script/config.yaml +++ b/script/config.yaml @@ -1,4 +1,4 @@ -debug: true +debug: false httpport: 80 oauth2: type: "nz_oauth2_type" #Oauth2 登录接入类型,gitee/github diff --git a/service/dao/dao.go b/service/dao/dao.go index b081ac2..7edd0fe 100644 --- a/service/dao/dao.go +++ b/service/dao/dao.go @@ -13,7 +13,7 @@ import ( pb "github.com/naiba/nezha/proto" ) -var Version = "v0.7.0" // !!记得修改 README 中的 badge 版本!! +var Version = "v0.7.1" // !!记得修改 README 中的 badge 版本!! const ( SnapshotDelay = 3 diff --git a/service/rpc/auth.go b/service/rpc/auth.go index 5d3485f..5648df9 100644 --- a/service/rpc/auth.go +++ b/service/rpc/auth.go @@ -18,7 +18,7 @@ func (a *AuthHandler) GetRequestMetadata(ctx context.Context, uri ...string) (ma } func (a *AuthHandler) RequireTransportSecurity() bool { - return !dao.Conf.Debug + return false } func (a *AuthHandler) Check(ctx context.Context) (uint64, error) {