commit
						5d9b24601d
					
				@ -1,12 +1,13 @@
 | 
				
			|||||||
<div align="center" style="background-color: white">
 | 
					<div align="center" style="background-color: white">
 | 
				
			||||||
  <img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
 | 
					  <img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
 | 
				
			||||||
  <br><br>
 | 
					  <br><br>
 | 
				
			||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.4.14&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.4.9-brightgreen?style=for-the-badge&logo=linux">
 | 
					<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.4.15&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.4.10-brightgreen?style=for-the-badge&logo=linux">
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>	
 | 
					  <p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>	
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\>> QQ 交流群: ~~955957790~~ 各式心态的人都有,解散了省心,**自2021年3月26起不再提供任何支持,接受PR,但不再更新。**
 | 
					\>> QQ 交流群: ~~955957790~~ 已解散,**自2021年3月26起不再提供技术支持,接受PR。**<br>
 | 
				
			||||||
 | 
					\>> 交流论坛:正在选型搭建中…… 欢迎想建设社区的铁子与奶爸取得联系。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\>> [我们的用户](https://www.google.com/search?q="powered+by+哪吒监控%7C哪吒面板"&filter=0) (Google)
 | 
					\>> [我们的用户](https://www.google.com/search?q="powered+by+哪吒监控%7C哪吒面板"&filter=0) (Google)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -447,6 +447,7 @@ type settingForm struct {
 | 
				
			|||||||
	CustomCode                 string
 | 
						CustomCode                 string
 | 
				
			||||||
	ViewPassword               string
 | 
						ViewPassword               string
 | 
				
			||||||
	EnableIPChangeNotification string
 | 
						EnableIPChangeNotification string
 | 
				
			||||||
 | 
						IgnoredIPNotification      string
 | 
				
			||||||
	Oauth2Type                 string
 | 
						Oauth2Type                 string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -460,6 +461,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	dao.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on"
 | 
						dao.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on"
 | 
				
			||||||
 | 
						dao.Conf.IgnoredIPNotification = sf.IgnoredIPNotification
 | 
				
			||||||
	dao.Conf.Site.Brand = sf.Title
 | 
						dao.Conf.Site.Brand = sf.Title
 | 
				
			||||||
	dao.Conf.Site.Theme = sf.Theme
 | 
						dao.Conf.Site.Theme = sf.Theme
 | 
				
			||||||
	dao.Conf.Site.CustomCode = sf.CustomCode
 | 
						dao.Conf.Site.CustomCode = sf.CustomCode
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,8 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/fsnotify/fsnotify"
 | 
						"github.com/fsnotify/fsnotify"
 | 
				
			||||||
	"github.com/spf13/viper"
 | 
						"github.com/spf13/viper"
 | 
				
			||||||
@ -33,8 +35,10 @@ type Config struct {
 | 
				
			|||||||
	HTTPPort                   uint
 | 
						HTTPPort                   uint
 | 
				
			||||||
	GRPCPort                   uint
 | 
						GRPCPort                   uint
 | 
				
			||||||
	EnableIPChangeNotification bool
 | 
						EnableIPChangeNotification bool
 | 
				
			||||||
 | 
						IgnoredIPNotification      string // 忽略IP变更提醒的服务器列表
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v *viper.Viper
 | 
						v                              *viper.Viper
 | 
				
			||||||
 | 
						IgnoredIPNotificationServerIDs map[uint64]struct{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Config) Read(path string) error {
 | 
					func (c *Config) Read(path string) error {
 | 
				
			||||||
@ -54,6 +58,8 @@ func (c *Config) Read(path string) error {
 | 
				
			|||||||
		c.Site.Theme = "default"
 | 
							c.Site.Theme = "default"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						c.updateIgnoredIPNotificationID()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.v.OnConfigChange(func(in fsnotify.Event) {
 | 
						c.v.OnConfigChange(func(in fsnotify.Event) {
 | 
				
			||||||
		c.v.Unmarshal(c)
 | 
							c.v.Unmarshal(c)
 | 
				
			||||||
		fmt.Println("配置文件更新,重载配置", c)
 | 
							fmt.Println("配置文件更新,重载配置", c)
 | 
				
			||||||
@ -63,7 +69,19 @@ func (c *Config) Read(path string) error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *Config) updateIgnoredIPNotificationID() {
 | 
				
			||||||
 | 
						c.IgnoredIPNotificationServerIDs = make(map[uint64]struct{})
 | 
				
			||||||
 | 
						splitedIDs := strings.Split(c.IgnoredIPNotification, ",")
 | 
				
			||||||
 | 
						for i := 0; i < len(splitedIDs); i++ {
 | 
				
			||||||
 | 
							id, _ := strconv.ParseUint(splitedIDs[i], 10, 64)
 | 
				
			||||||
 | 
							if id > 0 {
 | 
				
			||||||
 | 
								c.IgnoredIPNotificationServerIDs[id] = struct{}{}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Config) Save() error {
 | 
					func (c *Config) Save() error {
 | 
				
			||||||
 | 
						c.updateIgnoredIPNotificationID()
 | 
				
			||||||
	data, err := yaml.Marshal(c)
 | 
						data, err := yaml.Marshal(c)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
 | 
				
			|||||||
@ -27,6 +27,10 @@
 | 
				
			|||||||
                <label>前台查看密码</label>
 | 
					                <label>前台查看密码</label>
 | 
				
			||||||
                <input type="text" name="ViewPassword" placeholder="" value="{{.Conf.Site.ViewPassword}}">
 | 
					                <input type="text" name="ViewPassword" placeholder="" value="{{.Conf.Site.ViewPassword}}">
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class="field">
 | 
				
			||||||
 | 
					                <label>IP 变更忽略</label>
 | 
				
			||||||
 | 
					                <input type="text" name="IgnoredIPNotification" placeholder="服务器ID 以逗号隔开 1001,1002,1003" value="{{.Conf.IgnoredIPNotification}}">
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            <div class="field">
 | 
					            <div class="field">
 | 
				
			||||||
                <div class="ui nf-ssl checkbox">
 | 
					                <div class="ui nf-ssl checkbox">
 | 
				
			||||||
                    <input name="EnableIPChangeNotification" type="checkbox" tabindex="0" class="hidden">
 | 
					                    <input name="EnableIPChangeNotification" type="checkbox" tabindex="0" class="hidden">
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ NZ_BASE_PATH="/opt/nezha"
 | 
				
			|||||||
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
 | 
					NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
 | 
				
			||||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
 | 
					NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
 | 
				
			||||||
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
 | 
					NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
 | 
				
			||||||
NZ_VERSION="v0.4.9"
 | 
					NZ_VERSION="v0.4.10"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
red='\033[0;31m'
 | 
					red='\033[0;31m'
 | 
				
			||||||
green='\033[0;32m'
 | 
					green='\033[0;32m'
 | 
				
			||||||
@ -47,18 +47,18 @@ pre_check() {
 | 
				
			|||||||
        echo "根据ip.sb提供的信息,当前IP可能在中国"
 | 
					        echo "根据ip.sb提供的信息,当前IP可能在中国"
 | 
				
			||||||
        read -r -p "是否选用中国镜像完成安装? [Y/n] " input
 | 
					        read -r -p "是否选用中国镜像完成安装? [Y/n] " input
 | 
				
			||||||
        case $input in
 | 
					        case $input in
 | 
				
			||||||
            [yY][eE][sS]|[yY])
 | 
					        [yY][eE][sS] | [yY])
 | 
				
			||||||
                echo "使用中国镜像"
 | 
					            echo "使用中国镜像"
 | 
				
			||||||
                CN=true
 | 
					            CN=true
 | 
				
			||||||
                ;;
 | 
					            ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            [nN][oO]|[nN])
 | 
					        [nN][oO] | [nN])
 | 
				
			||||||
                echo "不使用中国镜像"  	
 | 
					            echo "不使用中国镜像"
 | 
				
			||||||
                ;;
 | 
					            ;;
 | 
				
			||||||
            *)
 | 
					        *)
 | 
				
			||||||
                echo "使用中国镜像"
 | 
					            echo "使用中国镜像"
 | 
				
			||||||
                CN=true
 | 
					            CN=true
 | 
				
			||||||
                ;;
 | 
					            ;;
 | 
				
			||||||
        esac
 | 
					        esac
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -72,8 +72,6 @@ pre_check() {
 | 
				
			|||||||
        GITHUB_URL="dn-dao-github-mirror.daocloud.io"
 | 
					        GITHUB_URL="dn-dao-github-mirror.daocloud.io"
 | 
				
			||||||
        Get_Docker_URL="get.daocloud.io/docker"
 | 
					        Get_Docker_URL="get.daocloud.io/docker"
 | 
				
			||||||
        Get_Docker_Argu=" -s docker --mirror Aliyun"
 | 
					        Get_Docker_Argu=" -s docker --mirror Aliyun"
 | 
				
			||||||
        echo "写入/etc/hosts 52.68.132.128 ghcr.io"
 | 
					 | 
				
			||||||
        echo "52.68.132.128 ghcr.io" >> /etc/hosts
 | 
					 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ import (
 | 
				
			|||||||
	pb "github.com/naiba/nezha/proto"
 | 
						pb "github.com/naiba/nezha/proto"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Version = "v0.4.14" // !!记得修改 README 重的 badge 版本!!
 | 
					var Version = "v0.4.15" // !!记得修改 README 重的 badge 版本!!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	SnapshotDelay = 3
 | 
						SnapshotDelay = 3
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package rpc
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"log"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,7 +28,7 @@ func (s *NezhaHandler) ReportTask(c context.Context, r *pb.TaskResult) (*pb.Rece
 | 
				
			|||||||
		if strings.HasPrefix(r.GetData(), "SSL证书错误:") {
 | 
							if strings.HasPrefix(r.GetData(), "SSL证书错误:") {
 | 
				
			||||||
			// 排除 i/o timeont、connection timeout、EOF 错误
 | 
								// 排除 i/o timeont、connection timeout、EOF 错误
 | 
				
			||||||
			if !strings.HasSuffix(r.GetData(), "timeout") &&
 | 
								if !strings.HasSuffix(r.GetData(), "timeout") &&
 | 
				
			||||||
				r.GetData() != "EOF" &&
 | 
									!strings.HasSuffix(r.GetData(), "EOF") &&
 | 
				
			||||||
				!strings.HasSuffix(r.GetData(), "timed out") {
 | 
									!strings.HasSuffix(r.GetData(), "timed out") {
 | 
				
			||||||
				errMsg = r.GetData()
 | 
									errMsg = r.GetData()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@ -130,7 +131,9 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
 | 
				
			|||||||
	host := model.PB2Host(r)
 | 
						host := model.PB2Host(r)
 | 
				
			||||||
	dao.ServerLock.RLock()
 | 
						dao.ServerLock.RLock()
 | 
				
			||||||
	defer dao.ServerLock.RUnlock()
 | 
						defer dao.ServerLock.RUnlock()
 | 
				
			||||||
 | 
						log.Println(dao.Conf.IgnoredIPNotificationServerIDs)
 | 
				
			||||||
	if dao.Conf.EnableIPChangeNotification &&
 | 
						if dao.Conf.EnableIPChangeNotification &&
 | 
				
			||||||
 | 
							dao.Conf.IgnoredIPNotificationServerIDs[clientID] != struct{}{} &&
 | 
				
			||||||
		dao.ServerList[clientID].Host != nil &&
 | 
							dao.ServerList[clientID].Host != nil &&
 | 
				
			||||||
		dao.ServerList[clientID].Host.IP != "" &&
 | 
							dao.ServerList[clientID].Host.IP != "" &&
 | 
				
			||||||
		host.IP != "" &&
 | 
							host.IP != "" &&
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user