mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 09:38:13 -05:00
⚡️ 提升「服务」页面抗击打能力
This commit is contained in:
parent
eefff7988a
commit
5c127bc03f
@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.16&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.8.1-brightgreen?style=for-the-badge&logo=linux">
|
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.17&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.8.1-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,计划任务和在线终端。</p>
|
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,计划任务和在线终端。</p>
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/hashicorp/go-uuid"
|
"github.com/hashicorp/go-uuid"
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"golang.org/x/sync/singleflight"
|
"golang.org/x/sync/singleflight"
|
||||||
|
|
||||||
@ -100,12 +101,22 @@ func (p *commonPage) checkViewPassword(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *commonPage) service(c *gin.Context) {
|
func (p *commonPage) service(c *gin.Context) {
|
||||||
singleton.AlertsLock.RLock()
|
res, _, _ := p.requestGroup.Do("servicePage", func() (interface{}, error) {
|
||||||
defer singleton.AlertsLock.RUnlock()
|
singleton.AlertsLock.RLock()
|
||||||
|
defer singleton.AlertsLock.RUnlock()
|
||||||
|
var stats map[uint64]model.ServiceItemResponse
|
||||||
|
var statsStore map[uint64]model.CycleTransferStats
|
||||||
|
copier.Copy(&stats, singleton.ServiceSentinelShared.LoadStats())
|
||||||
|
copier.Copy(&statsStore, singleton.AlertsCycleTransferStatsStore)
|
||||||
|
return []interface {
|
||||||
|
}{
|
||||||
|
stats, statsStore,
|
||||||
|
}, nil
|
||||||
|
})
|
||||||
c.HTML(http.StatusOK, "theme-"+singleton.Conf.Site.Theme+"/service", mygin.CommonEnvironment(c, gin.H{
|
c.HTML(http.StatusOK, "theme-"+singleton.Conf.Site.Theme+"/service", mygin.CommonEnvironment(c, gin.H{
|
||||||
"Title": "服务状态",
|
"Title": "服务状态",
|
||||||
"Services": singleton.ServiceSentinelShared.LoadStats(),
|
"Services": res.([]interface{})[0],
|
||||||
"CycleTransferStats": singleton.AlertsCycleTransferStatsStore,
|
"CycleTransferStats": res.([]interface{})[1],
|
||||||
"CustomCode": singleton.Conf.Site.CustomCode,
|
"CustomCode": singleton.Conf.Site.CustomCode,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"fmt"
|
||||||
|
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/jinzhu/copier"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
type Cat struct {
|
||||||
c := cron.New(cron.WithSeconds())
|
age int
|
||||||
_, err := c.AddFunc("* * * * * *", func() {
|
name string
|
||||||
log.Println("bingo second")
|
friends []string
|
||||||
})
|
}
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
func main() {
|
||||||
}
|
a := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
|
||||||
_, err = c.AddFunc("* * * * *", func() {
|
b := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
|
||||||
log.Println("bingo minute")
|
c := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
|
||||||
})
|
wilson := []*Cat{&a, &b, &c}
|
||||||
if err != nil {
|
nikita := []Cat{}
|
||||||
panic(err)
|
copier.Copy(&nikita, &wilson)
|
||||||
}
|
|
||||||
c.Start()
|
nikita[0].friends = append(nikita[0].friends, "Syd")
|
||||||
select {}
|
|
||||||
|
fmt.Println(wilson[0])
|
||||||
|
fmt.Println(nikita[0])
|
||||||
}
|
}
|
||||||
|
1
go.mod
1
go.mod
@ -17,6 +17,7 @@ require (
|
|||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/hashicorp/go-uuid v1.0.2
|
github.com/hashicorp/go-uuid v1.0.2
|
||||||
github.com/iamacarpet/go-winpty v1.0.2
|
github.com/iamacarpet/go-winpty v1.0.2
|
||||||
|
github.com/jinzhu/copier v0.3.5
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/ory/graceful v0.1.2
|
github.com/ory/graceful v0.1.2
|
||||||
github.com/p14yground/go-github-selfupdate v0.0.0-20220205132106-76a6d59b925b
|
github.com/p14yground/go-github-selfupdate v0.0.0-20220205132106-76a6d59b925b
|
||||||
|
2
go.sum
2
go.sum
@ -200,6 +200,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
|||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
|
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
|
||||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
|
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
|
||||||
|
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
|
||||||
|
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
|
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
pb "github.com/naiba/nezha/proto"
|
pb "github.com/naiba/nezha/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "v0.12.16" // !!记得修改 README 中的 badge 版本!!
|
var Version = "v0.12.17" // !!记得修改 README 中的 badge 版本!!
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Conf *model.Config
|
Conf *model.Config
|
||||||
|
Loading…
Reference in New Issue
Block a user