Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e54060e527 | ||
|
|
ca14674c36 | ||
|
|
1e27fb9413 | ||
|
|
460483fdef | ||
|
|
3a733c85ad |
@@ -22,15 +22,14 @@ jobs:
|
||||
uses: crazy-max/ghaction-xgo@v2
|
||||
with:
|
||||
xgo_version: latest
|
||||
go_version: 1.20.x
|
||||
go_version: 1.21
|
||||
dest: dist
|
||||
pkg: cmd/dashboard
|
||||
prefix: dashboard
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64,windows/amd64,windows/386,windows/arm64 # linux/386,
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386,
|
||||
v: true
|
||||
x: false
|
||||
race: false
|
||||
tags: timetzdata
|
||||
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }}
|
||||
buildmode: default
|
||||
|
||||
|
||||
@@ -25,15 +25,14 @@ jobs:
|
||||
uses: crazy-max/ghaction-xgo@v2
|
||||
with:
|
||||
xgo_version: latest
|
||||
go_version: 1.20.x
|
||||
go_version: 1.21
|
||||
dest: dist
|
||||
pkg: cmd/dashboard
|
||||
prefix: dashboard
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64,windows/amd64,windows/386,windows/arm64 # linux/386,
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386,
|
||||
v: true
|
||||
x: false
|
||||
race: false
|
||||
tags: timetzdata
|
||||
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test
|
||||
buildmode: default
|
||||
|
||||
|
||||
@@ -32,14 +32,13 @@ jobs:
|
||||
uses: crazy-max/ghaction-xgo@v2
|
||||
with:
|
||||
xgo_version: latest
|
||||
go_version: 1.20.x
|
||||
go_version: 1.21
|
||||
dest: dist
|
||||
pkg: cmd/dashboard
|
||||
prefix: dashboard
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64,windows/amd64,windows/386,windows/arm64 # linux/386,
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386,
|
||||
v: true
|
||||
x: false
|
||||
race: false
|
||||
tags: timetzdata
|
||||
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test
|
||||
buildmode: default
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<br>
|
||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||
<br><br>
|
||||
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.16.3-brightgreen?style=for-the-badge&logo=linux">
|
||||
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.9-brightgreen?style=for-the-badge&logo=linux">
|
||||
<br>
|
||||
<br>
|
||||
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
||||
@@ -42,21 +42,21 @@ You can change the dashboard language in the settings page (`/setting`) after th
|
||||
<a href="https://github.com/AkkiaS7" title="Akkia"><img src="https://avatars.githubusercontent.com/u/68485070?v=4" width="50;" alt="Akkia"/></a>
|
||||
<a href="https://github.com/Erope" title="卖女孩的小火柴"><img src="https://avatars.githubusercontent.com/u/44471469?v=4" width="50;" alt="卖女孩的小火柴"/></a>
|
||||
<a href="https://github.com/dysf888" title="黑歌"><img src="https://avatars.githubusercontent.com/u/47450409?v=4" width="50;" alt="黑歌"/></a>
|
||||
<a href="https://github.com/xykt" title="xykt"><img src="https://avatars.githubusercontent.com/u/152045469?v=4" width="50;" alt="xykt"/></a>
|
||||
<a href="https://github.com/MikoyChinese" title="MikoyChinese"><img src="https://avatars.githubusercontent.com/u/22676744?v=4" width="50;" alt="MikoyChinese"/></a>
|
||||
<a href="https://github.com/JackieSung4ev" title="JackieSung4ev"><img src="https://avatars.githubusercontent.com/u/24974735?v=4" width="50;" alt="JackieSung4ev"/></a>
|
||||
<a href="https://github.com/uubulb" title="UUBulb"><img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/></a>
|
||||
<a href="https://github.com/nap0o" title="nap0o"><img src="https://avatars.githubusercontent.com/u/144927971?v=4" width="50;" alt="nap0o"/></a>
|
||||
<a href="https://github.com/lemoeo" title="Lemoe"><img src="https://avatars.githubusercontent.com/u/18618627?v=4" width="50;" alt="Lemoe"/></a>
|
||||
<a href="https://github.com/cantoblanco" title="Kris"><img src="https://avatars.githubusercontent.com/u/116849421?v=4" width="50;" alt="Kris"/></a>
|
||||
<a href="https://github.com/nap0o" title="nap0o"><img src="https://avatars.githubusercontent.com/u/144927971?v=4" width="50;" alt="nap0o"/></a>
|
||||
<a href="https://github.com/CosmosZ-code" title="CosmosZ-code"><img src="https://avatars.githubusercontent.com/u/81398224?v=4" width="50;" alt="CosmosZ-code"/></a>
|
||||
<a href="https://github.com/liuyanxi975" title="刘颜溪"><img src="https://avatars.githubusercontent.com/u/24417037?v=4" width="50;" alt="刘颜溪"/></a>
|
||||
<a href="https://github.com/spiritLHLS" title="spiritlhl"><img src="https://avatars.githubusercontent.com/u/103393591?v=4" width="50;" alt="spiritlhl"/></a>
|
||||
<a href="https://github.com/lvgj-stack" title="Ko no dio"><img src="https://avatars.githubusercontent.com/u/38449861?v=4" width="50;" alt="Ko no dio"/></a>
|
||||
<a href="https://github.com/hhhkkk520" title="Kris"><img src="https://avatars.githubusercontent.com/u/52115472?v=4" width="50;" alt="Kris"/></a>
|
||||
<a href="https://github.com/1ridic" title="1ridic"><img src="https://avatars.githubusercontent.com/u/88495501?v=4" width="50;" alt="1ridic"/></a>
|
||||
<a href="https://github.com/hhhkkk520" title="Kris"><img src="https://avatars.githubusercontent.com/u/52115472?v=4" width="50;" alt="Kris"/></a>
|
||||
<a href="https://github.com/lvgj-stack" title="Ko no dio"><img src="https://avatars.githubusercontent.com/u/38449861?v=4" width="50;" alt="Ko no dio"/></a>
|
||||
<a href="https://github.com/uubulb" title="UUBulb"><img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/></a>
|
||||
<a href="https://github.com/Mmx233" title="Mmx"><img src="https://avatars.githubusercontent.com/u/36563672?v=4" width="50;" alt="Mmx"/></a>
|
||||
<a href="https://github.com/rootmelo92118" title="rootmelo92118"><img src="https://avatars.githubusercontent.com/u/32770959?v=4" width="50;" alt="rootmelo92118"/></a>
|
||||
<a href="https://github.com/xykt" title="xykt"><img src="https://avatars.githubusercontent.com/u/152045469?v=4" width="50;" alt="xykt"/></a>
|
||||
<a href="https://github.com/iilemon" title="Sean"><img src="https://avatars.githubusercontent.com/u/33201711?v=4" width="50;" alt="Sean"/></a>
|
||||
<a href="https://github.com/fscarmen" title="fscarmen"><img src="https://avatars.githubusercontent.com/u/62703343?v=4" width="50;" alt="fscarmen"/></a>
|
||||
<a href="https://github.com/ch8o" title="no-name-now"><img src="https://avatars.githubusercontent.com/u/9103372?v=4" width="50;" alt="no-name-now"/></a>
|
||||
@@ -66,26 +66,21 @@ You can change the dashboard language in the settings page (`/setting`) after th
|
||||
<a href="https://github.com/coreff" title="Core F"><img src="https://avatars.githubusercontent.com/u/38347122?v=4" width="50;" alt="Core F"/></a>
|
||||
<a href="https://github.com/colour93" title="玖叁"><img src="https://avatars.githubusercontent.com/u/64313711?v=4" width="50;" alt="玖叁"/></a>
|
||||
<a href="https://github.com/arkylin" title="凌"><img src="https://avatars.githubusercontent.com/u/35104502?v=4" width="50;" alt="凌"/></a>
|
||||
<a href="https://github.com/zhucaidan" title="zhucaidan"><img src="https://avatars.githubusercontent.com/u/47970938?v=4" width="50;" alt="zhucaidan"/></a>
|
||||
<a href="https://github.com/ysicing" title="缘生"><img src="https://avatars.githubusercontent.com/u/8605565?v=4" width="50;" alt="缘生"/></a>
|
||||
<a href="https://github.com/sunnywangzi" title="wang"><img src="https://avatars.githubusercontent.com/u/88769439?v=4" width="50;" alt="wang"/></a>
|
||||
<a href="https://github.com/unclezs" title="unclezs"><img src="https://avatars.githubusercontent.com/u/42318775?v=4" width="50;" alt="unclezs"/></a>
|
||||
<a href="https://github.com/lvyaoting" title="lvyaoting"><img src="https://avatars.githubusercontent.com/u/166296299?v=4" width="50;" alt="lvyaoting"/></a>
|
||||
<a href="https://github.com/yuanweize" title="I"><img src="https://avatars.githubusercontent.com/u/30067203?v=4" width="50;" alt="I"/></a>
|
||||
<a href="https://github.com/guoyongchang" title="guoyongchang"><img src="https://avatars.githubusercontent.com/u/10484506?v=4" width="50;" alt="guoyongchang"/></a>
|
||||
<a href="https://github.com/eya46" title="eya46"><img src="https://avatars.githubusercontent.com/u/61458340?v=4" width="50;" alt="eya46"/></a>
|
||||
<a href="https://github.com/acgpiano" title="Acgpiano"><img src="https://avatars.githubusercontent.com/u/15900800?v=4" width="50;" alt="Acgpiano"/></a>
|
||||
<a href="https://github.com/adminsama" title="adminsama"><img src="https://avatars.githubusercontent.com/u/60880076?v=4" width="50;" alt="adminsama"/></a>
|
||||
<a href="https://github.com/hmsjy2017" title="Tony"><img src="https://avatars.githubusercontent.com/u/42692274?v=4" width="50;" alt="Tony"/></a>
|
||||
<a href="https://github.com/nickfox-taterli" title="Tater Li"><img src="https://avatars.githubusercontent.com/u/19658596?v=4" width="50;" alt="Tater Li"/></a>
|
||||
<a href="https://github.com/dreamingsleeping" title="Nanjing Hopefun Network Technology Co. Ltd."><img src="https://avatars.githubusercontent.com/u/13828658?v=4" width="50;" alt="Nanjing Hopefun Network Technology Co. Ltd."/></a>
|
||||
<a href="https://github.com/MartijnLindeman" title="Martijn Lindeman"><img src="https://avatars.githubusercontent.com/u/78365708?v=4" width="50;" alt="Martijn Lindeman"/></a>
|
||||
<a href="https://github.com/funnyzak" title="Leon"><img src="https://avatars.githubusercontent.com/u/2562087?v=4" width="50;" alt="Leon"/></a>
|
||||
<a href="https://github.com/KorenKrita" title="KorenKrita"><img src="https://avatars.githubusercontent.com/u/22239339?v=4" width="50;" alt="KorenKrita"/></a>
|
||||
<a href="https://github.com/techotaku" title="Ian Li"><img src="https://avatars.githubusercontent.com/u/1948179?v=4" width="50;" alt="Ian Li"/></a>
|
||||
<a href="https://github.com/GreenTeodoro839" title="GreenTeodoro839"><img src="https://avatars.githubusercontent.com/u/77104800?v=4" width="50;" alt="GreenTeodoro839"/></a>
|
||||
<a href="https://github.com/Es-dese" title="Esdese"><img src="https://avatars.githubusercontent.com/u/71542548?v=4" width="50;" alt="Esdese"/></a>
|
||||
<a href="https://github.com/wwng2333" title="Crazy"><img src="https://avatars.githubusercontent.com/u/17147265?v=4" width="50;" alt="Crazy"/></a>
|
||||
<a href="https://github.com/wellcoming" title="Coming"><img src="https://avatars.githubusercontent.com/u/74850890?v=4" width="50;" alt="Coming"/></a><!--GAMFC_DELIMITER_END-->
|
||||
<a href="https://github.com/wwng2333" title="Crazy"><img src="https://avatars.githubusercontent.com/u/17147265?v=4" width="50;" alt="Crazy"/></a><!--GAMFC_DELIMITER_END-->
|
||||
|
||||
## Star History
|
||||
|
||||
|
||||
@@ -49,9 +49,6 @@ func (gp *guestPage) login(c *gin.Context) {
|
||||
} else if singleton.Conf.Oauth2.Type == model.ConfigTypeGitea {
|
||||
LoginType = "Gitea"
|
||||
RegistrationLink = fmt.Sprintf("%s/user/sign_up", singleton.Conf.Oauth2.Endpoint)
|
||||
} else if singleton.Conf.Oauth2.Type == model.ConfigTypeCloudflare {
|
||||
LoginType = "Cloudflare"
|
||||
RegistrationLink = "https://dash.cloudflare.com/sign-up/teams"
|
||||
}
|
||||
c.HTML(http.StatusOK, "dashboard-"+singleton.Conf.Site.DashboardTheme+"/login", mygin.CommonEnvironment(c, gin.H{
|
||||
"Title": singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "Login"}),
|
||||
|
||||
@@ -301,10 +301,7 @@ type serverForm struct {
|
||||
Note string
|
||||
HideForGuest string
|
||||
EnableDDNS string
|
||||
EnableIPv4 string
|
||||
EnableIpv6 string
|
||||
DDNSDomain string
|
||||
DDNSProfile string
|
||||
}
|
||||
|
||||
func (ma *memberAPI) addOrEditServer(c *gin.Context) {
|
||||
@@ -321,10 +318,7 @@ func (ma *memberAPI) addOrEditServer(c *gin.Context) {
|
||||
s.Note = sf.Note
|
||||
s.HideForGuest = sf.HideForGuest == "on"
|
||||
s.EnableDDNS = sf.EnableDDNS == "on"
|
||||
s.EnableIPv4 = sf.EnableIPv4 == "on"
|
||||
s.EnableIpv6 = sf.EnableIpv6 == "on"
|
||||
s.DDNSDomain = sf.DDNSDomain
|
||||
s.DDNSProfile = sf.DDNSProfile
|
||||
if s.ID == 0 {
|
||||
s.Secret, err = utils.GenerateRandomString(18)
|
||||
if err == nil {
|
||||
|
||||
@@ -2,10 +2,8 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/naiba/nezha/pkg/oidc/cloudflare"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -76,17 +74,6 @@ func (oa *oauth2controller) getCommonOauth2Config(c *gin.Context) *oauth2.Config
|
||||
},
|
||||
RedirectURL: oa.getRedirectURL(c),
|
||||
}
|
||||
} else if singleton.Conf.Oauth2.Type == model.ConfigTypeCloudflare {
|
||||
return &oauth2.Config{
|
||||
ClientID: singleton.Conf.Oauth2.ClientID,
|
||||
ClientSecret: singleton.Conf.Oauth2.ClientSecret,
|
||||
Scopes: []string{"openid", "email", "profile", "groups"},
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: fmt.Sprintf("%s/cdn-cgi/access/sso/oidc/%s/authorization", singleton.Conf.Oauth2.Endpoint, singleton.Conf.Oauth2.ClientID),
|
||||
TokenURL: fmt.Sprintf("%s/cdn-cgi/access/sso/oidc/%s/token", singleton.Conf.Oauth2.Endpoint, singleton.Conf.Oauth2.ClientID),
|
||||
},
|
||||
RedirectURL: oa.getRedirectURL(c),
|
||||
}
|
||||
} else {
|
||||
return &oauth2.Config{
|
||||
ClientID: singleton.Conf.Oauth2.ClientID,
|
||||
@@ -168,17 +155,6 @@ func (oa *oauth2controller) callback(c *gin.Context) {
|
||||
if err == nil {
|
||||
user = model.NewUserFromGitea(u)
|
||||
}
|
||||
} else if singleton.Conf.Oauth2.Type == model.ConfigTypeCloudflare {
|
||||
client := oauth2Config.Client(context.Background(), otk)
|
||||
resp, err := client.Get(fmt.Sprintf("%s/cdn-cgi/access/sso/oidc/%s/userinfo", singleton.Conf.Oauth2.Endpoint, singleton.Conf.Oauth2.ClientID))
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
var cloudflareUserInfo *cloudflare.UserInfo
|
||||
if err := json.NewDecoder(resp.Body).Decode(&cloudflareUserInfo); err == nil {
|
||||
user = cloudflareUserInfo.MapToNezhaUser()
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
var client *GitHubAPI.Client
|
||||
oc := oauth2Config.Client(ctx, otk)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
module github.com/naiba/nezha
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.3
|
||||
|
||||
require (
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20240425163905-bcdc1ad063ea
|
||||
code.gitea.io/sdk/gitea v0.18.0
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20240322144145-4816192cb114
|
||||
code.gitea.io/sdk/gitea v0.17.1
|
||||
github.com/BurntSushi/toml v1.3.2
|
||||
github.com/gin-contrib/pprof v1.4.0
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
@@ -20,16 +22,15 @@ require (
|
||||
github.com/samber/lo v1.39.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.18.2
|
||||
github.com/xanzy/go-gitlab v0.103.0
|
||||
golang.org/x/crypto v0.22.0
|
||||
golang.org/x/net v0.24.0
|
||||
golang.org/x/oauth2 v0.19.0
|
||||
golang.org/x/sync v0.7.0
|
||||
github.com/xanzy/go-gitlab v0.100.0
|
||||
golang.org/x/crypto v0.21.0
|
||||
golang.org/x/oauth2 v0.18.0
|
||||
golang.org/x/sync v0.6.0
|
||||
golang.org/x/text v0.14.0
|
||||
google.golang.org/grpc v1.63.0
|
||||
google.golang.org/grpc v1.62.1
|
||||
google.golang.org/protobuf v1.33.0
|
||||
gorm.io/driver/sqlite v1.5.5
|
||||
gorm.io/gorm v1.25.10
|
||||
gorm.io/gorm v1.25.8
|
||||
sigs.k8s.io/yaml v1.4.0
|
||||
)
|
||||
|
||||
@@ -45,6 +46,7 @@ require (
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
|
||||
@@ -74,9 +76,11 @@ require (
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/net v0.22.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20240425163905-bcdc1ad063ea h1:1tgMNDgo8PjpsHhlaxdibj28C0WyLeOW2SPJ7GGdc9A=
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20240425163905-bcdc1ad063ea/go.mod h1:3+xXJBOD8PsGHDqHedtCLalbaVJ+yi1OW+mXx9IcNxI=
|
||||
code.gitea.io/sdk/gitea v0.18.0 h1:+zZrwVmujIrgobt6wVBWCqITz6bn1aBjnCUHmpZrerI=
|
||||
code.gitea.io/sdk/gitea v0.18.0/go.mod h1:IG9xZJoltDNeDSW0qiF2Vqx5orMWa7OhVWrjvrd5NpI=
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20240322144145-4816192cb114 h1:7KJsK0gPah7XfO46ARJA2TUXHZaJEnPI80mzxQLre68=
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20240322144145-4816192cb114/go.mod h1:TNAH6xe5WOszc47+zM7NnpaJWBR8oYt12BUf4WLIZ98=
|
||||
code.gitea.io/sdk/gitea v0.17.1 h1:3jCPOG2ojbl8AcfaUCRYLT5MUcBMFwS0OSK2mA5Zok8=
|
||||
code.gitea.io/sdk/gitea v0.17.1/go.mod h1:aCnBqhHpoEWA180gMbaCtdX9Pl6BWBAuuP2miadoTNM=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
@@ -14,10 +14,13 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
|
||||
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
|
||||
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
|
||||
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
@@ -32,8 +35,10 @@ github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SU
|
||||
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
|
||||
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
|
||||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
@@ -44,26 +49,33 @@ github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXS
|
||||
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
|
||||
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-github/v47 v47.1.0 h1:Cacm/WxQBOa9lF0FT0EMjZ2BWMetQ1TQfyurn4yF1z8=
|
||||
github.com/google/go-github/v47 v47.1.0/go.mod h1:VPZBXNbFSJGjyjFRUKo9vZGawTajnWzC/YjGw/oFKi0=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
|
||||
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07 h1:57oOH2Mu5Nw16KnZAVLdlUjmPH/TSYCKTJgG0OVfX0Y=
|
||||
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c=
|
||||
github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
||||
@@ -87,6 +99,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
@@ -97,6 +110,7 @@ github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNa
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
@@ -111,8 +125,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4=
|
||||
github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
|
||||
github.com/onsi/gomega v1.33.0 h1:snPCflnZrpMsy94p4lXVEkHo12lmPnc3vY5XBbreexE=
|
||||
github.com/onsi/ginkgo/v2 v2.17.0 h1:kdnunFXpBjbzN56hcJHrXZ8M+LOkenKA7NnBzTNigTI=
|
||||
github.com/onsi/ginkgo/v2 v2.17.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
|
||||
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
|
||||
github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg=
|
||||
github.com/ory/graceful v0.1.3 h1:FaeXcHZh168WzS+bqruqWEw/HgXWLdNv2nJ+fbhxbhc=
|
||||
github.com/ory/graceful v0.1.3/go.mod h1:4zFz687IAF7oNHHiB586U4iL+/4aV09o/PYLE34t2bA=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
@@ -125,11 +141,13 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
|
||||
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||
@@ -168,8 +186,9 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xanzy/go-gitlab v0.103.0 h1:J9pTQoq0GsEFqzd6srCM1QfdfKAxSNz6mT6ntrpNF2w=
|
||||
github.com/xanzy/go-gitlab v0.103.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI=
|
||||
github.com/xanzy/go-gitlab v0.100.0 h1:jaOtYj5nWI19+9oVVmgy233pax2oYqucwetogYU46ks=
|
||||
github.com/xanzy/go-gitlab v0.100.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
||||
@@ -181,45 +200,78 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
|
||||
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI=
|
||||
golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
|
||||
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
|
||||
google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
|
||||
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
||||
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
|
||||
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
|
||||
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
@@ -239,8 +291,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
|
||||
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
|
||||
gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s=
|
||||
gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.8 h1:WAGEZ/aEcznN4D03laj8DKnehe1e9gYQAjW8xyPRdeo=
|
||||
gorm.io/gorm v1.25.8/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
|
||||
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
|
||||
|
||||
+13
-19
@@ -32,12 +32,11 @@ var DashboardThemes = map[string]string{
|
||||
}
|
||||
|
||||
const (
|
||||
ConfigTypeGitHub = "github"
|
||||
ConfigTypeGitee = "gitee"
|
||||
ConfigTypeGitlab = "gitlab"
|
||||
ConfigTypeJihulab = "jihulab"
|
||||
ConfigTypeGitea = "gitea"
|
||||
ConfigTypeCloudflare = "cloudflare"
|
||||
ConfigTypeGitHub = "github"
|
||||
ConfigTypeGitee = "gitee"
|
||||
ConfigTypeGitlab = "gitlab"
|
||||
ConfigTypeJihulab = "jihulab"
|
||||
ConfigTypeGitea = "gitea"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -71,7 +70,7 @@ func (c *AgentConfig) Save() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(c.v.ConfigFileUsed(), data, 0600)
|
||||
return os.WriteFile(c.v.ConfigFileUsed(), data, os.ModePerm)
|
||||
}
|
||||
|
||||
// Config 站点配置
|
||||
@@ -126,20 +125,9 @@ type Config struct {
|
||||
WebhookRequestBody string
|
||||
WebhookHeaders string
|
||||
MaxRetries uint32
|
||||
Profiles map[string]DDNSProfile
|
||||
}
|
||||
}
|
||||
|
||||
type DDNSProfile struct {
|
||||
Provider string
|
||||
AccessID string
|
||||
AccessSecret string
|
||||
WebhookURL string
|
||||
WebhookMethod string
|
||||
WebhookRequestBody string
|
||||
WebhookHeaders string
|
||||
}
|
||||
|
||||
// Read 读取配置文件并应用
|
||||
func (c *Config) Read(path string) error {
|
||||
c.v = viper.New()
|
||||
@@ -178,6 +166,12 @@ func (c *Config) Read(path string) error {
|
||||
if c.AvgPingCount == 0 {
|
||||
c.AvgPingCount = 2
|
||||
}
|
||||
if c.DDNS.Provider == "" {
|
||||
c.DDNS.Provider = "webhook"
|
||||
}
|
||||
if c.DDNS.WebhookMethod == "" {
|
||||
c.DDNS.WebhookMethod = "POST"
|
||||
}
|
||||
if c.DDNS.MaxRetries == 0 {
|
||||
c.DDNS.MaxRetries = 3
|
||||
}
|
||||
@@ -205,5 +199,5 @@ func (c *Config) Save() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(c.v.ConfigFileUsed(), data, 0600)
|
||||
return os.WriteFile(c.v.ConfigFileUsed(), data, os.ModePerm)
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ const (
|
||||
MTReportHostState
|
||||
)
|
||||
|
||||
type SensorTemperature struct {
|
||||
Name string
|
||||
Temperature float64
|
||||
}
|
||||
|
||||
type HostState struct {
|
||||
CPU float64
|
||||
MemUsed uint64
|
||||
@@ -31,18 +26,9 @@ type HostState struct {
|
||||
TcpConnCount uint64
|
||||
UdpConnCount uint64
|
||||
ProcessCount uint64
|
||||
Temperatures []SensorTemperature
|
||||
}
|
||||
|
||||
func (s *HostState) PB() *pb.State {
|
||||
var ts []*pb.State_SensorTemperature
|
||||
for _, t := range s.Temperatures {
|
||||
ts = append(ts, &pb.State_SensorTemperature{
|
||||
Name: t.Name,
|
||||
Temperature: t.Temperature,
|
||||
})
|
||||
}
|
||||
|
||||
return &pb.State{
|
||||
Cpu: s.CPU,
|
||||
MemUsed: s.MemUsed,
|
||||
@@ -59,19 +45,10 @@ func (s *HostState) PB() *pb.State {
|
||||
TcpConnCount: s.TcpConnCount,
|
||||
UdpConnCount: s.UdpConnCount,
|
||||
ProcessCount: s.ProcessCount,
|
||||
Temperatures: ts,
|
||||
}
|
||||
}
|
||||
|
||||
func PB2State(s *pb.State) HostState {
|
||||
var ts []SensorTemperature
|
||||
for _, t := range s.GetTemperatures() {
|
||||
ts = append(ts, SensorTemperature{
|
||||
Name: t.GetName(),
|
||||
Temperature: t.GetTemperature(),
|
||||
})
|
||||
}
|
||||
|
||||
return HostState{
|
||||
CPU: s.GetCpu(),
|
||||
MemUsed: s.GetMemUsed(),
|
||||
@@ -88,7 +65,6 @@ func PB2State(s *pb.State) HostState {
|
||||
TcpConnCount: s.GetTcpConnCount(),
|
||||
UdpConnCount: s.GetUdpConnCount(),
|
||||
ProcessCount: s.GetProcessCount(),
|
||||
Temperatures: ts,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,3 +19,4 @@ type MonitorHistory struct {
|
||||
Down uint64 // 检查状态异常计数
|
||||
Data string
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -18,10 +18,7 @@ type Server struct {
|
||||
DisplayIndex int // 展示排序,越大越靠前
|
||||
HideForGuest bool // 对游客隐藏
|
||||
EnableDDNS bool // 是否启用DDNS 未在配置文件中启用DDNS 或 DDNS检查时间为0时此项无效
|
||||
EnableIPv4 bool // 是否启用DDNS IPv4
|
||||
EnableIpv6 bool // 是否启用DDNS IPv6
|
||||
DDNSDomain string // DDNS中的前缀 如基础域名为abc.oracle DDNSName为mjj 就会把mjj.abc.oracle解析服务器IP 为空则停用
|
||||
DDNSProfile string // DDNS配置
|
||||
|
||||
Host *Host `gorm:"-"`
|
||||
State *HostState `gorm:"-"`
|
||||
@@ -57,6 +54,5 @@ func (s Server) Marshal() template.JS {
|
||||
note, _ := utils.Json.Marshal(s.Note)
|
||||
secret, _ := utils.Json.Marshal(s.Secret)
|
||||
ddnsDomain, _ := utils.Json.Marshal(s.DDNSDomain)
|
||||
ddnsProfile, _ := utils.Json.Marshal(s.DDNSProfile)
|
||||
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s,"HideForGuest": %s,"EnableDDNS": %s,"EnableIPv4": %s,"EnableIpv6": %s,"DDNSDomain": %s,"DDNSProfile": %s}`, s.ID, name, secret, s.DisplayIndex, tag, note, boolToString(s.HideForGuest), boolToString(s.EnableDDNS), boolToString(s.EnableIPv4), boolToString(s.EnableIpv6), ddnsDomain, ddnsProfile)) // #nosec
|
||||
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s,"HideForGuest": %s,"EnableDDNS": %s,"DDNSDomain": %s}`, s.ID, name, secret, s.DisplayIndex, tag, note, boolToString(s.HideForGuest), boolToString(s.EnableDDNS), ddnsDomain)) // #nosec
|
||||
}
|
||||
|
||||
+26
-5
@@ -1,7 +1,7 @@
|
||||
package ddns
|
||||
|
||||
import (
|
||||
"golang.org/x/net/publicsuffix"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@@ -33,8 +33,29 @@ func SetStringHeadersToRequest(req *http.Request, headers []string) {
|
||||
}
|
||||
|
||||
// SplitDomain 分割域名为前缀和一级域名
|
||||
func SplitDomain(domain string) (prefix string, realDomain string) {
|
||||
realDomain, _ = publicsuffix.EffectiveTLDPlusOne(domain)
|
||||
prefix = domain[:len(domain)-len(realDomain)-1]
|
||||
return prefix, realDomain
|
||||
func SplitDomain(domain string) (prefix string, topLevelDomain string) {
|
||||
// 带有二级TLD的一些常见例子,需要特别处理
|
||||
secondLevelTLDs := map[string]bool{
|
||||
".co.uk": true, ".com.cn": true, ".gov.cn": true, ".net.cn": true, ".org.cn": true,
|
||||
}
|
||||
|
||||
// 分割域名为"."的各部分
|
||||
parts := strings.Split(domain, ".")
|
||||
|
||||
// 处理特殊情况,例如 ".co.uk"
|
||||
for i := len(parts) - 2; i > 0; i-- {
|
||||
potentialTLD := fmt.Sprintf(".%s.%s", parts[i], parts[i+1])
|
||||
if secondLevelTLDs[potentialTLD] {
|
||||
if i > 1 {
|
||||
return strings.Join(parts[:i-1], "."), strings.Join(parts[i-1:], ".")
|
||||
}
|
||||
return "", domain // 当域名仅为二级TLD时,无前缀
|
||||
}
|
||||
}
|
||||
|
||||
// 常规处理,查找最后一个"."前的所有内容作为前缀
|
||||
if len(parts) > 2 {
|
||||
return strings.Join(parts[:len(parts)-2], "."), strings.Join(parts[len(parts)-2:], ".")
|
||||
}
|
||||
return "", domain // 当域名不包含子域名时,无前缀
|
||||
}
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
package ddns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
url = "https://dnspod.tencentcloudapi.com"
|
||||
)
|
||||
|
||||
type ProviderTencentCloud struct {
|
||||
SecretID string
|
||||
SecretKey string
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) UpdateDomain(domainConfig *DomainConfig) bool {
|
||||
if domainConfig == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 当IPv4和IPv6同时成功才算作成功
|
||||
var resultV4 = true
|
||||
var resultV6 = true
|
||||
if domainConfig.EnableIPv4 {
|
||||
if !provider.addDomainRecord(domainConfig, true) {
|
||||
resultV4 = false
|
||||
}
|
||||
}
|
||||
|
||||
if domainConfig.EnableIpv6 {
|
||||
if !provider.addDomainRecord(domainConfig, false) {
|
||||
resultV6 = false
|
||||
}
|
||||
}
|
||||
|
||||
return resultV4 && resultV6
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) addDomainRecord(domainConfig *DomainConfig, isIpv4 bool) bool {
|
||||
record, err := provider.findDNSRecord(domainConfig.FullDomain, isIpv4)
|
||||
if err != nil {
|
||||
log.Printf("查找 DNS 记录时出错: %s\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
if errResponse, ok := record["Error"].(map[string]interface{}); ok {
|
||||
if errCode, ok := errResponse["Code"].(string); ok && errCode == "ResourceNotFound.NoDataOfRecord" { // 没有找到 DNS 记录
|
||||
// 添加 DNS 记录
|
||||
return provider.createDNSRecord(domainConfig.FullDomain, domainConfig, isIpv4)
|
||||
} else {
|
||||
log.Printf("查询 DNS 记录时出错,错误代码为: %s\n", errCode)
|
||||
}
|
||||
}
|
||||
|
||||
// 默认情况下更新 DNS 记录
|
||||
return provider.updateDNSRecord(domainConfig.FullDomain, record["RecordList"].([]interface{})[0].(map[string]interface{})["RecordId"].(float64), domainConfig, isIpv4)
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) findDNSRecord(domain string, isIPv4 bool) (map[string]interface{}, error) {
|
||||
var ipType = "A"
|
||||
if !isIPv4 {
|
||||
ipType = "AAAA"
|
||||
}
|
||||
_, realDomain := SplitDomain(domain)
|
||||
prefix, _ := SplitDomain(domain)
|
||||
data := map[string]interface{}{
|
||||
"RecordType": ipType,
|
||||
"Domain": realDomain,
|
||||
"RecordLine": "默认",
|
||||
"Subdomain": prefix,
|
||||
}
|
||||
jsonData, _ := json.Marshal(data)
|
||||
body, err := provider.sendRequest("DescribeRecordList", jsonData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var res map[string]interface{}
|
||||
err = json.Unmarshal(body, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := res["Response"].(map[string]interface{})
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) createDNSRecord(domain string, domainConfig *DomainConfig, isIPv4 bool) bool {
|
||||
var ipType = "A"
|
||||
var ipAddr = domainConfig.Ipv4Addr
|
||||
if !isIPv4 {
|
||||
ipType = "AAAA"
|
||||
ipAddr = domainConfig.Ipv6Addr
|
||||
}
|
||||
_, realDomain := SplitDomain(domain)
|
||||
prefix, _ := SplitDomain(domain)
|
||||
data := map[string]interface{}{
|
||||
"RecordType": ipType,
|
||||
"RecordLine": "默认",
|
||||
"Domain": realDomain,
|
||||
"SubDomain": prefix,
|
||||
"Value": ipAddr,
|
||||
"TTL": 600,
|
||||
}
|
||||
jsonData, _ := json.Marshal(data)
|
||||
_, err := provider.sendRequest("CreateRecord", jsonData)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) updateDNSRecord(domain string, recordID float64, domainConfig *DomainConfig, isIPv4 bool) bool {
|
||||
var ipType = "A"
|
||||
var ipAddr = domainConfig.Ipv4Addr
|
||||
if !isIPv4 {
|
||||
ipType = "AAAA"
|
||||
ipAddr = domainConfig.Ipv6Addr
|
||||
}
|
||||
_, realDomain := SplitDomain(domain)
|
||||
prefix, _ := SplitDomain(domain)
|
||||
data := map[string]interface{}{
|
||||
"RecordType": ipType,
|
||||
"RecordLine": "默认",
|
||||
"Domain": realDomain,
|
||||
"SubDomain": prefix,
|
||||
"Value": ipAddr,
|
||||
"TTL": 600,
|
||||
"RecordId": recordID,
|
||||
}
|
||||
jsonData, _ := json.Marshal(data)
|
||||
_, err := provider.sendRequest("ModifyRecord", jsonData)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// 以下为辅助方法,如发送 HTTP 请求等
|
||||
func (provider ProviderTencentCloud) sendRequest(action string, data []byte) ([]byte, error) {
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("X-TC-Version", "2021-03-23")
|
||||
|
||||
provider.signRequest(provider.SecretID, provider.SecretKey, req, action, string(data))
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
log.Printf("NEZHA>> 无法关闭HTTP响应体流: %s\n", err.Error())
|
||||
}
|
||||
}(resp.Body)
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return body, nil
|
||||
}
|
||||
|
||||
// https://github.com/jeessy2/ddns-go/blob/master/util/tencent_cloud_signer.go
|
||||
|
||||
func (provider ProviderTencentCloud) sha256hex(s string) string {
|
||||
b := sha256.Sum256([]byte(s))
|
||||
return hex.EncodeToString(b[:])
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) hmacsha256(s, key string) string {
|
||||
hashed := hmac.New(sha256.New, []byte(key))
|
||||
hashed.Write([]byte(s))
|
||||
return string(hashed.Sum(nil))
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) WriteString(strs ...string) string {
|
||||
var b strings.Builder
|
||||
for _, str := range strs {
|
||||
b.WriteString(str)
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func (provider ProviderTencentCloud) signRequest(secretId string, secretKey string, r *http.Request, action string, payload string) {
|
||||
algorithm := "TC3-HMAC-SHA256"
|
||||
service := "dnspod"
|
||||
host := provider.WriteString(service, ".tencentcloudapi.com")
|
||||
timestamp := time.Now().Unix()
|
||||
timestampStr := strconv.FormatInt(timestamp, 10)
|
||||
|
||||
// 步骤 1:拼接规范请求串
|
||||
canonicalHeaders := provider.WriteString("content-type:application/json\nhost:", host, "\nx-tc-action:", strings.ToLower(action), "\n")
|
||||
signedHeaders := "content-type;host;x-tc-action"
|
||||
hashedRequestPayload := provider.sha256hex(payload)
|
||||
canonicalRequest := provider.WriteString("POST\n/\n\n", canonicalHeaders, "\n", signedHeaders, "\n", hashedRequestPayload)
|
||||
|
||||
// 步骤 2:拼接待签名字符串
|
||||
date := time.Unix(timestamp, 0).UTC().Format("2006-01-02")
|
||||
credentialScope := provider.WriteString(date, "/", service, "/tc3_request")
|
||||
hashedCanonicalRequest := provider.sha256hex(canonicalRequest)
|
||||
string2sign := provider.WriteString(algorithm, "\n", timestampStr, "\n", credentialScope, "\n", hashedCanonicalRequest)
|
||||
|
||||
// 步骤 3:计算签名
|
||||
secretDate := provider.hmacsha256(date, provider.WriteString("TC3", secretKey))
|
||||
secretService := provider.hmacsha256(service, secretDate)
|
||||
secretSigning := provider.hmacsha256("tc3_request", secretService)
|
||||
signature := hex.EncodeToString([]byte(provider.hmacsha256(string2sign, secretSigning)))
|
||||
|
||||
// 步骤 4:拼接 Authorization
|
||||
authorization := provider.WriteString(algorithm, " Credential=", secretId, "/", credentialScope, ", SignedHeaders=", signedHeaders, ", Signature=", signature)
|
||||
|
||||
r.Header.Add("Authorization", authorization)
|
||||
r.Header.Set("Host", host)
|
||||
r.Header.Set("X-TC-Action", action)
|
||||
r.Header.Add("X-TC-Timestamp", timestampStr)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package cloudflare
|
||||
|
||||
import (
|
||||
"github.com/naiba/nezha/model"
|
||||
"github.com/naiba/nezha/service/singleton"
|
||||
)
|
||||
|
||||
type UserInfo struct {
|
||||
Sub string `json:"sub"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Groups []string `json:"groups"`
|
||||
}
|
||||
|
||||
func (u UserInfo) MapToNezhaUser() model.User {
|
||||
var user model.User
|
||||
singleton.DB.Where("login = ?", u.Sub).First(&user)
|
||||
user.Login = u.Sub
|
||||
user.Email = u.Email
|
||||
user.Name = u.Name
|
||||
return user
|
||||
}
|
||||
+77
-164
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v5.26.1
|
||||
// protoc v3.21.12
|
||||
// source: proto/nezha.proto
|
||||
|
||||
package proto
|
||||
@@ -160,22 +160,21 @@ type State struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Cpu float64 `protobuf:"fixed64,1,opt,name=cpu,proto3" json:"cpu,omitempty"`
|
||||
MemUsed uint64 `protobuf:"varint,3,opt,name=mem_used,json=memUsed,proto3" json:"mem_used,omitempty"`
|
||||
SwapUsed uint64 `protobuf:"varint,4,opt,name=swap_used,json=swapUsed,proto3" json:"swap_used,omitempty"`
|
||||
DiskUsed uint64 `protobuf:"varint,5,opt,name=disk_used,json=diskUsed,proto3" json:"disk_used,omitempty"`
|
||||
NetInTransfer uint64 `protobuf:"varint,6,opt,name=net_in_transfer,json=netInTransfer,proto3" json:"net_in_transfer,omitempty"`
|
||||
NetOutTransfer uint64 `protobuf:"varint,7,opt,name=net_out_transfer,json=netOutTransfer,proto3" json:"net_out_transfer,omitempty"`
|
||||
NetInSpeed uint64 `protobuf:"varint,8,opt,name=net_in_speed,json=netInSpeed,proto3" json:"net_in_speed,omitempty"`
|
||||
NetOutSpeed uint64 `protobuf:"varint,9,opt,name=net_out_speed,json=netOutSpeed,proto3" json:"net_out_speed,omitempty"`
|
||||
Uptime uint64 `protobuf:"varint,10,opt,name=uptime,proto3" json:"uptime,omitempty"`
|
||||
Load1 float64 `protobuf:"fixed64,11,opt,name=load1,proto3" json:"load1,omitempty"`
|
||||
Load5 float64 `protobuf:"fixed64,12,opt,name=load5,proto3" json:"load5,omitempty"`
|
||||
Load15 float64 `protobuf:"fixed64,13,opt,name=load15,proto3" json:"load15,omitempty"`
|
||||
TcpConnCount uint64 `protobuf:"varint,14,opt,name=tcp_conn_count,json=tcpConnCount,proto3" json:"tcp_conn_count,omitempty"`
|
||||
UdpConnCount uint64 `protobuf:"varint,15,opt,name=udp_conn_count,json=udpConnCount,proto3" json:"udp_conn_count,omitempty"`
|
||||
ProcessCount uint64 `protobuf:"varint,16,opt,name=process_count,json=processCount,proto3" json:"process_count,omitempty"`
|
||||
Temperatures []*State_SensorTemperature `protobuf:"bytes,17,rep,name=temperatures,proto3" json:"temperatures,omitempty"`
|
||||
Cpu float64 `protobuf:"fixed64,1,opt,name=cpu,proto3" json:"cpu,omitempty"`
|
||||
MemUsed uint64 `protobuf:"varint,3,opt,name=mem_used,json=memUsed,proto3" json:"mem_used,omitempty"`
|
||||
SwapUsed uint64 `protobuf:"varint,4,opt,name=swap_used,json=swapUsed,proto3" json:"swap_used,omitempty"`
|
||||
DiskUsed uint64 `protobuf:"varint,5,opt,name=disk_used,json=diskUsed,proto3" json:"disk_used,omitempty"`
|
||||
NetInTransfer uint64 `protobuf:"varint,6,opt,name=net_in_transfer,json=netInTransfer,proto3" json:"net_in_transfer,omitempty"`
|
||||
NetOutTransfer uint64 `protobuf:"varint,7,opt,name=net_out_transfer,json=netOutTransfer,proto3" json:"net_out_transfer,omitempty"`
|
||||
NetInSpeed uint64 `protobuf:"varint,8,opt,name=net_in_speed,json=netInSpeed,proto3" json:"net_in_speed,omitempty"`
|
||||
NetOutSpeed uint64 `protobuf:"varint,9,opt,name=net_out_speed,json=netOutSpeed,proto3" json:"net_out_speed,omitempty"`
|
||||
Uptime uint64 `protobuf:"varint,10,opt,name=uptime,proto3" json:"uptime,omitempty"`
|
||||
Load1 float64 `protobuf:"fixed64,11,opt,name=load1,proto3" json:"load1,omitempty"`
|
||||
Load5 float64 `protobuf:"fixed64,12,opt,name=load5,proto3" json:"load5,omitempty"`
|
||||
Load15 float64 `protobuf:"fixed64,13,opt,name=load15,proto3" json:"load15,omitempty"`
|
||||
TcpConnCount uint64 `protobuf:"varint,14,opt,name=tcp_conn_count,json=tcpConnCount,proto3" json:"tcp_conn_count,omitempty"`
|
||||
UdpConnCount uint64 `protobuf:"varint,15,opt,name=udp_conn_count,json=udpConnCount,proto3" json:"udp_conn_count,omitempty"`
|
||||
ProcessCount uint64 `protobuf:"varint,16,opt,name=process_count,json=processCount,proto3" json:"process_count,omitempty"`
|
||||
}
|
||||
|
||||
func (x *State) Reset() {
|
||||
@@ -315,68 +314,6 @@ func (x *State) GetProcessCount() uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *State) GetTemperatures() []*State_SensorTemperature {
|
||||
if x != nil {
|
||||
return x.Temperatures
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type State_SensorTemperature struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Temperature float64 `protobuf:"fixed64,2,opt,name=temperature,proto3" json:"temperature,omitempty"`
|
||||
}
|
||||
|
||||
func (x *State_SensorTemperature) Reset() {
|
||||
*x = State_SensorTemperature{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_nezha_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *State_SensorTemperature) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*State_SensorTemperature) ProtoMessage() {}
|
||||
|
||||
func (x *State_SensorTemperature) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_nezha_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use State_SensorTemperature.ProtoReflect.Descriptor instead.
|
||||
func (*State_SensorTemperature) Descriptor() ([]byte, []int) {
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *State_SensorTemperature) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *State_SensorTemperature) GetTemperature() float64 {
|
||||
if x != nil {
|
||||
return x.Temperature
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -390,7 +327,7 @@ type Task struct {
|
||||
func (x *Task) Reset() {
|
||||
*x = Task{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_nezha_proto_msgTypes[3]
|
||||
mi := &file_proto_nezha_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -403,7 +340,7 @@ func (x *Task) String() string {
|
||||
func (*Task) ProtoMessage() {}
|
||||
|
||||
func (x *Task) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_nezha_proto_msgTypes[3]
|
||||
mi := &file_proto_nezha_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -416,7 +353,7 @@ func (x *Task) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Task.ProtoReflect.Descriptor instead.
|
||||
func (*Task) Descriptor() ([]byte, []int) {
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{3}
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Task) GetId() uint64 {
|
||||
@@ -455,7 +392,7 @@ type TaskResult struct {
|
||||
func (x *TaskResult) Reset() {
|
||||
*x = TaskResult{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_nezha_proto_msgTypes[4]
|
||||
mi := &file_proto_nezha_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -468,7 +405,7 @@ func (x *TaskResult) String() string {
|
||||
func (*TaskResult) ProtoMessage() {}
|
||||
|
||||
func (x *TaskResult) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_nezha_proto_msgTypes[4]
|
||||
mi := &file_proto_nezha_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -481,7 +418,7 @@ func (x *TaskResult) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TaskResult.ProtoReflect.Descriptor instead.
|
||||
func (*TaskResult) Descriptor() ([]byte, []int) {
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{4}
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *TaskResult) GetId() uint64 {
|
||||
@@ -530,7 +467,7 @@ type Receipt struct {
|
||||
func (x *Receipt) Reset() {
|
||||
*x = Receipt{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_nezha_proto_msgTypes[5]
|
||||
mi := &file_proto_nezha_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -543,7 +480,7 @@ func (x *Receipt) String() string {
|
||||
func (*Receipt) ProtoMessage() {}
|
||||
|
||||
func (x *Receipt) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_nezha_proto_msgTypes[5]
|
||||
mi := &file_proto_nezha_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -556,7 +493,7 @@ func (x *Receipt) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Receipt.ProtoReflect.Descriptor instead.
|
||||
func (*Receipt) Descriptor() ([]byte, []int) {
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{5}
|
||||
return file_proto_nezha_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *Receipt) GetProced() bool {
|
||||
@@ -592,7 +529,7 @@ var file_proto_nezha_proto_rawDesc = []byte{
|
||||
0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65,
|
||||
0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x43,
|
||||
0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0c,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x97, 0x04,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xd3, 0x03,
|
||||
0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x65, 0x6d,
|
||||
0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x65, 0x6d,
|
||||
@@ -622,45 +559,35 @@ var file_proto_nezha_proto_rawDesc = []byte{
|
||||
0x52, 0x0c, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x23,
|
||||
0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18,
|
||||
0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75,
|
||||
0x72, 0x65, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x54, 0x65,
|
||||
0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x65,
|
||||
0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0x4f, 0x0a, 0x17, 0x53, 0x74, 0x61, 0x74, 0x65,
|
||||
0x5f, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75,
|
||||
0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x65, 0x72,
|
||||
0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x74, 0x65, 0x6d,
|
||||
0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x3e, 0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b,
|
||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04,
|
||||
0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x7a, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b,
|
||||
0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65,
|
||||
0x6c, 0x61, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x64, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x66,
|
||||
0x75, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73,
|
||||
0x73, 0x66, 0x75, 0x6c, 0x22, 0x21, 0x0a, 0x07, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x32, 0xd6, 0x01, 0x0a, 0x0c, 0x4e, 0x65, 0x7a, 0x68,
|
||||
0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f,
|
||||
0x72, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0c, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x1a, 0x0e, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x22, 0x00, 0x12, 0x31, 0x0a,
|
||||
0x10, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66,
|
||||
0x6f, 0x12, 0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x1a, 0x0e,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x22, 0x00,
|
||||
0x12, 0x31, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x11,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c,
|
||||
0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70,
|
||||
0x74, 0x22, 0x00, 0x12, 0x2b, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x61,
|
||||
0x73, 0x6b, 0x12, 0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x1a,
|
||||
0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x22, 0x00, 0x30, 0x01,
|
||||
0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
0x75, 0x6e, 0x74, 0x22, 0x3e, 0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64,
|
||||
0x61, 0x74, 0x61, 0x22, 0x7a, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c,
|
||||
0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69,
|
||||
0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
|
||||
0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x64,
|
||||
0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x66, 0x75, 0x6c, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x66, 0x75, 0x6c, 0x22,
|
||||
0x21, 0x0a, 0x07, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x63, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x63,
|
||||
0x65, 0x64, 0x32, 0xd6, 0x01, 0x0a, 0x0c, 0x4e, 0x65, 0x7a, 0x68, 0x61, 0x53, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x79, 0x73,
|
||||
0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x1a, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52,
|
||||
0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6f,
|
||||
0x72, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0b, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x0a, 0x52,
|
||||
0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x0e, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x22, 0x00, 0x12, 0x2b,
|
||||
0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0b, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x42, 0x09, 0x5a, 0x07, 0x2e,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -675,30 +602,28 @@ func file_proto_nezha_proto_rawDescGZIP() []byte {
|
||||
return file_proto_nezha_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_nezha_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_proto_nezha_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_proto_nezha_proto_goTypes = []interface{}{
|
||||
(*Host)(nil), // 0: proto.Host
|
||||
(*State)(nil), // 1: proto.State
|
||||
(*State_SensorTemperature)(nil), // 2: proto.State_SensorTemperature
|
||||
(*Task)(nil), // 3: proto.Task
|
||||
(*TaskResult)(nil), // 4: proto.TaskResult
|
||||
(*Receipt)(nil), // 5: proto.Receipt
|
||||
(*Host)(nil), // 0: proto.Host
|
||||
(*State)(nil), // 1: proto.State
|
||||
(*Task)(nil), // 2: proto.Task
|
||||
(*TaskResult)(nil), // 3: proto.TaskResult
|
||||
(*Receipt)(nil), // 4: proto.Receipt
|
||||
}
|
||||
var file_proto_nezha_proto_depIdxs = []int32{
|
||||
2, // 0: proto.State.temperatures:type_name -> proto.State_SensorTemperature
|
||||
1, // 1: proto.NezhaService.ReportSystemState:input_type -> proto.State
|
||||
0, // 2: proto.NezhaService.ReportSystemInfo:input_type -> proto.Host
|
||||
4, // 3: proto.NezhaService.ReportTask:input_type -> proto.TaskResult
|
||||
0, // 4: proto.NezhaService.RequestTask:input_type -> proto.Host
|
||||
5, // 5: proto.NezhaService.ReportSystemState:output_type -> proto.Receipt
|
||||
5, // 6: proto.NezhaService.ReportSystemInfo:output_type -> proto.Receipt
|
||||
5, // 7: proto.NezhaService.ReportTask:output_type -> proto.Receipt
|
||||
3, // 8: proto.NezhaService.RequestTask:output_type -> proto.Task
|
||||
5, // [5:9] is the sub-list for method output_type
|
||||
1, // [1:5] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
1, // 0: proto.NezhaService.ReportSystemState:input_type -> proto.State
|
||||
0, // 1: proto.NezhaService.ReportSystemInfo:input_type -> proto.Host
|
||||
3, // 2: proto.NezhaService.ReportTask:input_type -> proto.TaskResult
|
||||
0, // 3: proto.NezhaService.RequestTask:input_type -> proto.Host
|
||||
4, // 4: proto.NezhaService.ReportSystemState:output_type -> proto.Receipt
|
||||
4, // 5: proto.NezhaService.ReportSystemInfo:output_type -> proto.Receipt
|
||||
4, // 6: proto.NezhaService.ReportTask:output_type -> proto.Receipt
|
||||
2, // 7: proto.NezhaService.RequestTask:output_type -> proto.Task
|
||||
4, // [4:8] is the sub-list for method output_type
|
||||
0, // [0:4] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_nezha_proto_init() }
|
||||
@@ -732,18 +657,6 @@ func file_proto_nezha_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_nezha_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*State_SensorTemperature); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_nezha_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Task); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -755,7 +668,7 @@ func file_proto_nezha_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_nezha_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proto_nezha_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*TaskResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -767,7 +680,7 @@ func file_proto_nezha_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_nezha_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proto_nezha_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Receipt); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -786,7 +699,7 @@ func file_proto_nezha_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_nezha_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
@@ -41,12 +41,6 @@ message State {
|
||||
uint64 tcp_conn_count = 14;
|
||||
uint64 udp_conn_count = 15;
|
||||
uint64 process_count = 16;
|
||||
repeated State_SensorTemperature temperatures = 17;
|
||||
}
|
||||
|
||||
message State_SensorTemperature {
|
||||
string name = 1;
|
||||
double temperature = 2;
|
||||
}
|
||||
|
||||
message Task {
|
||||
|
||||
Vendored
+12
-27
@@ -32,10 +32,10 @@ other = "Logout"
|
||||
other = "Login"
|
||||
|
||||
[ConfirmLogout]
|
||||
other = "Do you want to Logout?"
|
||||
other = "Confirm Logout?"
|
||||
|
||||
[AfterLoggingOutYouHaveToLoginAgain]
|
||||
other = "You need to Login again to continue"
|
||||
other = "You need to login again after logout to continue"
|
||||
|
||||
[Cancel]
|
||||
other = "Cancel"
|
||||
@@ -227,7 +227,7 @@ other = "Secret"
|
||||
other = "Note"
|
||||
|
||||
[LinuxOneKeyInstall]
|
||||
other = "Linux One-Command Install"
|
||||
other = "Linux One-Key Install"
|
||||
|
||||
[NoDomainAlert]
|
||||
other = "Set CDN bypassed Domain/IP in setting before using this function"
|
||||
@@ -257,7 +257,7 @@ other = "Execute by Trigger"
|
||||
other = "Delete Scheduled Task"
|
||||
|
||||
[ConfirmToDeleteThisScheduledTask]
|
||||
other = "Are you sure you want to Delete?"
|
||||
other = "Confirm Delete?"
|
||||
|
||||
[AccessDenied]
|
||||
other = "Access Denied"
|
||||
@@ -293,7 +293,7 @@ other = "Delete Notification Method"
|
||||
other = "Confirm to Delete This Notification Method?"
|
||||
|
||||
[ForceUpdate]
|
||||
other = "Force to Update"
|
||||
other = "Force Update"
|
||||
|
||||
[SelectAll]
|
||||
other = "Select All"
|
||||
@@ -302,7 +302,7 @@ other = "Select All"
|
||||
other = "Version"
|
||||
|
||||
[OneKeyInstall]
|
||||
other = "One-Command Install"
|
||||
other = "One-Key Install"
|
||||
|
||||
[ClickToCopy]
|
||||
other = "Click To Copy"
|
||||
@@ -398,7 +398,7 @@ other = "Virtualization"
|
||||
other = "Swap"
|
||||
|
||||
[NetTransfer]
|
||||
other = "Usage"
|
||||
other = "Transfer"
|
||||
|
||||
[Load]
|
||||
other = "Load"
|
||||
@@ -419,7 +419,7 @@ other = "Last Active"
|
||||
other = "Version"
|
||||
|
||||
[NetSpeed]
|
||||
other = "NIC"
|
||||
other = "Speed"
|
||||
|
||||
[Uptime]
|
||||
other = "Uptime"
|
||||
@@ -473,7 +473,7 @@ other = "Next check"
|
||||
other = "Current Usage"
|
||||
|
||||
[VerifyPassword]
|
||||
other = "Please enter your password"
|
||||
other = "Verify Password"
|
||||
|
||||
[LightMode]
|
||||
other = "Light Mode"
|
||||
@@ -482,7 +482,7 @@ other = "Light Mode"
|
||||
other = "Dark Mode"
|
||||
|
||||
[FollowSystem]
|
||||
other = "System Auto"
|
||||
other = "Follow System"
|
||||
|
||||
[GridLayout]
|
||||
other = "Grid Layout"
|
||||
@@ -619,18 +619,9 @@ other = "Enable Show in Service"
|
||||
[EnableDDNS]
|
||||
other = "Enable DDNS"
|
||||
|
||||
[EnableIPv4]
|
||||
other = "Enable DDNS IPv4"
|
||||
|
||||
[EnableIpv6]
|
||||
other = "Enable DDNS IPv6"
|
||||
|
||||
[DDNSDomain]
|
||||
other = "DDNS Domain"
|
||||
|
||||
[DDNSProfile]
|
||||
other = "DDNS Profile Name"
|
||||
|
||||
[Feature]
|
||||
other = "Feature"
|
||||
|
||||
@@ -638,13 +629,7 @@ other = "Feature"
|
||||
other = "Template"
|
||||
|
||||
[Stat]
|
||||
other = "Asset"
|
||||
|
||||
[Temperature]
|
||||
other = "Temperature"
|
||||
other = "Stat"
|
||||
|
||||
[DisableSwitchTemplateInFrontend]
|
||||
other = "Disable Switch Template in Frontend"
|
||||
|
||||
[ServersOnWorldMap]
|
||||
other = "Servers On World Map"
|
||||
other = "Disable Switch Template in Frontend"
|
||||
Vendored
+1
-16
@@ -619,18 +619,9 @@ other = "Mostrar en servicio"
|
||||
[EnableDDNS]
|
||||
other = "Habilitar DDNS"
|
||||
|
||||
[EnableIPv4]
|
||||
other = "Habilitar DDNS IPv4"
|
||||
|
||||
[EnableIpv6]
|
||||
other = "Habilitar DDNS IPv6"
|
||||
|
||||
[DDNSDomain]
|
||||
other = "Dominio DDNS"
|
||||
|
||||
[DDNSProfile]
|
||||
other = "Nombre del perfil de DDNS"
|
||||
|
||||
[Feature]
|
||||
other = "Característica"
|
||||
|
||||
@@ -640,11 +631,5 @@ other = "Plantilla"
|
||||
[Stat]
|
||||
other = "Stat"
|
||||
|
||||
[Temperature]
|
||||
other = "Temperatura"
|
||||
|
||||
[DisableSwitchTemplateInFrontend]
|
||||
other = "Deshabilitar Cambio de Plantilla en Frontend"
|
||||
|
||||
[ServersOnWorldMap]
|
||||
other = "Servidores en el mapa mundial"
|
||||
other = "Deshabilitar Cambio de Plantilla en Frontend"
|
||||
Vendored
-15
@@ -619,18 +619,9 @@ other = "在服务中显示"
|
||||
[EnableDDNS]
|
||||
other = "启用DDNS"
|
||||
|
||||
[EnableIPv4]
|
||||
other = "启用DDNS IPv4"
|
||||
|
||||
[EnableIpv6]
|
||||
other = "启用DDNS IPv6"
|
||||
|
||||
[DDNSDomain]
|
||||
other = "DDNS域名"
|
||||
|
||||
[DDNSProfile]
|
||||
other = "DDNS配置名"
|
||||
|
||||
[Feature]
|
||||
other = "功能"
|
||||
|
||||
@@ -640,11 +631,5 @@ other = "主题"
|
||||
[Stat]
|
||||
other = "信息"
|
||||
|
||||
[Temperature]
|
||||
other = "温度"
|
||||
|
||||
[DisableSwitchTemplateInFrontend]
|
||||
other = "禁止前台切换模板"
|
||||
|
||||
[ServersOnWorldMap]
|
||||
other = "服务器世界分布图"
|
||||
|
||||
Vendored
-15
@@ -619,18 +619,9 @@ other = "在服務中顯示"
|
||||
[EnableDDNS]
|
||||
other = "啟用DDNS"
|
||||
|
||||
[EnableIPv4]
|
||||
other = "啟用DDNS IPv4"
|
||||
|
||||
[EnableIpv6]
|
||||
other = "啟用DDNS IPv6"
|
||||
|
||||
[DDNSDomain]
|
||||
other = "DDNS網域"
|
||||
|
||||
[DDNSProfile]
|
||||
other = "DDNS設定名"
|
||||
|
||||
[Feature]
|
||||
other = "功能"
|
||||
|
||||
@@ -640,11 +631,5 @@ other = "主題"
|
||||
[Stat]
|
||||
other = "信息"
|
||||
|
||||
[Temperature]
|
||||
other = "溫度"
|
||||
|
||||
[DisableSwitchTemplateInFrontend]
|
||||
other = "禁止前台切換主題"
|
||||
|
||||
[ServersOnWorldMap]
|
||||
other = "伺服器世界分布圖"
|
||||
|
||||
@@ -303,7 +303,6 @@ function addOrEditServer(server, conf) {
|
||||
modal.find("input[name=name]").val(server ? server.Name : null);
|
||||
modal.find("input[name=Tag]").val(server ? server.Tag : null);
|
||||
modal.find("input[name=DDNSDomain]").val(server ? server.DDNSDomain : null);
|
||||
modal.find("input[name=DDNSProfile]").val(server ? server.DDNSProfile : null);
|
||||
modal
|
||||
.find("input[name=DisplayIndex]")
|
||||
.val(server ? server.DisplayIndex : null);
|
||||
@@ -328,16 +327,6 @@ function addOrEditServer(server, conf) {
|
||||
} else {
|
||||
modal.find(".ui.enableddns.checkbox").checkbox("set unchecked");
|
||||
}
|
||||
if (server && server.EnableIPv4) {
|
||||
modal.find(".ui.enableipv4.checkbox").checkbox("set checked");
|
||||
} else {
|
||||
modal.find(".ui.enableipv4.checkbox").checkbox("set unchecked");
|
||||
}
|
||||
if (server && server.EnableIpv6) {
|
||||
modal.find(".ui.enableipv6.checkbox").checkbox("set checked");
|
||||
} else {
|
||||
modal.find(".ui.enableipv6.checkbox").checkbox("set unchecked");
|
||||
}
|
||||
showFormModal(".server.modal", "#serverForm", "/api/server");
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -10,6 +10,14 @@
|
||||
.ui.card>.content>.header:not(.ui),.ui.cards>.card>.content>.header:not(.ui) {
|
||||
margin-top:0.4em !important;
|
||||
}
|
||||
.ui.card>.content>.header,.ui.cards>.card>.content>.header {
|
||||
padding-top: 0.5rem;
|
||||
display: flex;
|
||||
color: rgba(0, 0, 0, .85);
|
||||
align-items: center;
|
||||
padding-bottom: .2em;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, .2);
|
||||
}
|
||||
.ui.menu .item>img:not(.ui){
|
||||
width: 2.2rem;
|
||||
}
|
||||
@@ -215,4 +223,4 @@ td {
|
||||
|
||||
.ui-alerts.top-center {
|
||||
z-index: 99999999;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,16 +157,3 @@ body[theme="dark"] footer p a:hover {
|
||||
color: #f1f1f1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
body[theme="dark"] .modal-content{
|
||||
background-color: #1c1d26;
|
||||
color: #f1f1f1;
|
||||
}
|
||||
|
||||
body[theme="dark"] .modal-header{
|
||||
border-bottom-color:#080808;
|
||||
}
|
||||
|
||||
body[theme="dark"] .modal-header i{
|
||||
color: #f1f1f1;
|
||||
}
|
||||
|
||||
@@ -131,17 +131,4 @@ body[theme="light"] footer p a,
|
||||
body[theme="light"] footer p a:hover {
|
||||
color: #333333;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
body[theme="light"] .modal-content{
|
||||
background-color: #ffffff;
|
||||
color: rgba(0, 0, 0, 0.87);
|
||||
}
|
||||
|
||||
body[theme="light"] .modal-header{
|
||||
border-bottom-color:#f1f1f1;
|
||||
}
|
||||
|
||||
body[theme="light"] .modal-header i{
|
||||
color: rgba(0, 0, 0, 0.87);
|
||||
}
|
||||
+3
-45
@@ -281,42 +281,10 @@ body {
|
||||
.service-status .tooltip-inner {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 服务页 正文结束 */
|
||||
|
||||
|
||||
/* 服务器分布图 */
|
||||
#mapChartBox{
|
||||
z-index: 999999999;
|
||||
}
|
||||
|
||||
.modal-content{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.modal-dialog-centered{
|
||||
margin: 0 auto;
|
||||
width: 1134px;
|
||||
max-width: 1134px;
|
||||
display: flex;
|
||||
align-items: center; /* 垂直居中 */
|
||||
justify-content: center; /* 水平居中 */
|
||||
min-height: calc(100%) /* 确保模态框占据整个视口高度 */
|
||||
}
|
||||
|
||||
.modal-header{
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.modal-header i{
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
font-size: 2em;
|
||||
top: 13px;
|
||||
right: 13px;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1200px) {
|
||||
.accordian-body{
|
||||
margin: 5px 0px 5px 10px;
|
||||
@@ -397,16 +365,6 @@ body {
|
||||
.toolbox {
|
||||
right: 18px;
|
||||
}
|
||||
.modal-dialog-centered{
|
||||
width: 95%;
|
||||
}
|
||||
.modal-title{
|
||||
line-height: 0.5;
|
||||
}
|
||||
.modal-header i{
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (min-width: 768px) {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
/** Name of the expando, to work with multiple documents or to re-shiv one document */
|
||||
var expando = '_html5shiv';
|
||||
|
||||
/** The id for the documents expando */
|
||||
/** The id for the the documents expando */
|
||||
var expanID = 0;
|
||||
|
||||
/** Cached data for each document */
|
||||
|
||||
-20
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -10,7 +10,7 @@
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
|
||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
|
||||
<script src="/static/main.js?v20240330"></script>
|
||||
<script src="/static/main.js?v20240224"></script>
|
||||
<script>
|
||||
(function () {
|
||||
updateLang({{.LANG }});
|
||||
|
||||
-16
@@ -32,26 +32,10 @@
|
||||
<label>{{tr "EnableDDNS"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableipv4 checkbox">
|
||||
<input name="EnableIPv4" type="checkbox" tabindex="0" />
|
||||
<label>{{tr "EnableIPv4"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableipv6 checkbox">
|
||||
<input name="EnableIpv6" type="checkbox" tabindex="0" />
|
||||
<label>{{tr "EnableIpv6"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSDomain"}}</label>
|
||||
<input type="text" name="DDNSDomain" placeholder="{{tr "DDNSDomain"}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSProfile"}}</label>
|
||||
<input type="text" name="DDNSProfile" placeholder="{{tr "DDNSProfile"}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "Note"}}</label>
|
||||
<textarea name="Note"></textarea>
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
<th>{{tr "VersionNumber"}}</th>
|
||||
<th>{{tr "HideForGuest"}}</th>
|
||||
<th>{{tr "EnableDDNS"}}</th>
|
||||
<th>{{tr "EnableIPv4"}}</th>
|
||||
<th>{{tr "EnableIpv6"}}</th>
|
||||
<th>{{tr "DDNSDomain"}}</th>
|
||||
<th>{{tr "Secret"}}</th>
|
||||
<th>{{tr "OneKeyInstall"}}</th>
|
||||
@@ -50,8 +48,6 @@
|
||||
<td>{{$server.Host.Version}}</td>
|
||||
<td>{{$server.HideForGuest}}</td>
|
||||
<td>{{$server.EnableDDNS}}</td>
|
||||
<td>{{$server.EnableIPv4}}</td>
|
||||
<td>{{$server.EnableIpv6}}</td>
|
||||
<td>{{$server.DDNSDomain}}</td>
|
||||
<td>
|
||||
<button class="ui icon green mini button" data-clipboard-text="{{$server.Secret}}" data-tooltip="{{tr "ClickToCopy"}}">
|
||||
@@ -69,11 +65,6 @@
|
||||
data-tooltip="{{tr "ClickToCopy"}}">
|
||||
<i class="windows icon"></i>
|
||||
</button>
|
||||
<button class="ui icon green mini button"
|
||||
data-clipboard-text="{{if $.Conf.GRPCHost}}curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.command -o nezha.command && chmod +x nezha.command && sudo ./nezha.command install_agent {{$.Conf.GRPCHost}} {{if $.Conf.ProxyGRPCPort}}{{$.Conf.ProxyGRPCPort}}{{else}}{{$.Conf.GRPCPort}}{{end}} {{$server.Secret}}{{if $.Conf.TLS}} --tls{{end}}{{else}}{{tr "NoDomainAlert"}}{{end}}"
|
||||
data-tooltip="{{tr "ClickToCopy"}}">
|
||||
<i class="apple icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td style="word-break: break-word;white-space: pre-wrap;">{{$server.Note}}</td>
|
||||
<td>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
|
||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
|
||||
<script src="/static/main.js?v20240330"></script>
|
||||
<script src="/static/main.js?v20240224"></script>
|
||||
<script src="/static/theme-default/js/mixin.js?v20240302"></script>
|
||||
<script>
|
||||
(function () {
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
<i :class="item.icon + ' icon'"></i>@#item.name#@
|
||||
<i class="check icon" v-if="preferredTemplate === item.key"></i>
|
||||
</a>
|
||||
<a v-if="defaultTemplate === 'custom'" @click="toggleTemplate('custom')" class="item">
|
||||
<i class="expand icon"></i>Custom
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
+317
-241
@@ -20,281 +20,357 @@
|
||||
</head>
|
||||
|
||||
<body data-theme="light" data-gridlist="grid">
|
||||
<header>
|
||||
<section class="nav-bar clearfix">
|
||||
<figure class="logo">
|
||||
<a href="/">
|
||||
<img src="/static/logo.svg?v20210804" alt='{{tr "NezhaMonitoring"}}' width="50" height="50">
|
||||
</a>
|
||||
<a href="/">{{.Conf.Site.Brand}}</a>
|
||||
</figure>
|
||||
<div class="icon-container">
|
||||
<div class="row cf">
|
||||
<div class="three col">
|
||||
<div class="hamburger" id="hamburger-icon"><span class="line"></span><span
|
||||
class="line"></span><span class="line"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="nav-menu">
|
||||
<ul>
|
||||
<li><a href="/">{{tr "Home"}}</a></li>
|
||||
<li><a href="/service">{{tr "Services"}}</a></li>
|
||||
<li><a href="/network">{{tr "NetworkSpiter"}}</a></li>
|
||||
{{if .Admin}}
|
||||
<li><a href="/server">{{tr "AdminPanel"}}</a></li>
|
||||
{{else}}
|
||||
<li><a href="/login">{{tr "Login"}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div id="network">
|
||||
<div class="server-info-container" v-for='server in servers' :id="server.ID">
|
||||
<div class="info-body" @click="redirectNetwork(server.ID)">
|
||||
<ul class="server-info-body-container">
|
||||
<li>
|
||||
<h3>@#server.Name#@</h3>
|
||||
</li>
|
||||
<li><img :src="'/static/theme-daynight/img/flag/'+(server.Host&&server.Host.CountryCode?server.Host.CountryCode.toUpperCase():'CN')+'.png'"
|
||||
:title="server.Host.CountryCode.toUpperCase()" /></li>
|
||||
</ul>
|
||||
<header>
|
||||
<section class="nav-bar clearfix">
|
||||
<figure class="logo">
|
||||
<a href="/">
|
||||
<img src="/static/logo.svg?v20210804" alt='{{tr "NezhaMonitoring"}}' width="50" height="50">
|
||||
</a>
|
||||
<a href="/">{{.Conf.Site.Brand}}</a>
|
||||
</figure>
|
||||
<div class="icon-container">
|
||||
<div class="row cf">
|
||||
<div class="three col">
|
||||
<div class="hamburger" id="hamburger-icon"><span class="line"></span><span
|
||||
class="line"></span><span class="line"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="network-chart" style="height: 800px;overflow: hidden">
|
||||
<div id="monitor-info-container" style="height: 520px;max-width: 1400px">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar-container">
|
||||
<nav class="nav-menu">
|
||||
<ul>
|
||||
<li><i class="fas fa-sun" title='{{tr "LightMode"}}'></i><span>{{tr "LightMode"}}</span></li>
|
||||
<li><i class="fas fa-moon" title='{{tr "DarkMode"}}'></i><span>{{tr "DarkMode"}}</span></li>
|
||||
<li><i class="fas fa-th" title='{{tr "GridLayout"}}'></i><span>{{tr "GridLayout"}}</span></li>
|
||||
<li><i class="fas fa-list-ul" title='{{tr "ListLayout"}}'></i><span>{{tr "ListLayout"}}</span></li>
|
||||
<li><a href="/">{{tr "Home"}}</a></li>
|
||||
<li><a href="/service">{{tr "Services"}}</a></li>
|
||||
<li><a href="/network">{{tr "NetworkSpiter"}}</a></li>
|
||||
{{if .Admin}}
|
||||
<li><a href="/server">{{tr "AdminPanel"}}</a></li>
|
||||
{{else}}
|
||||
<li><a href="/login">{{tr "Login"}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<section class="dark-light-toggle">
|
||||
<label class="switcher">
|
||||
<input type="checkbox" name="theme" id="dark-light" />
|
||||
<div>
|
||||
<i class="fas fa-adjust"></i>
|
||||
</div>
|
||||
</label>
|
||||
</nav>
|
||||
</section>
|
||||
</header>
|
||||
|
||||
<!-- Back to top button -->
|
||||
<a id="back-to-top"></a>
|
||||
<main>
|
||||
<div id="network">
|
||||
<div class="server-info-container" v-for='server in servers' :id="server.ID" style="font-size: .6em">
|
||||
<div class="info-body" @click="redirectNetwork(server.ID)">
|
||||
<ul class="server-info-body-container">
|
||||
<li>
|
||||
<h3>@#server.Name#@</h3>
|
||||
</li>
|
||||
<li><img :src="'/static/theme-daynight/img/flag/'+(server.Host&&server.Host.CountryCode?server.Host.CountryCode.toUpperCase():'CN')+'.png'"
|
||||
:title="server.Host.CountryCode.toUpperCase()" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="network-chart" style="height: 800px;overflow: hidden">
|
||||
<div id="monitor-info-container" style="height: 520px;max-width: 1400px">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar-container">
|
||||
<ul>
|
||||
<li><i class="fas fa-sun" title='{{tr "LightMode"}}'></i><span>{{tr "LightMode"}}</span></li>
|
||||
<li><i class="fas fa-moon" title='{{tr "DarkMode"}}'></i><span>{{tr "DarkMode"}}</span></li>
|
||||
<li><i class="fas fa-th" title='{{tr "GridLayout"}}'></i><span>{{tr "GridLayout"}}</span></li>
|
||||
<li><i class="fas fa-list-ul" title='{{tr "ListLayout"}}'></i><span>{{tr "ListLayout"}}</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<div class="footer-container">
|
||||
<div><a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "NezhaMonitoring"}} ·
|
||||
{{.Version}}</a>
|
||||
<p>© <span id="copyright-date">
|
||||
<section class="dark-light-toggle">
|
||||
<label class="switcher">
|
||||
<input type="checkbox" name="theme" id="dark-light" />
|
||||
<div>
|
||||
<i class="fas fa-adjust"></i>
|
||||
</div>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<!-- Back to top button -->
|
||||
<a id="back-to-top"></a>
|
||||
|
||||
<footer>
|
||||
<div class="footer-container">
|
||||
<div><a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "NezhaMonitoring"}} · {{.Version}}</a>
|
||||
<p>© <span id="copyright-date">
|
||||
<script>document.getElementById('copyright-date').appendChild(document.createTextNode(new Date().getFullYear()))</script>
|
||||
</span> · <a href="https://blog.jackiesung.com" target="_blank">Theme designed by Jackie Sung</a>
|
||||
</p>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="/static/theme-daynight/js/main.js?v202102012266"></script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
|
||||
<script
|
||||
src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js"></script>
|
||||
<script src="/static/theme-daynight/js/main.js?v202102012266"></script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js"></script>
|
||||
|
||||
<script>
|
||||
const monitorInfo = JSON.parse('{{.MonitorInfos}}');
|
||||
const initData = JSON.parse('{{.Servers}}').servers;
|
||||
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
const myChart = echarts.init(document.getElementById('monitor-info-container'));
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
var statusCards = new Vue({
|
||||
el: '#network',
|
||||
delimiters: ['@#', '#@'],
|
||||
data: {
|
||||
servers: initData,
|
||||
cache: [],
|
||||
option: {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
position: function (pt) {
|
||||
return [pt[0], '10%'];
|
||||
},
|
||||
formatter: function (params) {
|
||||
let result = params[0].axisValueLabel + "<br />";
|
||||
params.forEach(function (item) {
|
||||
result += item.marker + item.seriesName + ": " + item.value[1].toFixed(2) + " ms<br />";
|
||||
})
|
||||
return result;
|
||||
},
|
||||
confine: true,
|
||||
transitionDuration: 0
|
||||
<script>
|
||||
const monitorInfo = JSON.parse('{{.MonitorInfos}}');
|
||||
const initData = JSON.parse('{{.Servers}}').servers;
|
||||
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
|
||||
if (MaxTCPPingValue == null) {
|
||||
MaxTCPPingValue = 1000;
|
||||
}
|
||||
new Vue({
|
||||
el: '#app',
|
||||
delimiters: ['@#', '#@'],
|
||||
data: {
|
||||
page: 'network',
|
||||
defaultTemplate: {{.Conf.Site.Theme}},
|
||||
templates: {{.Themes}},
|
||||
servers: initData,
|
||||
option: {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
position: function (pt) {
|
||||
return [pt[0], '10%'];
|
||||
},
|
||||
title: {
|
||||
left: 'center',
|
||||
text: "",
|
||||
textStyle: {}
|
||||
formatter: function(params){
|
||||
let result = params[0].axisValueLabel + "<br />";
|
||||
params.forEach(function(item){
|
||||
result += item.marker + item.seriesName + ": " + item.value[1].toFixed(2) + " ms<br />";
|
||||
})
|
||||
return result;
|
||||
},
|
||||
legend: {
|
||||
top: '5%',
|
||||
data: [],
|
||||
textStyle: {
|
||||
fontSize: 14
|
||||
}
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
dataZoom: {
|
||||
yAxisIndex: 'none'
|
||||
},
|
||||
restore: {},
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
dataZoom: [
|
||||
{
|
||||
start: 94,
|
||||
end: 100
|
||||
}
|
||||
],
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
boundaryGap: false
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
boundaryGap: [0, '100%']
|
||||
},
|
||||
series: [],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.DarkMode();
|
||||
this.parseMonitorInfo(monitorInfo);
|
||||
window.addEventListener('resize', this.resizeHandle);
|
||||
},
|
||||
destroyed() {
|
||||
window.removeEventListener('resize', this.resizeHandle)
|
||||
},
|
||||
methods: {
|
||||
DarkMode() {
|
||||
const hour = new Date(Date.now()).getHours()
|
||||
if (hour > 17 || hour < 4) {
|
||||
document.querySelector("input[name=theme]").checked = true;
|
||||
document.getElementsByTagName("BODY")[0].setAttribute('data-theme', 'dark');
|
||||
document.getElementById("monitor-info-container").style.backgroundColor = "#1E1E1E";
|
||||
confine: true,
|
||||
transitionDuration: 0
|
||||
},
|
||||
title: {
|
||||
left: 'center',
|
||||
text: "",
|
||||
textStyle: {}
|
||||
},
|
||||
legend: {
|
||||
top: '5%',
|
||||
data: [],
|
||||
textStyle: {
|
||||
fontSize: 14
|
||||
}
|
||||
},
|
||||
redirectNetwork(id) {
|
||||
grid: {
|
||||
left: '8%',
|
||||
right: '8%',
|
||||
},
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.8)',
|
||||
toolbox: {
|
||||
feature: {
|
||||
dataZoom: {
|
||||
yAxisIndex: 'none'
|
||||
},
|
||||
restore: {},
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
dataZoom: [
|
||||
{
|
||||
start: 0,
|
||||
end: 100
|
||||
}
|
||||
],
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
boundaryGap: false
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
boundaryGap: false
|
||||
},
|
||||
series: [],
|
||||
},
|
||||
chartOnOff: true,
|
||||
},
|
||||
mixins: [mixinsVue],
|
||||
mounted() {
|
||||
this.renderChart();
|
||||
this.parseMonitorInfo(monitorInfo);
|
||||
window.addEventListener('resize', this.resizeHandle);
|
||||
},
|
||||
destroyed () {
|
||||
window.removeEventListener('resize', this.resizeHandle)
|
||||
},
|
||||
methods: {
|
||||
getFontLogoClass(str) {
|
||||
if (["almalinux",
|
||||
"alpine",
|
||||
"aosc",
|
||||
"apple",
|
||||
"archlinux",
|
||||
"archlabs",
|
||||
"artix",
|
||||
"budgie",
|
||||
"centos",
|
||||
"coreos",
|
||||
"debian",
|
||||
"deepin",
|
||||
"devuan",
|
||||
"docker",
|
||||
"elementary",
|
||||
"fedora",
|
||||
"ferris",
|
||||
"flathub",
|
||||
"freebsd",
|
||||
"gentoo",
|
||||
"gnu-guix",
|
||||
"illumos",
|
||||
"kali-linux",
|
||||
"linuxmint",
|
||||
"mageia",
|
||||
"mandriva",
|
||||
"manjaro",
|
||||
"nixos",
|
||||
"openbsd",
|
||||
"opensuse",
|
||||
"pop-os",
|
||||
"raspberry-pi",
|
||||
"redhat",
|
||||
"rocky-linux",
|
||||
"sabayon",
|
||||
"slackware",
|
||||
"snappy",
|
||||
"solus",
|
||||
"tux",
|
||||
"ubuntu",
|
||||
"void",
|
||||
"zorin"].indexOf(str)
|
||||
> -1) {
|
||||
return str;
|
||||
}
|
||||
if (['openwrt', 'linux', "immortalwrt"].indexOf(str) > -1) {
|
||||
return 'tux';
|
||||
}
|
||||
if (str == 'amazon') {
|
||||
return 'redhat';
|
||||
}
|
||||
if (str == 'arch') {
|
||||
return 'archlinux';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
redirectNetwork(id) {
|
||||
this.getMonitorHistory(id)
|
||||
.then(function (monitorInfo) {
|
||||
var vm = network.__vue__;
|
||||
vm.parseMonitorInfo(monitorInfo);
|
||||
})
|
||||
.catch(function (error) {
|
||||
window.location.href = "/404";
|
||||
})
|
||||
.then(function(monitorInfo) {
|
||||
var vm = app.__vue__;
|
||||
vm.parseMonitorInfo(monitorInfo);
|
||||
})
|
||||
.catch(function(error){
|
||||
window.location.href = "/404";
|
||||
})
|
||||
},
|
||||
getMonitorHistory(id) {
|
||||
return $.ajax({
|
||||
url: "/api/v1/monitor/" + id,
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
parseMonitorInfo(monitorInfo) {
|
||||
let tSeries = [];
|
||||
let tLegendData = [];
|
||||
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
var lcolor = lcolors[i % lcolors.length];
|
||||
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
|
||||
var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
|
||||
let loss = 0;
|
||||
let data = [];
|
||||
let datal = [];
|
||||
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
|
||||
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
|
||||
if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
|
||||
data.push([monitorInfo.result[i].created_at[j], avgDelay]);
|
||||
}
|
||||
else {
|
||||
loss += 1;
|
||||
datal.push({
|
||||
xAxis: monitorInfo.result[i].created_at[j],
|
||||
label: { show: false },
|
||||
emphasis: { disabled: true },
|
||||
lineStyle: {
|
||||
type: "solid",
|
||||
color: rgbaColorBar
|
||||
}
|
||||
});
|
||||
}
|
||||
getMonitorHistory(id) {
|
||||
return $.ajax({
|
||||
url: "/api/v1/monitor/"+id,
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
parseMonitorInfo(monitorInfo) {
|
||||
let tSeries = [];
|
||||
let tLegendData = [];
|
||||
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
|
||||
let maxPing = 0;
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
|
||||
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
|
||||
if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
|
||||
maxPing = avgDelay;
|
||||
}
|
||||
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
|
||||
if (lossRate > 99) {
|
||||
datal = [];
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
var lcolor = lcolors[i % lcolors.length];
|
||||
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
|
||||
var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
|
||||
let loss = 0;
|
||||
let data = [];
|
||||
let datal = [];
|
||||
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
|
||||
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
|
||||
if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
|
||||
data.push([monitorInfo.result[i].created_at[j], avgDelay]);
|
||||
}
|
||||
legendName = monitorInfo.result[i].monitor_name + " " + lossRate + "%";
|
||||
tLegendData.push(legendName);
|
||||
tSeries.push({
|
||||
else {
|
||||
loss += 1;
|
||||
datal.push([monitorInfo.result[i].created_at[j], maxPing]);
|
||||
}
|
||||
}
|
||||
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
|
||||
if (lossRate > 99) {
|
||||
datal = [];
|
||||
}
|
||||
legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
|
||||
tLegendData.push(legendName);
|
||||
tSeries.push({
|
||||
name: legendName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: data,
|
||||
markLine: {
|
||||
symbol: "none",
|
||||
symbolSize: 0,
|
||||
data: datal
|
||||
},
|
||||
markPoint: {
|
||||
data: [
|
||||
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
|
||||
{ type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
this.option.title.text = monitorInfo.result[0].server_name;
|
||||
this.option.series = tSeries;
|
||||
this.option.legend.data = tLegendData;
|
||||
myChart.clear();
|
||||
myChart.setOption(this.option);
|
||||
},
|
||||
resizeHandle() {
|
||||
myChart.resize();
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
});
|
||||
tSeries.push({
|
||||
name: legendName,
|
||||
type: 'bar',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: datal,
|
||||
itemStyle: { color: rgbaColorBar }
|
||||
});
|
||||
}
|
||||
this.option.title.text = monitorInfo.result[0].server_name;
|
||||
this.option.series = tSeries;
|
||||
this.option.legend.data = tLegendData;
|
||||
this.myChart.clear();
|
||||
this.myChart.setOption(this.option);
|
||||
},
|
||||
this.option.title.text = monitorInfo.result[0].server_name;
|
||||
this.option.series = tSeries;
|
||||
this.option.legend.data = tLegendData;
|
||||
this.myChart.clear();
|
||||
this.myChart.setOption(this.option);
|
||||
},
|
||||
isWindowsPlatform(str) {
|
||||
return str.includes('Windows')
|
||||
},
|
||||
renderChart() {
|
||||
this.myChart = echarts.init(this.$refs.chartDom);
|
||||
this.myChart.setOption(this.option);
|
||||
},
|
||||
resizeHandle () {
|
||||
this.myChart.resize();
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.myChart.dispose();
|
||||
this.myChart = null;
|
||||
},
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
<style>
|
||||
#network {
|
||||
width: calc(100vw - 6em);
|
||||
max-width: 1400px;
|
||||
margin: 1em auto;
|
||||
}
|
||||
|
||||
#monitor-info-container {
|
||||
margin: 0em auto;
|
||||
align-content: start;
|
||||
background-color: #F1F1F2;
|
||||
}
|
||||
|
||||
.server-info-container {
|
||||
font-size: .6em;
|
||||
width: fit-content;
|
||||
display: inline-block;
|
||||
}
|
||||
#network {
|
||||
display: grid;
|
||||
/*grid-template-columns: repeat(5, 1fr);*/
|
||||
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
|
||||
grid-gap: 1em;
|
||||
width: 100%;
|
||||
width: calc(100vw - 6em);
|
||||
max-width: 1400px;
|
||||
margin: 1em auto;
|
||||
align-content: start;
|
||||
}
|
||||
#monitor-info-container{
|
||||
margin: 0em auto;
|
||||
align-content: start;
|
||||
background-color: #F1F1F2;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
|
||||
+10
-11
@@ -7,20 +7,19 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/semantic.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/assets/font-logos.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/flag-icons.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/assets/font-logos.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lipis/[email protected]/css/flag-icons.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/semantic-ui-alerts.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/theme-default/css/main.css?v20240226">
|
||||
<script src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>
|
||||
<script src="https://unpkg.com/[email protected]/dist/semantic.min.js"></script>
|
||||
<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
|
||||
<script src="https://unpkg.com/[email protected]/dist/echarts.min.js"></script>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
|
||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
|
||||
<script src="/static/theme-default/js/mixin.js?v20240302"></script>
|
||||
</head>
|
||||
<body>
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
+515
-543
File diff suppressed because it is too large
Load Diff
-3
@@ -27,9 +27,6 @@
|
||||
<i :class="item.icon + ' icon'"></i>@#item.name#@
|
||||
<i class="check icon" v-if="preferredTemplate === item.key"></i>
|
||||
</a>
|
||||
<a v-if="defaultTemplate === 'custom'" @click="toggleTemplate('custom')" class="item">
|
||||
<i class="expand icon"></i>Custom
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
+21
-14
@@ -28,6 +28,9 @@
|
||||
const monitorInfo = JSON.parse('{{.MonitorInfos}}');
|
||||
const initData = JSON.parse('{{.Servers}}').servers;
|
||||
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
|
||||
if (MaxTCPPingValue == null) {
|
||||
MaxTCPPingValue = 1000;
|
||||
}
|
||||
new Vue({
|
||||
el: '#app',
|
||||
delimiters: ['@#', '#@'],
|
||||
@@ -183,6 +186,15 @@
|
||||
let tSeries = [];
|
||||
let tLegendData = [];
|
||||
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
|
||||
let maxPing = 0;
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
|
||||
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
|
||||
if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
|
||||
maxPing = avgDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
var lcolor = lcolors[i % lcolors.length];
|
||||
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
|
||||
@@ -197,15 +209,7 @@
|
||||
}
|
||||
else {
|
||||
loss += 1;
|
||||
datal.push({
|
||||
xAxis: monitorInfo.result[i].created_at[j],
|
||||
label: { show: false },
|
||||
emphasis: { disabled: true },
|
||||
lineStyle: {
|
||||
type: "solid",
|
||||
color: rgbaColorBar
|
||||
}
|
||||
});
|
||||
datal.push([monitorInfo.result[i].created_at[j], maxPing]);
|
||||
}
|
||||
}
|
||||
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
|
||||
@@ -220,11 +224,6 @@
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: data,
|
||||
markLine: {
|
||||
symbol: "none",
|
||||
symbolSize :0,
|
||||
data: datal
|
||||
},
|
||||
markPoint: {
|
||||
data: [
|
||||
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
|
||||
@@ -232,6 +231,14 @@
|
||||
]
|
||||
}
|
||||
});
|
||||
tSeries.push({
|
||||
name: legendName,
|
||||
type: 'bar',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: datal,
|
||||
itemStyle: { color: rgbaColorBar }
|
||||
});
|
||||
}
|
||||
this.option.title.text = monitorInfo.result[0].server_name;
|
||||
this.option.series = tSeries;
|
||||
|
||||
+21
-14
@@ -55,6 +55,9 @@
|
||||
const monitorInfo = JSON.parse('{{.MonitorInfos}}');
|
||||
const initData = JSON.parse('{{.Servers}}').servers;
|
||||
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
|
||||
if (MaxTCPPingValue == null) {
|
||||
MaxTCPPingValue = 1000;
|
||||
}
|
||||
new Vue({
|
||||
el: '#app',
|
||||
delimiters: ['@#', '#@'],
|
||||
@@ -206,6 +209,15 @@
|
||||
let tSeries = [];
|
||||
let tLegendData = [];
|
||||
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
|
||||
let maxPing = 0;
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
|
||||
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
|
||||
if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
|
||||
maxPing = avgDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
var lcolor = lcolors[i % lcolors.length];
|
||||
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
|
||||
@@ -220,15 +232,7 @@
|
||||
}
|
||||
else {
|
||||
loss += 1;
|
||||
datal.push({
|
||||
xAxis: monitorInfo.result[i].created_at[j],
|
||||
label: { show: false },
|
||||
emphasis: { disabled: true },
|
||||
lineStyle: {
|
||||
type: "solid",
|
||||
color: rgbaColorBar
|
||||
}
|
||||
});
|
||||
datal.push([monitorInfo.result[i].created_at[j], maxPing]);
|
||||
}
|
||||
}
|
||||
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
|
||||
@@ -243,11 +247,6 @@
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: data,
|
||||
markLine: {
|
||||
symbol: "none",
|
||||
symbolSize :0,
|
||||
data: datal
|
||||
},
|
||||
markPoint: {
|
||||
data: [
|
||||
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
|
||||
@@ -255,6 +254,14 @@
|
||||
]
|
||||
}
|
||||
});
|
||||
tSeries.push({
|
||||
name: legendName,
|
||||
type: 'bar',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: datal,
|
||||
itemStyle: { color: rgbaColorBar }
|
||||
});
|
||||
}
|
||||
this.option.title.text = monitorInfo.result[0].server_name;
|
||||
this.option.series = tSeries;
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
</p>
|
||||
</footer>
|
||||
<aside class="toolbox">
|
||||
<span v-if="page=='index' && countryMapChartData.length!=0" class="showMapChart">
|
||||
<i @click="showMapChart" data-toggle="modal" data-target="#mapChartBox" class="bi bi-geo-alt"></i>
|
||||
</span>
|
||||
<span class="toggleView">
|
||||
<i v-if="showGroup" @click="toggleView" class="show-nogroup bi bi-justify"></i>
|
||||
<i v-else @click="toggleView" class="show-group bi bi-view-stacked"></i>
|
||||
|
||||
@@ -39,11 +39,6 @@
|
||||
<i class="check icon" v-if="preferredTemplate === item.key"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="defaultTemplate === 'custom'">
|
||||
<a @click="toggleTemplate('custom')" class="item">
|
||||
<i class="expand icon" style="font-size:1em"></i>Custom
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
{{ end }}
|
||||
|
||||
+15
-23
@@ -6,22 +6,16 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/main.css?v20240225">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/dark.css">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/light.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/assets/font-logos.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lipis/[email protected]/css/flag-icons.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css">
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/main.css?v20240407">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/dark.css?v20240407">
|
||||
<link rel="stylesheet" href="/static/theme-server-status/css/light.css?v20240407">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/assets/font-logos.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/flag-icons.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/semantic.min.css">
|
||||
<script src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>
|
||||
<script src="https://unpkg.com/[email protected]/dist/js/bootstrap.min.js"></script>
|
||||
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
||||
<script src="https://unpkg.com/[email protected]/dist/echarts.min.js"></script>
|
||||
<script src="/static/theme-server-status/js/world.js?v20240613"></script>
|
||||
<script src="/static/theme-server-status/js/mixin.js?v20240302"></script>
|
||||
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="/static/theme-server-status/js/html5shiv.js"></script>
|
||||
@@ -30,13 +24,11 @@
|
||||
{{if ts .CustomCode}}
|
||||
{{.CustomCode|safe}}
|
||||
{{end}}
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
|
||||
<script src="/static/theme-server-status/js/mixin.js?v20240302"></script>
|
||||
</head>
|
||||
<body>
|
||||
{{end}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{end}}
|
||||
+7
-10
@@ -27,10 +27,10 @@
|
||||
</td>
|
||||
<td class="node-cell name center">@#node.name#@</td>
|
||||
<td class="node-cell os center">
|
||||
<i v-if='getFontLogoClass(node.host.Platform) == "" && node.online' class="fl-tux"></i>
|
||||
<i v-if='node.os == "darwin"' class="apple icon"></i>
|
||||
<i v-else-if='isWindowsPlatform(node.host.Platform)' class="windows icon"></i>
|
||||
<i v-else :class="'fl-' + getFontLogoClass(node.host.Platform)"></i>
|
||||
<span class="node-cell-os-text">@#getPlatformName(node.os)#@</span>
|
||||
<span class="node-cell-os-text">@#node.os#@</span>
|
||||
</td>
|
||||
<td style="text-align: center;" class="node-cell location">
|
||||
<i :class="'fi fi-' + node.location"></i>
|
||||
@@ -71,23 +71,20 @@
|
||||
</span>
|
||||
<span class="node-cell-expand" v-if="node.host.CPU">
|
||||
<span class="node-cell-expand-label">CPU:</span>
|
||||
@#node.host.CPU.join(",")#@ (@#node.cpu.percent#@%)
|
||||
@#node.host.CPU.join(",")#@
|
||||
</span>
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "DiskUsed"}}:</span>
|
||||
@#formatByteSize(node.state.DiskUsed)#@ / @#formatByteSize(node.host.DiskTotal)#@ (@#node.hdd.percent#@%)
|
||||
@#formatByteSize(node.state.DiskUsed)#@ / @#formatByteSize(node.host.DiskTotal)#@
|
||||
</span>
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "MemUsed"}}:</span>
|
||||
@#formatByteSize(node.state.MemUsed)#@ / @#formatByteSize(node.host.MemTotal)#@ (@#toFixed2(node.state.MemUsed / node.host.MemTotal * 100)#@%)
|
||||
@#formatByteSize(node.state.MemUsed)#@ / @#formatByteSize(node.host.MemTotal)#@(@#toFixed2(node.state.MemUsed / node.host.MemTotal * 100)#@%)
|
||||
</span>
|
||||
<span v-if="node.host.SwapTotal > 0" class="node-cell-expand">
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "SwapUsed"}}:</span>
|
||||
@#formatByteSize(node.state.SwapUsed)#@ / @#formatByteSize(node.host.SwapTotal)#@
|
||||
<span>(@#toFixed2(node.state.SwapUsed / node.host.SwapTotal * 100)#@%)</span>
|
||||
</span>
|
||||
<span v-else class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "SwapUsed"}}: OFF</span>
|
||||
<span v-if="node.host.SwapTotal">(@#toFixed2(node.state.SwapUsed / node.host.SwapTotal * 100)#@%)</span>
|
||||
</span>
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "NetTransfer"}}:</span>
|
||||
|
||||
+10
-9
@@ -30,10 +30,10 @@
|
||||
</td>
|
||||
<td class="node-cell name center">@#node.name#@</td>
|
||||
<td class="node-cell os center">
|
||||
<i v-if='getFontLogoClass(node.host.Platform) == "" && node.online' class="fl-tux"></i>
|
||||
<i v-if='node.os == "darwin"' class="apple icon"></i>
|
||||
<i v-else-if='isWindowsPlatform(node.host.Platform)' class="windows icon"></i>
|
||||
<i v-else :class="'fl-' + getFontLogoClass(node.host.Platform)"></i>
|
||||
<span class="node-cell-os-text">@#getPlatformName(node.os)#@</span>
|
||||
<span class="node-cell-os-text">@#node.os#@</span>
|
||||
</td>
|
||||
<td style="text-align: center;" class="node-cell location">
|
||||
<i :class="'fi fi-' + node.location"></i>
|
||||
@@ -74,19 +74,20 @@
|
||||
</span>
|
||||
<span class="node-cell-expand" v-if="node.host.CPU">
|
||||
<span class="node-cell-expand-label">CPU:</span>
|
||||
@#node.host.CPU.join(",")#@ (@#node.cpu.percent#@%)
|
||||
@#node.host.CPU.join(",")#@
|
||||
</span>
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "DiskUsed"}}:</span>
|
||||
@#formatByteSize(node.state.DiskUsed)#@ / @#formatByteSize(node.host.DiskTotal)#@ (@#node.hdd.percent#@%)
|
||||
@#formatByteSize(node.state.DiskUsed)#@ / @#formatByteSize(node.host.DiskTotal)#@
|
||||
</span>
|
||||
<span v-if="node.host.SwapTotal > 0" class="node-cell-expand">
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "MemUsed"}}:</span>
|
||||
@#formatByteSize(node.state.MemUsed)#@ / @#formatByteSize(node.host.MemTotal)#@(@#toFixed2(node.state.MemUsed / node.host.MemTotal * 100)#@%)
|
||||
</span>
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "SwapUsed"}}:</span>
|
||||
@#formatByteSize(node.state.SwapUsed)#@ / @#formatByteSize(node.host.SwapTotal)#@
|
||||
<span>(@#toFixed2(node.state.SwapUsed / node.host.SwapTotal * 100)#@%)</span>
|
||||
</span>
|
||||
<span v-else class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "SwapUsed"}}: OFF</span>
|
||||
<span v-if="node.host.SwapTotal">(@#toFixed2(node.state.SwapUsed / node.host.SwapTotal * 100)#@%)</span>
|
||||
</span>
|
||||
<span class="node-cell-expand">
|
||||
<span class="node-cell-expand-label">{{tr "NetTransfer"}}:</span>
|
||||
|
||||
+2
-153
File diff suppressed because one or more lines are too long
+21
-14
@@ -22,6 +22,9 @@
|
||||
const monitorInfo = JSON.parse('{{.MonitorInfos}}');
|
||||
const initData = JSON.parse('{{.Servers}}').servers;
|
||||
let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
|
||||
if (MaxTCPPingValue == null) {
|
||||
MaxTCPPingValue = 1000;
|
||||
}
|
||||
new Vue({
|
||||
el: '#app',
|
||||
delimiters: ['@#', '#@'],
|
||||
@@ -169,6 +172,15 @@
|
||||
let tSeries = [];
|
||||
let tLegendData = [];
|
||||
var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
|
||||
let maxPing = 0;
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
|
||||
avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
|
||||
if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
|
||||
maxPing = avgDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < monitorInfo.result.length; i++) {
|
||||
var lcolor = lcolors[i % lcolors.length];
|
||||
var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
|
||||
@@ -183,15 +195,7 @@
|
||||
}
|
||||
else {
|
||||
loss += 1;
|
||||
datal.push({
|
||||
xAxis: monitorInfo.result[i].created_at[j],
|
||||
label: { show: false },
|
||||
emphasis: { disabled: true },
|
||||
lineStyle: {
|
||||
type: "solid",
|
||||
color: rgbaColorBar
|
||||
}
|
||||
});
|
||||
datal.push([monitorInfo.result[i].created_at[j], maxPing]);
|
||||
}
|
||||
}
|
||||
lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
|
||||
@@ -206,11 +210,6 @@
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: data,
|
||||
markLine: {
|
||||
symbol: "none",
|
||||
symbolSize :0,
|
||||
data: datal
|
||||
},
|
||||
markPoint: {
|
||||
data: [
|
||||
{ type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
|
||||
@@ -218,6 +217,14 @@
|
||||
]
|
||||
}
|
||||
});
|
||||
tSeries.push({
|
||||
name: legendName,
|
||||
type: 'bar',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: datal,
|
||||
itemStyle: { color: rgbaColorBar }
|
||||
});
|
||||
}
|
||||
this.option.title.text = monitorInfo.result[0].server_name;
|
||||
this.option.series = tSeries;
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@
|
||||
const className = result.className;
|
||||
if (className === "good") {
|
||||
result.className = 'progress-bar progress-bar-success'
|
||||
} else if (className === "warning") {
|
||||
} else if (className === "waining") {
|
||||
result.className = 'progress-bar progress-bar-warning'
|
||||
} else if (className === "danger") {
|
||||
result.className = 'progress-bar progress-bar-danger'
|
||||
|
||||
+1
-10
@@ -14,7 +14,7 @@ site:
|
||||
theme: "default"
|
||||
ddns:
|
||||
enable: false
|
||||
provider: "webhook" # 如需使用多配置功能,请把此项留空
|
||||
provider: "webhook"
|
||||
accessid: ""
|
||||
accesssecret: ""
|
||||
webhookmethod: ""
|
||||
@@ -22,12 +22,3 @@ ddns:
|
||||
webhookrequestbody: ""
|
||||
webhookheaders: ""
|
||||
maxretries: 3
|
||||
profiles:
|
||||
example:
|
||||
provider: ""
|
||||
accessid: ""
|
||||
accesssecret: ""
|
||||
webhookmethod: ""
|
||||
webhookurl: ""
|
||||
webhookrequestbody: ""
|
||||
webhookheaders: ""
|
||||
@@ -1,291 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#========================================================
|
||||
# System Required: macOS 10.13+
|
||||
# Description: Nezha Agent Install Script (macOS)
|
||||
# Github: https://github.com/naiba/nezha
|
||||
#========================================================
|
||||
|
||||
NZ_BASE_PATH="/opt/nezha"
|
||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
yellow='\033[0;33m'
|
||||
plain='\033[0m'
|
||||
export PATH=$PATH:/usr/local/bin
|
||||
|
||||
pre_check() {
|
||||
# check root
|
||||
[[ $EUID -ne 0 ]] && echo -e "${red}ERROR: ${plain} This script must be run with the root user!\n" && exit 1
|
||||
|
||||
## os_arch
|
||||
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
|
||||
os_arch="amd64"
|
||||
elif [[ $(uname -m | grep 'arm64\|arm64e') != "" ]]; then
|
||||
os_arch="arm64"
|
||||
fi
|
||||
|
||||
## China_IP
|
||||
if [[ -z "${CN}" ]]; then
|
||||
if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||
echo "According to the information provided by ipapi.co, the current IP may be in China"
|
||||
read -e -r -p "Is the installation done with a Chinese Mirror? [Y/n] (Custom Mirror Input 3):" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Use Chinese Mirror"
|
||||
CN=true
|
||||
;;
|
||||
|
||||
[nN][oO] | [nN])
|
||||
echo "No Use Chinese Mirror"
|
||||
;;
|
||||
|
||||
[3])
|
||||
echo "Use Custom Mirror"
|
||||
read -e -r -p "Please enter a custom image (e.g. :dn-dao-github-mirror.daocloud.io), leave blank to nouse: " input
|
||||
case $input in
|
||||
*)
|
||||
CUSTOM_MIRROR=$input
|
||||
;;
|
||||
esac
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "No Use Chinese Mirror"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${CUSTOM_MIRROR}" ]]; then
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL=$CUSTOM_MIRROR
|
||||
else
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
|
||||
GITHUB_URL="github.com"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" "
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
else
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="github.com"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" -s docker --mirror Aliyun"
|
||||
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
before_show_menu() {
|
||||
echo && echo -n -e "${yellow}* Press Enter to return to the main menu *${plain}" && read temp
|
||||
show_menu
|
||||
}
|
||||
|
||||
install_agent() {
|
||||
echo -e "> Install Nezha Agent"
|
||||
|
||||
echo -e "Obtaining Agent version"
|
||||
|
||||
local version=$(curl -m 10 -sL "https://api.github.com/repos/nezhahq/agent/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
if [ ! -n "$version" ]; then
|
||||
version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
|
||||
fi
|
||||
if [ ! -n "$version" ]; then
|
||||
version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
|
||||
fi
|
||||
|
||||
if [ ! -n "$version" ]; then
|
||||
echo -e "Fail to obtaine agent version, please check if the network can link https://api.github.com/repos/nezhahq/agent/releases/latest"
|
||||
return 0
|
||||
else
|
||||
echo -e "The current latest version is: ${version}"
|
||||
fi
|
||||
|
||||
# Nezha Agent Folder
|
||||
mkdir -p $NZ_AGENT_PATH
|
||||
chmod -R 777 $NZ_AGENT_PATH
|
||||
|
||||
echo -e "Downloading Agent"
|
||||
curl -o nezha-agent_darwin_${os_arch}.zip -L -f --retry 2 --retry-max-time 60 https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_darwin_${os_arch}.zip >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Fail to download agent, please check if the network can link ${GITHUB_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
unzip -qo nezha-agent_darwin_${os_arch}.zip &&
|
||||
mv nezha-agent $NZ_AGENT_PATH &&
|
||||
rm -rf nezha-agent_darwin_${os_arch}.zip README.md
|
||||
|
||||
if [ $# -ge 3 ]; then
|
||||
modify_agent_config "$@"
|
||||
else
|
||||
modify_agent_config 0
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
modify_agent_config() {
|
||||
echo -e "> Modify Agent Configuration"
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Please add Agent in the admin panel first, record the secret" &&
|
||||
read -ep "Please enter a domain that resolves to the IP where the panel is located (no CDN sets): " nz_grpc_host &&
|
||||
read -ep "Please enter the panel RPC port (default 5555): " nz_grpc_port &&
|
||||
read -ep "Please enter the Agent secret: " nz_client_secret &&
|
||||
read -ep "Do you want to enable SSL/TLS encryption for the gRPC port (--tls)? Press [y] if yes, the default is not required, and users can press Enter to skip if you don't understand: " nz_grpc_proxy
|
||||
grep -qiw 'Y' <<<"${nz_grpc_proxy}" && args='--tls'
|
||||
if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then
|
||||
echo -e "${red}All options cannot be empty${plain}"
|
||||
before_show_menu
|
||||
return 1
|
||||
fi
|
||||
if [[ -z "${nz_grpc_port}" ]]; then
|
||||
nz_grpc_port=5555
|
||||
fi
|
||||
else
|
||||
nz_grpc_host=$1
|
||||
nz_grpc_port=$2
|
||||
nz_client_secret=$3
|
||||
shift 3
|
||||
if [ $# -gt 0 ]; then
|
||||
args=" $*"
|
||||
fi
|
||||
fi
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
${NZ_AGENT_PATH}/nezha-agent service uninstall >/dev/null 2>&1
|
||||
${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
echo -e "Agent configuration ${green} modified successfully, please wait for agent self-restart to take effect${plain}"
|
||||
|
||||
#if [[ $# == 0 ]]; then
|
||||
# before_show_menu
|
||||
#fi
|
||||
}
|
||||
|
||||
show_agent_log() {
|
||||
echo -e "> > View Agent Log"
|
||||
|
||||
tail -n 10 /var/log/nezha-agent.err.log
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_agent() {
|
||||
echo -e "> Uninstall Agent"
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service uninstall
|
||||
|
||||
rm -rf $NZ_AGENT_PATH
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
restart_agent() {
|
||||
echo -e "> Restart Agent"
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service restart
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
clean_all() {
|
||||
if [ -z "$(ls -A ${NZ_BASE_PATH})" ]; then
|
||||
rm -rf ${NZ_BASE_PATH}
|
||||
fi
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
echo "Nezha Agent Management Script Usage: "
|
||||
echo "--------------------------------------------------------"
|
||||
echo "./nezha.sh install_agent - Install Agent"
|
||||
echo "./nezha.sh modify_agent_config - Modify Agent Configuration"
|
||||
echo "./nezha.sh show_agent_log - View Agent Log"
|
||||
echo "./nezha.sh uninstall_agent - Uninstall Agent"
|
||||
echo "./nezha.sh restart_agent - Restart Agent"
|
||||
echo "./nezha.sh update_script - Update Script"
|
||||
echo "--------------------------------------------------------"
|
||||
}
|
||||
|
||||
show_menu() {
|
||||
echo -e "
|
||||
${green}Nezha Agent Management Script${plain} ${red}macOS${plain}
|
||||
--- https://github.com/naiba/nezha ---
|
||||
${green}1.${plain} Install Agent
|
||||
${green}2.${plain} Modify Agent Configuration
|
||||
${green}3.${plain} View Agent Log
|
||||
${green}4.${plain} Uninstall Agent
|
||||
${green}5.${plain} Restart Agent
|
||||
————————————————-
|
||||
${green}0.${plain} Exit Script
|
||||
"
|
||||
echo && read -ep "Please enter [0-5]: " num
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_agent
|
||||
;;
|
||||
2)
|
||||
modify_agent_config
|
||||
;;
|
||||
3)
|
||||
show_agent_log
|
||||
;;
|
||||
4)
|
||||
uninstall_agent
|
||||
;;
|
||||
5)
|
||||
restart_agent
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-5]${plain}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
pre_check
|
||||
|
||||
if [[ $# > 0 ]]; then
|
||||
case $1 in
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
else
|
||||
show_menu
|
||||
fi
|
||||
+25
-30
@@ -7,69 +7,64 @@ if($PSVersionTable.PSVersion.Major -lt 5){
|
||||
exit
|
||||
}
|
||||
$agentrepo = "nezhahq/agent"
|
||||
# x86 or x64 or arm64
|
||||
$nssmrepo = "nezhahq/nssm-backup"
|
||||
# x86 or x64
|
||||
if ([System.Environment]::Is64BitOperatingSystem) {
|
||||
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
|
||||
$file = "nezha-agent_windows_arm64.zip"
|
||||
} else {
|
||||
$file = "nezha-agent_windows_amd64.zip"
|
||||
}
|
||||
$file = "nezha-agent_windows_amd64.zip"
|
||||
}
|
||||
else {
|
||||
$file = "nezha-agent_windows_386.zip"
|
||||
}
|
||||
$agentreleases = "https://api.github.com/repos/$agentrepo/releases"
|
||||
$nssmreleases = "https://api.github.com/repos/$nssmrepo/releases"
|
||||
#重复运行自动更新
|
||||
if (Test-Path "C:\nezha\nezha-agent.exe") {
|
||||
if (Test-Path "C:\nezha") {
|
||||
Write-Host "Nezha monitoring already exists, delete and reinstall" -BackgroundColor DarkGreen -ForegroundColor White
|
||||
C:\nezha\nezha-agent.exe service uninstall
|
||||
C:/nezha/nssm.exe stop nezha
|
||||
C:/nezha/nssm.exe remove nezha
|
||||
Remove-Item "C:\nezha" -Recurse
|
||||
}
|
||||
#TLS/SSL
|
||||
Write-Host "Determining latest nezha release" -BackgroundColor DarkGreen -ForegroundColor White
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$agenttag = (Invoke-WebRequest -Uri $agentreleases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
|
||||
if ([string]::IsNullOrWhiteSpace($agenttag)) {
|
||||
$optionUrl = "https://fastly.jsdelivr.net/gh/nezhahq/agent/"
|
||||
Try {
|
||||
$response = Invoke-WebRequest -Uri $optionUrl -UseBasicParsing -TimeoutSec 10
|
||||
if ($response.StatusCode -eq 200) {
|
||||
$versiontext = $response.Content | findstr /c:"option.value"
|
||||
$version = [regex]::Match($versiontext, "@(\d+\.\d+\.\d+)").Groups[1].Value
|
||||
$agenttag = "v" + $version
|
||||
}
|
||||
} Catch {
|
||||
$optionUrl = "https://gcore.jsdelivr.net/gh/nezhahq/agent/"
|
||||
$response = Invoke-WebRequest -Uri $optionUrl -UseBasicParsing -TimeoutSec 10
|
||||
if ($response.StatusCode -eq 200) {
|
||||
$versiontext = $response.Content | findstr /c:"option.value"
|
||||
$version = [regex]::Match($versiontext, "@(\d+\.\d+\.\d+)").Groups[1].Value
|
||||
$agenttag = "v" + $version
|
||||
}
|
||||
}
|
||||
}
|
||||
$nssmtag = (Invoke-WebRequest -Uri $nssmreleases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
|
||||
#Region判断
|
||||
$ipapi= Invoke-RestMethod -Uri "https://api.myip.com/" -UserAgent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1"
|
||||
$region=$ipapi.cc
|
||||
echo $ipapi
|
||||
if($region -ne "CN"){
|
||||
$download = "https://github.com/$agentrepo/releases/download/$agenttag/$file"
|
||||
$nssmdownload="https://github.com/$nssmrepo/releases/download/$nssmtag/nssm.zip"
|
||||
Write-Host "Location:$region,connect directly!" -BackgroundColor DarkRed -ForegroundColor Green
|
||||
}else{
|
||||
$download = "https://github.com/$agentrepo/releases/download/$agenttag/$file"
|
||||
$download = "https://dn-dao-github-mirror.daocloud.io/$agentrepo/releases/download/$agenttag/$file"
|
||||
$nssmdownload="https://dn-dao-github-mirror.daocloud.io/$nssmrepo/releases/download/$nssmtag/nssm.zip"
|
||||
Write-Host "Location:CN,use mirror address" -BackgroundColor DarkRed -ForegroundColor Green
|
||||
}
|
||||
echo $download
|
||||
echo $nssmdownload
|
||||
Invoke-WebRequest $download -OutFile "C:\nezha.zip"
|
||||
#使用nssm安装服务
|
||||
Invoke-WebRequest $nssmdownload -OutFile "C:\nssm.zip"
|
||||
#解压
|
||||
Expand-Archive "C:\nezha.zip" -DestinationPath "C:\temp" -Force
|
||||
Expand-Archive "C:\nssm.zip" -DestinationPath "C:\temp" -Force
|
||||
if (!(Test-Path "C:\nezha")) { New-Item -Path "C:\nezha" -type directory }
|
||||
#整理文件
|
||||
Move-Item -Path "C:\temp\nezha-agent.exe" -Destination "C:\nezha\nezha-agent.exe"
|
||||
if ($file = "nezha-agent_windows_amd64.zip") {
|
||||
Move-Item -Path "C:\temp\nssm-2.24\win64\nssm.exe" -Destination "C:\nezha\nssm.exe"
|
||||
}
|
||||
else {
|
||||
Move-Item -Path "C:\temp\nssm-2.24\win32\nssm.exe" -Destination "C:\nezha\nssm.exe"
|
||||
}
|
||||
#清理垃圾
|
||||
Remove-Item "C:\nezha.zip"
|
||||
Remove-Item "C:\nssm.zip"
|
||||
Remove-Item "C:\temp" -Recurse
|
||||
#安装部分
|
||||
C:\nezha\nezha-agent.exe service install -s $server -p $key $tls
|
||||
C:\nezha\nssm.exe install nezha C:\nezha\nezha-agent.exe -s $server -p $key $tls -d
|
||||
C:\nezha\nssm.exe start nezha
|
||||
#enjoy
|
||||
Write-Host "Enjoy It!" -BackgroundColor DarkGreen -ForegroundColor Red
|
||||
Write-Host "Enjoy It!" -BackgroundColor DarkGreen -ForegroundColor Red
|
||||
|
||||
+468
-180
@@ -10,9 +10,11 @@
|
||||
NZ_BASE_PATH="/opt/nezha"
|
||||
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
|
||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
|
||||
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
|
||||
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
||||
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
||||
NZ_VERSION="v0.16.3"
|
||||
NZ_VERSION="v0.15.9"
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
@@ -92,70 +94,28 @@ pre_check() {
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
else
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="github.com"
|
||||
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" -s docker --mirror Aliyun"
|
||||
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
installation_check() {
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker compose"
|
||||
if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
FRESH_INSTALL=0
|
||||
return
|
||||
else
|
||||
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
|
||||
fi
|
||||
fi
|
||||
elif command -v docker-compose >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
FRESH_INSTALL=0
|
||||
return
|
||||
else
|
||||
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
|
||||
fi
|
||||
confirm() {
|
||||
if [[ $# > 1 ]]; then
|
||||
echo && read -e -p "$1 [默认$2]: " temp
|
||||
if [[ x"${temp}" == x"" ]]; then
|
||||
temp=$2
|
||||
fi
|
||||
else
|
||||
read -e -p "$1 [y/n]: " temp
|
||||
fi
|
||||
|
||||
if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
|
||||
IS_DOCKER_NEZHA=0
|
||||
FRESH_INSTALL=0
|
||||
fi
|
||||
}
|
||||
|
||||
select_version() {
|
||||
if [[ -z $IS_DOCKER_NEZHA ]]; then
|
||||
echo -e "${yellow}请自行选择您的安装方式(如果你是安装Agent,输入哪个都是一样的):\n1. Docker\n2. 独立安装${plain}"
|
||||
while true; do
|
||||
read -e -r -p "请输入选择 [1-2]:" option
|
||||
case "${option}" in
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
;;
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "${red}请输入正确的数字 [1-2]${plain}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -195,7 +155,7 @@ install_arch() {
|
||||
[yY][eE][sS] | [yY])
|
||||
useradd -m nezha-agent
|
||||
sed -i "$ a\nezha-agent ALL=(ALL ) NOPASSWD:ALL" /etc/sudoers
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys 4695881C254508D1;
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys BE22091E3EF62275;
|
||||
cd /tmp; git clone https://aur.archlinux.org/libsepol.git; cd libsepol; makepkg -si --noconfirm --asdeps; cd ..;
|
||||
git clone https://aur.archlinux.org/libselinux.git; cd libselinux; makepkg -si --noconfirm; cd ..;
|
||||
rm -rf libsepol libselinux'
|
||||
@@ -226,7 +186,7 @@ install_dashboard() {
|
||||
echo -e "> 安装面板"
|
||||
|
||||
# 哪吒监控文件夹
|
||||
if [[ ! $FRESH_INSTALL == 0 ]]; then
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/docker-compose.yaml" ]; then
|
||||
mkdir -p $NZ_DASHBOARD_PATH
|
||||
else
|
||||
echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。"
|
||||
@@ -248,10 +208,17 @@ install_dashboard() {
|
||||
|
||||
chmod 777 -R $NZ_DASHBOARD_PATH
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
install_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
install_dashboard_standalone
|
||||
command -v docker >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "正在安装 Docker"
|
||||
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载脚本失败,请检查本机能否连接 ${Get_Docker_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
systemctl enable docker.service
|
||||
systemctl start docker.service
|
||||
echo -e "${green}Docker${plain} 安装成功"
|
||||
fi
|
||||
|
||||
modify_dashboard_config 0
|
||||
@@ -261,34 +228,43 @@ install_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
install_dashboard_docker() {
|
||||
if [[ ! $FRESH_INSTALL == 0 ]]; then
|
||||
command -v docker >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "正在安装 Docker"
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载脚本失败,请检查本机能否连接 ${Get_Docker_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
systemctl enable docker.service
|
||||
systemctl start docker.service
|
||||
else
|
||||
apk add docker docker-compose >/dev/null 2>&1
|
||||
rc-update add docker
|
||||
rc-service docker start
|
||||
fi
|
||||
echo -e "${green}Docker${plain} 安装成功"
|
||||
installation_check
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
install_dashboard_standalone() {
|
||||
install_base
|
||||
|
||||
echo -e "> 安装面板"
|
||||
|
||||
# 哪吒监控文件夹
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/app" ]; then
|
||||
mkdir -p $NZ_DASHBOARD_PATH
|
||||
else
|
||||
echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。"
|
||||
read -e -r -p "是否退出安装? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "继续安装"
|
||||
;;
|
||||
*)
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then
|
||||
mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
chmod 777 -R $NZ_DASHBOARD_PATH
|
||||
|
||||
modify_dashboard_config_standalone 0
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
selinux() {
|
||||
@@ -333,7 +309,7 @@ install_agent() {
|
||||
chmod 777 -R $NZ_AGENT_PATH
|
||||
|
||||
echo -e "正在下载监控端"
|
||||
wget -t 2 -T 60 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||
wget -t 2 -T 10 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Release 下载失败,请检查本机能否连接 ${GITHUB_URL}${plain}"
|
||||
return 0
|
||||
@@ -357,6 +333,21 @@ install_agent() {
|
||||
modify_agent_config() {
|
||||
echo -e "> 修改Agent配置"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
wget -t 2 -T 10 -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
wget -t 2 -T 10 -O $NZ_AGENT_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-agent >/dev/null 2>&1
|
||||
chmod +x $NZ_AGENT_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Fail to download service, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "请先在管理面板上添加Agent,记录下密钥" &&
|
||||
read -ep "请输入一个解析到面板所在IP的域名(不可套CDN): " nz_grpc_host &&
|
||||
@@ -378,19 +369,33 @@ modify_agent_config() {
|
||||
nz_client_secret=$3
|
||||
shift 3
|
||||
if [ $# -gt 0 ]; then
|
||||
args="$*"
|
||||
args=" $*"
|
||||
fi
|
||||
fi
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
${NZ_AGENT_PATH}/nezha-agent service uninstall >/dev/null 2>&1
|
||||
${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICE}
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICE}
|
||||
sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICE}
|
||||
[ -n "${args}" ] && sed -i "/ExecStart/ s/$/ ${args}/" ${NZ_AGENT_SERVICE}
|
||||
else
|
||||
sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICERC}
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICERC}
|
||||
sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICERC}
|
||||
[ -n "${args}" ] && sed -i "/command_args/ s/\"$/ ${args}\"/" ${NZ_AGENT_SERVICERC}
|
||||
fi
|
||||
|
||||
|
||||
echo -e "Agent配置 ${green}修改成功,请稍等重启生效${plain}"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable nezha-agent
|
||||
systemctl restart nezha-agent
|
||||
else
|
||||
rc-update add nezha-agent
|
||||
rc-service nezha-agent restart
|
||||
fi
|
||||
|
||||
#if [[ $# == 0 ]]; then
|
||||
# before_show_menu
|
||||
#fi
|
||||
@@ -399,16 +404,14 @@ modify_agent_config() {
|
||||
modify_dashboard_config() {
|
||||
echo -e "> 修改面板配置"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
echo -e "正在下载 Docker 脚本"
|
||||
wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
echo -e "正在下载 Docker 脚本"
|
||||
wget -t 2 -T 10 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
@@ -447,37 +450,88 @@ modify_dashboard_config() {
|
||||
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
|
||||
fi
|
||||
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
|
||||
|
||||
mkdir -p $NZ_DASHBOARD_PATH/data
|
||||
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
|
||||
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
|
||||
|
||||
echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}"
|
||||
|
||||
restart_and_update
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
modify_dashboard_config_standalone() {
|
||||
echo -e "> 修改面板配置"
|
||||
|
||||
echo -e "正在下载配置模板"
|
||||
|
||||
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载文件失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
echo -e "正在下载服务文件"
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
|
||||
else
|
||||
wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
|
||||
chmod +x $NZ_DASHBOARD_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
echo "关于 GitHub Oauth2 应用:在 https://github.com/settings/developers 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
|
||||
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
|
||||
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
|
||||
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
|
||||
read -ep "请输入站点标题: " nz_site_title &&
|
||||
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
|
||||
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
|
||||
|
||||
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
|
||||
echo -e "${red}所有选项都不能为空${plain}"
|
||||
before_show_menu
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "${nz_site_port}" ]]; then
|
||||
nz_site_port=8008
|
||||
fi
|
||||
if [[ -z "${nz_grpc_port}" ]]; then
|
||||
nz_grpc_port=5555
|
||||
fi
|
||||
if [[ -z "${nz_oauth2_type}" ]]; then
|
||||
nz_oauth2_type=github
|
||||
fi
|
||||
|
||||
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
|
||||
|
||||
mkdir -p $NZ_DASHBOARD_PATH/data
|
||||
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||
|
||||
echo -e "正在下载服务文件"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
|
||||
else
|
||||
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
|
||||
chmod +x $NZ_DASHBOARD_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}"
|
||||
|
||||
restart_and_update
|
||||
restart_and_update_standalone
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
@@ -489,10 +543,15 @@ restart_and_update() {
|
||||
|
||||
cd $NZ_DASHBOARD_PATH
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
restart_and_update_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
restart_and_update_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
docker compose pull
|
||||
docker compose down
|
||||
docker compose up -d
|
||||
else
|
||||
docker-compose pull
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -507,13 +566,11 @@ restart_and_update() {
|
||||
fi
|
||||
}
|
||||
|
||||
restart_and_update_docker() {
|
||||
$DOCKER_COMPOSE_COMMAND pull
|
||||
$DOCKER_COMPOSE_COMMAND down
|
||||
$DOCKER_COMPOSE_COMMAND up -d
|
||||
}
|
||||
|
||||
restart_and_update_standalone() {
|
||||
echo -e "> 重启并更新面板"
|
||||
|
||||
cd $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl stop nezha-dashboard
|
||||
else
|
||||
@@ -530,15 +587,27 @@ restart_and_update_standalone() {
|
||||
rc-update add nezha-dashboard
|
||||
rc-service nezha-dashboard restart
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}哪吒监控 重启成功${plain}"
|
||||
echo -e "默认管理面板地址:${yellow}域名:站点访问端口${plain}"
|
||||
else
|
||||
echo -e "${red}重启失败,可能是因为启动时间超过了两秒,请稍后查看日志信息${plain}"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
start_dashboard() {
|
||||
echo -e "> 启动面板"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
start_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
start_dashboard_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose up -d
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose up -d
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -552,25 +621,34 @@ start_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
start_dashboard_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND up -d
|
||||
}
|
||||
|
||||
start_dashboard_standalone() {
|
||||
echo -e "> 启动面板"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl start nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard start
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}哪吒监控 启动成功${plain}"
|
||||
else
|
||||
echo -e "${red}启动失败,请稍后查看日志信息${plain}"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
stop_dashboard() {
|
||||
echo -e "> 停止面板"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
stop_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
stop_dashboard_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose down
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose down
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -584,25 +662,19 @@ stop_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
stop_dashboard_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
|
||||
}
|
||||
|
||||
stop_dashboard_standalone() {
|
||||
echo -e "> 停止面板"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl stop nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard stop
|
||||
fi
|
||||
}
|
||||
|
||||
show_dashboard_log() {
|
||||
echo -e "> 获取面板日志"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
show_dashboard_log_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
show_dashboard_log_standalone
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}哪吒监控 停止成功${plain}"
|
||||
else
|
||||
echo -e "${red}停止失败,请稍后查看日志信息${plain}"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -610,27 +682,48 @@ show_dashboard_log() {
|
||||
fi
|
||||
}
|
||||
|
||||
show_dashboard_log_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND logs -f
|
||||
show_dashboard_log() {
|
||||
echo -e "> 获取面板日志"
|
||||
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose logs -f
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose logs -f
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
show_dashboard_log_standalone() {
|
||||
echo -e "> 获取面板日志"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
journalctl -xf -u nezha-dashboard.service
|
||||
else
|
||||
tail -n 10 /var/log/nezha-dashboard.err
|
||||
echo "很抱歉,OpenRC 无此功能"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_dashboard() {
|
||||
echo -e "> 卸载管理面板"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
uninstall_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
uninstall_dashboard_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose down
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose down
|
||||
fi
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
|
||||
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -638,14 +731,9 @@ uninstall_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_dashboard_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
|
||||
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
|
||||
}
|
||||
|
||||
uninstall_dashboard_standalone() {
|
||||
echo -e "> 卸载管理面板"
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
@@ -659,6 +747,12 @@ uninstall_dashboard_standalone() {
|
||||
else
|
||||
rm $NZ_DASHBOARD_SERVICERC
|
||||
fi
|
||||
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
show_agent_log() {
|
||||
@@ -667,7 +761,7 @@ show_agent_log() {
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
journalctl -xf -u nezha-agent.service
|
||||
else
|
||||
tail -n 10 /var/log/nezha-agent.err
|
||||
echo "很抱歉,OpenRC 无此功能"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -678,7 +772,16 @@ show_agent_log() {
|
||||
uninstall_agent() {
|
||||
echo -e "> 卸载Agent"
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service uninstall
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl disable nezha-agent.service
|
||||
systemctl stop nezha-agent.service
|
||||
rm -rf $NZ_AGENT_SERVICE
|
||||
systemctl daemon-reload
|
||||
else
|
||||
rc-update del nezha-agent
|
||||
rc-service nezha-agent stop
|
||||
rm -rf $NZ_AGENT_SERVICERC
|
||||
fi
|
||||
|
||||
rm -rf $NZ_AGENT_PATH
|
||||
clean_all
|
||||
@@ -691,7 +794,11 @@ uninstall_agent() {
|
||||
restart_agent() {
|
||||
echo -e "> 重启Agent"
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service restart
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl restart nezha-agent.service
|
||||
else
|
||||
rc-service nezha-agent restart
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
@@ -704,6 +811,59 @@ clean_all() {
|
||||
fi
|
||||
}
|
||||
|
||||
select_version() {
|
||||
DOCKER_COMPOSE_COMMAND=""
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker compose"
|
||||
if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
return
|
||||
else
|
||||
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
|
||||
fi
|
||||
fi
|
||||
elif command -v docker-compose >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "存在带有 nezha-dashboard 仓库的 Docker 镜像:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
return
|
||||
else
|
||||
echo "未找到带有 nezha-dashboard 仓库的 Docker 镜像。"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
|
||||
IS_DOCKER_NEZHA=0
|
||||
else
|
||||
echo -e "${yellow}请自行选择您的安装方式(如果你是安装Agent,输入哪个都是一样的):\n1. Docker\n2. 独立安装${plain}"
|
||||
while true; do
|
||||
read -e -r -p "请输入数字 [1-2]:" option
|
||||
case "${option}" in
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
;;
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "输入有误,请重新输入"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
echo "哪吒监控 管理脚本使用方法: "
|
||||
echo "--------------------------------------------------------"
|
||||
@@ -748,7 +908,8 @@ show_menu() {
|
||||
${green}0.${plain} 退出脚本
|
||||
"
|
||||
echo && read -ep "请输入选择 [0-13]: " num
|
||||
case "${num}" in
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
@@ -794,14 +955,65 @@ show_menu() {
|
||||
*)
|
||||
echo -e "${red}请输入正确的数字 [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_dashboard_standalone
|
||||
;;
|
||||
2)
|
||||
modify_dashboard_config_standalone
|
||||
;;
|
||||
3)
|
||||
start_dashboard_standalone
|
||||
;;
|
||||
4)
|
||||
stop_dashboard_standalone
|
||||
;;
|
||||
5)
|
||||
restart_and_update_standalone
|
||||
;;
|
||||
6)
|
||||
show_dashboard_log_standalone
|
||||
;;
|
||||
7)
|
||||
uninstall_dashboard_standalone
|
||||
;;
|
||||
8)
|
||||
install_agent
|
||||
;;
|
||||
9)
|
||||
modify_agent_config
|
||||
;;
|
||||
10)
|
||||
show_agent_log
|
||||
;;
|
||||
11)
|
||||
uninstall_agent
|
||||
;;
|
||||
12)
|
||||
restart_agent
|
||||
;;
|
||||
13)
|
||||
update_script
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}请输入正确的数字 [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
select_version
|
||||
fi
|
||||
}
|
||||
|
||||
pre_check
|
||||
installation_check
|
||||
|
||||
if [[ $# > 0 ]]; then
|
||||
case $1 in
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard 0
|
||||
;;
|
||||
@@ -847,8 +1059,84 @@ if [[ $# > 0 ]]; then
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard_standalone 0
|
||||
;;
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config_standalone 0
|
||||
;;
|
||||
"start_dashboard")
|
||||
start_dashboard_standalone 0
|
||||
;;
|
||||
"stop_dashboard")
|
||||
stop_dashboard_standalone 0
|
||||
;;
|
||||
"restart_and_update")
|
||||
restart_and_update_standalone 0
|
||||
;;
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log_standalone 0
|
||||
;;
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard_standalone 0
|
||||
;;
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
select_version
|
||||
show_menu
|
||||
fi
|
||||
fi
|
||||
|
||||
+465
-178
@@ -10,9 +10,11 @@
|
||||
NZ_BASE_PATH="/opt/nezha"
|
||||
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
|
||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
|
||||
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
|
||||
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
||||
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
||||
NZ_VERSION="v0.16.3"
|
||||
NZ_VERSION="v0.15.9"
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
@@ -91,7 +93,7 @@ pre_check() {
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
else
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="github.com"
|
||||
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" -s docker --mirror Aliyun"
|
||||
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
|
||||
@@ -99,60 +101,19 @@ pre_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
installation_check() {
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker compose"
|
||||
if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "Docker image with nezha-dashboard repository exists:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
return
|
||||
else
|
||||
echo "No Docker images with the nezha-dashboard repository were found."
|
||||
fi
|
||||
fi
|
||||
elif command -v docker-compose >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "Docker image with nezha-dashboard repository exists:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
return
|
||||
else
|
||||
echo "No Docker images with the nezha-dashboard repository were found."
|
||||
fi
|
||||
confirm() {
|
||||
if [[ $# > 1 ]]; then
|
||||
echo && read -e -p "$1 [默认$2]: " temp
|
||||
if [[ x"${temp}" == x"" ]]; then
|
||||
temp=$2
|
||||
fi
|
||||
else
|
||||
read -e -p "$1 [y/n]: " temp
|
||||
fi
|
||||
|
||||
if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
|
||||
IS_DOCKER_NEZHA=0
|
||||
FRESH_INSTALL=0
|
||||
fi
|
||||
}
|
||||
|
||||
select_version() {
|
||||
if [[ -z $IS_DOCKER_NEZHA ]]; then
|
||||
echo -e "${yellow}Select your installation method(Input anything is ok if you are installing agent):\n1. Docker\n2. Standalone${plain}"
|
||||
while true; do
|
||||
read -e -r -p "Please enter [1-2]: " option
|
||||
case "${option}" in
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
;;
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "${red}Please enter the correct number [1-2]${plain}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -182,7 +143,7 @@ before_show_menu() {
|
||||
|
||||
install_base() {
|
||||
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 && command -v getenforce >/dev/null 2>&1) ||
|
||||
(install_soft curl wget git unzip)
|
||||
(install_soft curl wget git unzip tzdata)
|
||||
}
|
||||
|
||||
install_arch() {
|
||||
@@ -192,7 +153,7 @@ install_arch() {
|
||||
[yY][eE][sS] | [yY])
|
||||
useradd -m nezha-agent
|
||||
sed -i "$ a\nezha-agent ALL=(ALL ) NOPASSWD:ALL" /etc/sudoers
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys 4695881C254508D1;
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys BE22091E3EF62275;
|
||||
cd /tmp; git clone https://aur.archlinux.org/libsepol.git; cd libsepol; makepkg -si --noconfirm --asdeps; cd ..;
|
||||
git clone https://aur.archlinux.org/libselinux.git; cd libselinux; makepkg -si --noconfirm; cd ..;
|
||||
rm -rf libsepol libselinux'
|
||||
@@ -223,7 +184,7 @@ install_dashboard() {
|
||||
echo -e "> Install Panel"
|
||||
|
||||
# Nezha Monitoring Folder
|
||||
if [[ ! $FRESH_INSTALL == 0 ]]; then
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/docker-compose.yaml" ]; then
|
||||
mkdir -p $NZ_DASHBOARD_PATH
|
||||
else
|
||||
echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup."
|
||||
@@ -244,10 +205,17 @@ install_dashboard() {
|
||||
fi
|
||||
chmod 777 -R $NZ_DASHBOARD_PATH
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
install_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
install_dashboard_standalone
|
||||
command -v docker >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "Installing Docker"
|
||||
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Script failed to get, please check if the network can link ${Get_Docker_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
systemctl enable docker.service
|
||||
systemctl start docker.service
|
||||
echo -e "${green}Docker${plain} installed successfully"
|
||||
fi
|
||||
|
||||
modify_dashboard_config 0
|
||||
@@ -257,34 +225,43 @@ install_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
install_dashboard_docker() {
|
||||
if [[ ! $FRESH_INSTALL == 0 ]]; then
|
||||
command -v docker >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "Installing Docker"
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Script failed to get, please check if the network can link ${Get_Docker_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
systemctl enable docker.service
|
||||
systemctl start docker.service
|
||||
else
|
||||
apk add docker docker-compose >/dev/null 2>&1
|
||||
rc-update add docker
|
||||
rc-service docker start
|
||||
fi
|
||||
echo -e "${green}Docker${plain} installed successfully"
|
||||
installation_check
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
install_dashboard_standalone() {
|
||||
install_base
|
||||
|
||||
echo -e "> Install Panel"
|
||||
|
||||
# Nezha Monitoring Folder
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/app" ]; then
|
||||
mkdir -p $NZ_DASHBOARD_PATH
|
||||
else
|
||||
echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup."
|
||||
read -e -r -p "Exit the installation? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "Continue."
|
||||
;;
|
||||
*)
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then
|
||||
mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
chmod 777 -R $NZ_DASHBOARD_PATH
|
||||
|
||||
modify_dashboard_config_standalone 0
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
selinux() {
|
||||
@@ -329,7 +306,7 @@ install_agent() {
|
||||
chmod 777 -R $NZ_AGENT_PATH
|
||||
|
||||
echo -e "Downloading Agent"
|
||||
wget -t 2 -T 60 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||
wget -t 2 -T 10 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Fail to download agent, please check if the network can link ${GITHUB_URL}${plain}"
|
||||
return 0
|
||||
@@ -353,6 +330,21 @@ install_agent() {
|
||||
modify_agent_config() {
|
||||
echo -e "> Modify Agent Configuration"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
wget -t 2 -T 10 -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Fail to download service, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
wget -t 2 -T 10 -O $NZ_AGENT_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-agent >/dev/null 2>&1
|
||||
chmod +x $NZ_AGENT_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Fail to download service, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Please add Agent in the admin panel first, record the secret" &&
|
||||
read -ep "Please enter a domain that resolves to the IP where the panel is located (no CDN sets): " nz_grpc_host &&
|
||||
@@ -374,19 +366,33 @@ modify_agent_config() {
|
||||
nz_client_secret=$3
|
||||
shift 3
|
||||
if [ $# -gt 0 ]; then
|
||||
args="$*"
|
||||
args=" $*"
|
||||
fi
|
||||
fi
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
${NZ_AGENT_PATH}/nezha-agent service uninstall >/dev/null 2>&1
|
||||
${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICE}
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICE}
|
||||
sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICE}
|
||||
[ -n "${args}" ] && sed -i "/ExecStart/ s/$/ ${args}/" ${NZ_AGENT_SERVICE}
|
||||
else
|
||||
sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICERC}
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICERC}
|
||||
sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICERC}
|
||||
[ -n "${args}" ] && sed -i "/command_args/ s/\"$/ ${args}\"/" ${NZ_AGENT_SERVICERC}
|
||||
fi
|
||||
|
||||
echo -e "Agent configuration ${green} modified successfully, please wait for agent self-restart to take effect${plain}"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable nezha-agent
|
||||
systemctl restart nezha-agent
|
||||
else
|
||||
rc-update add nezha-agent
|
||||
rc-service nezha-agent restart
|
||||
fi
|
||||
|
||||
#if [[ $# == 0 ]]; then
|
||||
# before_show_menu
|
||||
#fi
|
||||
@@ -395,16 +401,14 @@ modify_agent_config() {
|
||||
modify_dashboard_config() {
|
||||
echo -e "> Modify Panel Configuration"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
echo -e "Download Docker Script"
|
||||
wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Script failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
echo -e "Download Docker Script"
|
||||
wget -t 2 -T 10 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Script failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Script failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
@@ -443,37 +447,88 @@ modify_dashboard_config() {
|
||||
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_language/en-US/" /tmp/nezha-config.yaml
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
|
||||
fi
|
||||
sed -i "s/nz_site_port/${nz_site_port}/" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/g" /tmp/nezha-docker-compose.yaml
|
||||
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
|
||||
|
||||
mkdir -p $NZ_DASHBOARD_PATH/data
|
||||
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
|
||||
mv -f /tmp/nezha-docker-compose.yaml ${NZ_DASHBOARD_PATH}/docker-compose.yaml
|
||||
|
||||
echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
|
||||
|
||||
restart_and_update
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
modify_dashboard_config_standalone() {
|
||||
echo -e "> Modify Panel Configuration"
|
||||
|
||||
echo -e "Download configuration template"
|
||||
|
||||
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
echo -e "Downloading service file"
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
|
||||
else
|
||||
wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
|
||||
chmod +x $NZ_DASHBOARD_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
echo "About the GitHub Oauth2 application: create it at https://github.com/settings/developers, no review required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
echo "(Not recommended) About the Gitee Oauth2 application: create it at https://gitee.com/oauth/applications, no auditing required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
read -ep "Please enter the OAuth2 provider (github/gitlab/jihulab/gitee, default github): " nz_oauth2_type &&
|
||||
read -ep "Please enter the Client ID of the Oauth2 application: " nz_github_oauth_client_id &&
|
||||
read -ep "Please enter the Client Secret of the Oauth2 application: " nz_github_oauth_client_secret &&
|
||||
read -ep "Please enter your GitHub/Gitee login name as the administrator, separated by commas: " nz_admin_logins &&
|
||||
read -ep "Please enter the site title: " nz_site_title &&
|
||||
read -ep "Please enter the site access port: (default 8008)" nz_site_port &&
|
||||
read -ep "Please enter the RPC port to be used for Agent access: (default 5555)" nz_grpc_port
|
||||
|
||||
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
|
||||
echo -e "${red}All options cannot be empty${plain}"
|
||||
before_show_menu
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "${nz_site_port}" ]]; then
|
||||
nz_site_port=8008
|
||||
fi
|
||||
if [[ -z "${nz_grpc_port}" ]]; then
|
||||
nz_grpc_port=5555
|
||||
fi
|
||||
if [[ -z "${nz_oauth2_type}" ]]; then
|
||||
nz_oauth2_type=github
|
||||
fi
|
||||
|
||||
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
|
||||
|
||||
mkdir -p $NZ_DASHBOARD_PATH/data
|
||||
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||
|
||||
echo -e "Downloading service file"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
|
||||
else
|
||||
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
|
||||
chmod +x $NZ_DASHBOARD_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
|
||||
|
||||
restart_and_update
|
||||
restart_and_update_standalone
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
@@ -485,10 +540,15 @@ restart_and_update() {
|
||||
|
||||
cd $NZ_DASHBOARD_PATH
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
restart_and_update_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
restart_and_update_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
docker compose pull
|
||||
docker compose down
|
||||
docker compose up -d
|
||||
else
|
||||
docker-compose pull
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -503,13 +563,11 @@ restart_and_update() {
|
||||
fi
|
||||
}
|
||||
|
||||
restart_and_update_docker() {
|
||||
$DOCKER_COMPOSE_COMMAND pull
|
||||
$DOCKER_COMPOSE_COMMAND down
|
||||
$DOCKER_COMPOSE_COMMAND up -d
|
||||
}
|
||||
|
||||
restart_and_update_standalone() {
|
||||
echo -e "> Restart and Update the Panel"
|
||||
|
||||
cd $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl stop nezha-dashboard
|
||||
else
|
||||
@@ -526,15 +584,27 @@ restart_and_update_standalone() {
|
||||
rc-update add nezha-dashboard
|
||||
rc-service nezha-dashboard restart
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}Nezha Monitoring Restart Successful${plain}"
|
||||
echo -e "Default panel address: ${yellow}domain:Site_access_port${plain}"
|
||||
else
|
||||
echo -e "${red}The restart failed, probably because the boot time exceeded two seconds, please check the log information later${plain}"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
start_dashboard() {
|
||||
echo -e "> Start Panel"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
start_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
start_dashboard_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose up -d
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose up -d
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -548,25 +618,34 @@ start_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
start_dashboard_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND up -d
|
||||
}
|
||||
|
||||
start_dashboard_standalone() {
|
||||
echo -e "> Start Panel"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl start nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard start
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}Nezha Monitoring Start Successful${plain}"
|
||||
else
|
||||
echo -e "${red}Failed to start, please check the log message later${plain}"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
stop_dashboard() {
|
||||
echo -e "> Stop Panel"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
stop_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
stop_dashboard_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose down
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose down
|
||||
fi
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -580,25 +659,19 @@ stop_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
stop_dashboard_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
|
||||
}
|
||||
|
||||
stop_dashboard_standalone() {
|
||||
echo -e "> Stop Panel"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl stop nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard stop
|
||||
fi
|
||||
}
|
||||
|
||||
show_dashboard_log() {
|
||||
echo -e "> View Panel Log"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
show_dashboard_log_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
show_dashboard_log_standalone
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}Nezha Monitoring Stop Successful${plain}"
|
||||
else
|
||||
echo -e "${red}Failed to stop, please check the log message later${plain}"
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -606,27 +679,48 @@ show_dashboard_log() {
|
||||
fi
|
||||
}
|
||||
|
||||
show_dashboard_log_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND logs -f
|
||||
show_dashboard_log() {
|
||||
echo -e "> View Panel Log"
|
||||
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose logs -f
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose logs -f
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
show_dashboard_log_standalone() {
|
||||
echo -e "> View Panel Log"
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
journalctl -xf -u nezha-dashboard.service
|
||||
else
|
||||
tail -n 10 /var/log/nezha-dashboard.err
|
||||
echo "Sorry, OpenRC do not have this feature yet."
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_dashboard() {
|
||||
echo -e "> Uninstall Panel"
|
||||
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
uninstall_dashboard_docker
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
uninstall_dashboard_standalone
|
||||
docker compose version
|
||||
if [[ $? == 0 ]]; then
|
||||
cd $NZ_DASHBOARD_PATH && docker compose down
|
||||
else
|
||||
cd $NZ_DASHBOARD_PATH && docker-compose down
|
||||
fi
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
|
||||
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -634,14 +728,9 @@ uninstall_dashboard() {
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_dashboard_docker() {
|
||||
cd $NZ_DASHBOARD_PATH && $DOCKER_COMPOSE_COMMAND down
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
|
||||
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
|
||||
}
|
||||
|
||||
uninstall_dashboard_standalone() {
|
||||
echo -e "> Uninstall Panel"
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
@@ -655,6 +744,12 @@ uninstall_dashboard_standalone() {
|
||||
else
|
||||
rm $NZ_DASHBOARD_SERVICERC
|
||||
fi
|
||||
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
show_agent_log() {
|
||||
@@ -663,7 +758,7 @@ show_agent_log() {
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
journalctl -xf -u nezha-agent.service
|
||||
else
|
||||
tail -n 10 /var/log/nezha-agent.err
|
||||
echo "Sorry, OpenRC do not have this feature yet."
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -674,7 +769,16 @@ show_agent_log() {
|
||||
uninstall_agent() {
|
||||
echo -e "> Uninstall Agent"
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service uninstall
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl disable nezha-agent.service
|
||||
systemctl stop nezha-agent.service
|
||||
rm -rf $NZ_AGENT_SERVICE
|
||||
systemctl daemon-reload
|
||||
else
|
||||
rc-update del nezha-agent
|
||||
rc-service nezha-agent stop
|
||||
rm -rf $NZ_AGENT_SERVICERC
|
||||
fi
|
||||
|
||||
rm -rf $NZ_AGENT_PATH
|
||||
clean_all
|
||||
@@ -687,7 +791,11 @@ uninstall_agent() {
|
||||
restart_agent() {
|
||||
echo -e "> Restart Agent"
|
||||
|
||||
${NZ_AGENT_PATH}/nezha-agent service restart
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl restart nezha-agent.service
|
||||
else
|
||||
rc-service nezha-agent restart
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
@@ -700,6 +808,59 @@ clean_all() {
|
||||
fi
|
||||
}
|
||||
|
||||
select_version() {
|
||||
DOCKER_COMPOSE_COMMAND=""
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker compose"
|
||||
if $DOCKER_COMPOSE_COMMAND ls | grep -qw "$NZ_DASHBOARD_PATH/docker-compose.yaml" >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "Docker image with nezha-dashboard repository exists:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
return
|
||||
else
|
||||
echo "No Docker images with the nezha-dashboard repository were found."
|
||||
fi
|
||||
fi
|
||||
elif command -v docker-compose >/dev/null 2>&1; then
|
||||
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||
if $DOCKER_COMPOSE_COMMAND -f "$NZ_DASHBOARD_PATH/docker-compose.yaml" config >/dev/null 2>&1; then
|
||||
NEZHA_IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -w "nezha-dashboard")
|
||||
if [ -n "$NEZHA_IMAGES" ]; then
|
||||
echo "Docker image with nezha-dashboard repository exists:"
|
||||
echo "$NEZHA_IMAGES"
|
||||
IS_DOCKER_NEZHA=1
|
||||
return
|
||||
else
|
||||
echo "No Docker images with the nezha-dashboard repository were found."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f $NZ_DASHBOARD_PATH/app ]]; then
|
||||
IS_DOCKER_NEZHA=0
|
||||
else
|
||||
echo -e "${yellow}Select your installation method(Input anything is ok if you are installing agent):\n1. Docker\n2. Standalone${plain}"
|
||||
while true; do
|
||||
read -e -r -p "Input a number [1-2]: " option
|
||||
case "${option}" in
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
;;
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Wrong input, try again"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
echo "Nezha Monitor Management Script Usage: "
|
||||
echo "--------------------------------------------------------"
|
||||
@@ -744,7 +905,8 @@ show_menu() {
|
||||
${green}0.${plain} Exit Script
|
||||
"
|
||||
echo && read -ep "Please enter [0-13]: " num
|
||||
case "${num}" in
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
@@ -790,14 +952,63 @@ show_menu() {
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_dashboard_standalone
|
||||
;;
|
||||
2)
|
||||
modify_dashboard_config_standalone
|
||||
;;
|
||||
3)
|
||||
start_dashboard_standalone
|
||||
;;
|
||||
4)
|
||||
stop_dashboard_standalone
|
||||
;;
|
||||
5)
|
||||
restart_and_update_standalone
|
||||
;;
|
||||
6)
|
||||
show_dashboard_log_standalone
|
||||
;;
|
||||
7)
|
||||
uninstall_dashboard_standalone
|
||||
;;
|
||||
8)
|
||||
install_agent
|
||||
;;
|
||||
9)
|
||||
modify_agent_config
|
||||
;;
|
||||
10)
|
||||
show_agent_log
|
||||
;;
|
||||
11)
|
||||
uninstall_agent
|
||||
;;
|
||||
12)
|
||||
restart_agent
|
||||
;;
|
||||
13)
|
||||
update_script
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
pre_check
|
||||
installation_check
|
||||
|
||||
if [[ $# > 0 ]]; then
|
||||
case $1 in
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard 0
|
||||
;;
|
||||
@@ -843,8 +1054,84 @@ if [[ $# > 0 ]]; then
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard_standalone 0
|
||||
;;
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config_standalone 0
|
||||
;;
|
||||
"start_dashboard")
|
||||
start_dashboard_standalone 0
|
||||
;;
|
||||
"stop_dashboard")
|
||||
stop_dashboard_standalone 0
|
||||
;;
|
||||
"restart_and_update")
|
||||
restart_and_update_standalone 0
|
||||
;;
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log_standalone 0
|
||||
;;
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard_standalone 0
|
||||
;;
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
select_version
|
||||
show_menu
|
||||
fi
|
||||
fi
|
||||
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/sbin/openrc-run
|
||||
supervisor=supervise-daemon
|
||||
name=nezha-agent
|
||||
supervise_daemon_args="--stdout /var/log/${name}.log --stderr /var/log/${name}.err"
|
||||
SERVER="nz_grpc_host:nz_grpc_port" #Dashboard 地址 ip:port
|
||||
SECRET="nz_client_secret" #SECRET
|
||||
NZ_BASE_PATH="/opt/nezha"
|
||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||
pidfile="/run/${RC_SVCNAME}.pid"
|
||||
command="/opt/nezha/agent/nezha-agent"
|
||||
command_args="-s ${SERVER} -p ${SECRET}"
|
||||
command_background=true
|
||||
depend() {
|
||||
need net
|
||||
}
|
||||
checkconfig() {
|
||||
GITHUB_URL="github.com"
|
||||
if [ ! -f "${NZ_AGENT_PATH}/nezha-agent" ]; then
|
||||
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
|
||||
os_arch="amd64"
|
||||
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||
os_arch="386"
|
||||
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||
os_arch="arm64"
|
||||
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||
os_arch="arm"
|
||||
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||
os_arch="s390x"
|
||||
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||
os_arch="riscv64"
|
||||
fi
|
||||
local version=$(curl -m 10 -sL "https://api.github.com/repos/nezhahq/agent/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
if [ ! -n "$version" ]; then
|
||||
version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
|
||||
fi
|
||||
if [ ! -n "$version" ]; then
|
||||
version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
|
||||
fi
|
||||
if [ ! -n "$version" ]; then
|
||||
echo -e "获取版本号失败,请检查本机能否链接 https://api.github.com/repos/nezhahq/agent/releases/latest"
|
||||
return 0
|
||||
else
|
||||
echo -e "当前最新版本为: ${version}"
|
||||
fi
|
||||
wget -t 2 -T 10 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "Release 下载失败,请检查本机能否连接 ${GITHUB_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
mkdir -p $NZ_AGENT_PATH
|
||||
chmod 755 -R $NZ_AGENT_PATH
|
||||
unzip -qo nezha-agent_linux_${os_arch}.zip && mv nezha-agent $NZ_AGENT_PATH && rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||
fi
|
||||
if [ ! -x "${NZ_AGENT_PATH}/nezha-agent" ]; then
|
||||
chmod +x ${NZ_AGENT_PATH}/nezha-agent
|
||||
fi
|
||||
}
|
||||
start_pre() {
|
||||
if [ "${RC_CMD}" != "restart" ]; then
|
||||
checkconfig || return $?
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
[Unit]
|
||||
Description=Nezha Agent
|
||||
After=syslog.target
|
||||
#After=network.target
|
||||
#After=nezha-dashboard.service
|
||||
|
||||
[Service]
|
||||
# Modify these two values and uncomment them if you have
|
||||
# repos with lots of files and get an HTTP error 500 because
|
||||
# of that
|
||||
###
|
||||
#LimitMEMLOCK=infinity
|
||||
#LimitNOFILE=65535
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/nezha/agent/
|
||||
ExecStart=/opt/nezha/agent/nezha-agent -s nz_grpc_host:nz_grpc_port -p nz_client_secret
|
||||
Restart=always
|
||||
#Environment=DEBUG=true
|
||||
|
||||
# Some distributions may not support these hardening directives. If you cannot start the service due
|
||||
# to an unknown option, comment out the ones not supported by your version of systemd.
|
||||
#ProtectSystem=full
|
||||
#PrivateDevices=yes
|
||||
#PrivateTmp=yes
|
||||
#NoNewPrivileges=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Executable → Regular
+5
-7
@@ -1,8 +1,4 @@
|
||||
#!/sbin/openrc-run
|
||||
supervisor=supervise-daemon
|
||||
name=nezha-dashboard
|
||||
output_log=/var/log/${name}.log
|
||||
error_log=/var/log/${name}.err
|
||||
pidfile="/run/${RC_SVCNAME}.pid"
|
||||
command="/opt/nezha/dashboard/app"
|
||||
command_args=""
|
||||
@@ -10,9 +6,11 @@ command_background=true
|
||||
directory="/opt/nezha/dashboard"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
need net
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
checkpath -f -m 0644 -o root:root "/var/log/${name}.log"
|
||||
reload() {
|
||||
ebegin "Reloading ${RC_SVCNAME}"
|
||||
start-stop-daemon --signal HUP --pidfile "${pidfile}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
@@ -106,7 +106,6 @@ func (s *NezhaHandler) ReportSystemState(c context.Context, r *pb.State) (*pb.Re
|
||||
|
||||
func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Receipt, error) {
|
||||
var clientID uint64
|
||||
var provider ddns.Provider
|
||||
var err error
|
||||
if clientID, err = s.Auth.Check(c); err != nil {
|
||||
return nil, err
|
||||
@@ -123,17 +122,13 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
|
||||
singleton.ServerList[clientID].Host.IP != host.IP {
|
||||
|
||||
serverDomain := singleton.ServerList[clientID].DDNSDomain
|
||||
if singleton.Conf.DDNS.Provider == "" {
|
||||
provider, err = singleton.GetDDNSProviderFromProfile(singleton.ServerList[clientID].DDNSProfile)
|
||||
} else {
|
||||
provider, err = singleton.GetDDNSProviderFromString(singleton.Conf.DDNS.Provider)
|
||||
}
|
||||
provider, err := singleton.GetDDNSProviderFromString(singleton.Conf.DDNS.Provider)
|
||||
if err == nil && serverDomain != "" {
|
||||
ipv4, ipv6, _ := utils.SplitIPAddr(host.IP)
|
||||
maxRetries := int(singleton.Conf.DDNS.MaxRetries)
|
||||
config := &ddns.DomainConfig{
|
||||
EnableIPv4: singleton.ServerList[clientID].EnableIPv4,
|
||||
EnableIpv6: singleton.ServerList[clientID].EnableIpv6,
|
||||
EnableIPv4: true,
|
||||
EnableIpv6: true,
|
||||
FullDomain: serverDomain,
|
||||
Ipv4Addr: ipv4,
|
||||
Ipv6Addr: ipv6,
|
||||
@@ -142,7 +137,7 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
|
||||
|
||||
} else {
|
||||
// 虽然会在启动时panic, 可以断言不会走这个分支, 但是考虑到动态加载配置或者其它情况, 这里输出一下方便检查奇奇怪怪的BUG
|
||||
log.Printf("NEZHA>> 未找到对应的DDNS配置(%s), 或者是provider填写不正确, 请前往config.yml检查你的设置\n", singleton.ServerList[clientID].DDNSProfile)
|
||||
log.Printf("NEZHA>> 未找到对应的DDNS提供者(%s), 请前往config.yml检查你的设置\n", singleton.Conf.DDNS.Provider)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,52 +37,6 @@ func GetDDNSProviderFromString(provider string) (ddns2.Provider, error) {
|
||||
return ddns2.ProviderCloudflare{
|
||||
Secret: Conf.DDNS.AccessSecret,
|
||||
}, nil
|
||||
case "tencentcloud":
|
||||
return ddns2.ProviderTencentCloud{
|
||||
SecretID: Conf.DDNS.AccessID,
|
||||
SecretKey: Conf.DDNS.AccessSecret,
|
||||
}, nil
|
||||
}
|
||||
return ddns2.ProviderDummy{}, errors.New(fmt.Sprintf("无法找到配置的DDNS提供者%s", Conf.DDNS.Provider))
|
||||
}
|
||||
|
||||
func GetDDNSProviderFromProfile(profileName string) (ddns2.Provider, error) {
|
||||
profile, ok := Conf.DDNS.Profiles[profileName]
|
||||
if !ok {
|
||||
return ddns2.ProviderDummy{}, errors.New(fmt.Sprintf("未找到配置项 %s", profileName))
|
||||
}
|
||||
|
||||
switch profile.Provider {
|
||||
case "webhook":
|
||||
return ddns2.ProviderWebHook{
|
||||
URL: profile.WebhookURL,
|
||||
RequestMethod: profile.WebhookMethod,
|
||||
RequestBody: profile.WebhookRequestBody,
|
||||
RequestHeader: profile.WebhookHeaders,
|
||||
}, nil
|
||||
case "dummy":
|
||||
return ddns2.ProviderDummy{}, nil
|
||||
case "cloudflare":
|
||||
return ddns2.ProviderCloudflare{
|
||||
Secret: profile.AccessSecret,
|
||||
}, nil
|
||||
case "tencentcloud":
|
||||
return ddns2.ProviderTencentCloud{
|
||||
SecretID: profile.AccessID,
|
||||
SecretKey: profile.AccessSecret,
|
||||
}, nil
|
||||
}
|
||||
return ddns2.ProviderDummy{}, errors.New(fmt.Sprintf("无法找到配置的DDNS提供者%s", profile.Provider))
|
||||
}
|
||||
|
||||
func ValidateDDNSProvidersFromProfiles() error {
|
||||
validProviders := map[string]bool{"webhook": true, "dummy": true, "cloudflare": true, "tencentcloud": true}
|
||||
providers := make(map[string]string)
|
||||
for profileName, profile := range Conf.DDNS.Profiles {
|
||||
if _, ok := validProviders[profile.Provider]; !ok {
|
||||
return errors.New(fmt.Sprintf("无法找到配置的DDNS提供者%s", profile.Provider))
|
||||
}
|
||||
providers[profileName] = profile.Provider
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ func (ss *ServiceSentinel) Monitors() []*model.Monitor {
|
||||
return monitors
|
||||
}
|
||||
|
||||
// loadMonitorHistory 加载服务监控器的历史状态信息
|
||||
// LoadStats 加载服务监控器的历史状态信息
|
||||
func (ss *ServiceSentinel) loadMonitorHistory() {
|
||||
var monitors []*model.Monitor
|
||||
err := DB.Find(&monitors).Error
|
||||
@@ -335,7 +335,7 @@ func (ss *ServiceSentinel) worker() {
|
||||
// 从服务状态汇报管道获取汇报的服务数据
|
||||
for r := range ss.serviceReportChannel {
|
||||
if ss.monitors[r.Data.GetId()] == nil || ss.monitors[r.Data.GetId()].ID == 0 {
|
||||
log.Printf("NEZHA>> 错误的服务监控上报 %+v", r)
|
||||
log.Printf("NEZAH>> 错误的服务监控上报 %+v", r)
|
||||
continue
|
||||
}
|
||||
mh := r.Data
|
||||
|
||||
@@ -52,16 +52,12 @@ func InitConfigFromPath(path string) {
|
||||
|
||||
// ValidateConfig 验证配置文件有效性
|
||||
func ValidateConfig() {
|
||||
var err error
|
||||
if Conf.DDNS.Provider == "" {
|
||||
err = ValidateDDNSProvidersFromProfiles()
|
||||
} else {
|
||||
_, err = GetDDNSProviderFromString(Conf.DDNS.Provider)
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// 如果DDNS启用则检查Provider是否存在, 不存在直接退出
|
||||
if Conf.DDNS.Enable {
|
||||
_, err := GetDDNSProviderFromString(Conf.DDNS.Provider)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if Conf.DDNS.MaxRetries < 1 || Conf.DDNS.MaxRetries > 10 {
|
||||
panic(fmt.Errorf("DDNS.MaxRetries值域为[1, 10]的整数, 当前为 %d", Conf.DDNS.MaxRetries))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user