This commit is contained in:
naiba 2021-02-28 23:58:04 +08:00
parent dbf62991a5
commit 8f7346141a
6 changed files with 38 additions and 5 deletions

View File

@ -1,6 +1,6 @@
# 哪吒监控
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=管理面板%20v0.4.10&logo=github&style=for-the-badge) ![Agent release](https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge) ![shell](https://img.shields.io/badge/安装脚本-v0.4.7-brightgreen?style=for-the-badge&logo=linux)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=管理面板%20v0.4.11&logo=github&style=for-the-badge) ![Agent release](https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge) ![shell](https://img.shields.io/badge/安装脚本-v0.4.7-brightgreen?style=for-the-badge&logo=linux)
:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。

View File

@ -1,6 +1,7 @@
package model
import (
"encoding/json"
"fmt"
"html/template"
"time"
@ -25,5 +26,10 @@ type Server struct {
}
func (s Server) Marshal() template.JS {
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":"%s","Secret":"%s","DisplayIndex":%d,"Tag":"%s","Note":"%s"}`, s.ID, s.Name, s.Secret, s.DisplayIndex, s.Tag, s.Note))
name, _ := json.Marshal(s.Name)
tag, _ := json.Marshal(s.Tag)
note, _ := json.Marshal(s.Note)
secret, _ := json.Marshal(s.Secret)
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s}`,
s.ID, name, secret, s.DisplayIndex, tag, note))
}

27
model/server_test.go Normal file
View File

@ -0,0 +1,27 @@
package model
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestServerMarshal(t *testing.T) {
patterns := []string{
"asd > asd",
"asd \" asd",
"asd } asd",
}
for i := 0; i < len(patterns); i++ {
server := Server{
Name: patterns[i],
Tag: patterns[i],
}
serverStr := string(server.Marshal())
var serverRestore Server
assert.Nil(t, json.Unmarshal([]byte(serverStr), &serverRestore))
assert.Equal(t, server, serverRestore)
}
}

View File

@ -40,7 +40,7 @@
</div>
</div>
{{else}}
<a href="/login" class="ui large teal button">登录</a>
<a href="/login" class="ui large teal button"><i class="sign-in icon"></i>登录</a>
{{end}}
</div>
</div>

View File

@ -13,7 +13,7 @@ import (
pb "github.com/naiba/nezha/proto"
)
var Version = "v0.4.10" // !!记得修改 README 重的 badge 版本!!
var Version = "v0.4.11" // !!记得修改 README 重的 badge 版本!!
const (
SnapshotDelay = 3

View File

@ -26,7 +26,7 @@ func (s *NezhaHandler) ReportTask(c context.Context, r *pb.TaskResult) (*pb.Rece
var errMsg string
if strings.HasPrefix(r.GetData(), "SSL证书错误") {
// 排除超时错误
if !strings.HasSuffix(r.GetData(), "i/o timeout") {
if !strings.HasSuffix(r.GetData(), "timeout") {
errMsg = r.GetData()
}
} else {