diff --git a/README.md b/README.md index 574f92ec88..3ad6733ab6 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 - `net_in_speed` 入站网速、`net_out_speed` 出站网速、`net_all_speed` 双向网速、`transfer_in` 入站流量、`transfer_out` 出站流量、`transfer_all` 双向流量 - `offline` 离线监控 - `load1`、`load5`、`load15` 负载 - - `process_count` 进程数 *目前取线程数占用资源太多,暂时不支持* + - `process_count` 进程数 _目前取线程数占用资源太多,暂时不支持_ - `tcp_conn_count`、`udp_conn_count` 连接数 - duration:持续秒数,秒数内采样记录 30% 以上触发阈值才会报警(防数据插针) - min/max @@ -224,7 +224,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
如何禁用网络连接数监控? -编辑 `/etc/systemd/system/nezha-agent.service`,在 `ExecStart=` 这一行的末尾加上 `-kconn` 就是不监控连接数 +编辑 `/etc/systemd/system/nezha-agent.service`,在 `ExecStart=` 这一行的末尾加上 `--skip-conn` 就是不监控连接数
diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 5fee32c602..c57b7bdb03 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "encoding/json" "errors" - "flag" "fmt" "io" "log" @@ -21,6 +20,7 @@ import ( "github.com/go-ping/ping" "github.com/gorilla/websocket" "github.com/p14yground/go-github-selfupdate/selfupdate" + flag "github.com/spf13/pflag" "google.golang.org/grpc" "github.com/naiba/nezha/cmd/agent/monitor" @@ -35,6 +35,7 @@ import ( func init() { cert.TimeoutSeconds = 30 http.DefaultClient.Timeout = time.Second * 5 + flag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true } var ( @@ -67,14 +68,13 @@ func main() { // 来自于 GoReleaser 的版本号 monitor.Version = version - flag.String("i", "", "unused 旧Agent配置兼容") - flag.BoolVar(&debug, "d", false, "开启调试信息") - flag.StringVar(&server, "s", "localhost:5555", "管理面板RPC端口") - flag.StringVar(&clientSecret, "p", "", "Agent连接Secret") - flag.BoolVar(&stateConf.SkipConnectionCount, "kconn", false, "不监控连接数") + flag.BoolVarP(&debug, "debug", "d", false, "开启调试信息") + flag.StringVarP(&server, "*server", "s", "localhost:5555", "管理面板RPC端口") + flag.StringVarP(&clientSecret, "password", "p", "", "Agent连接Secret") + flag.BoolVar(&stateConf.SkipConnectionCount, "skip-conn", false, "不监控连接数") flag.Parse() - if server == "" || clientSecret == "" { + if clientSecret == "" { flag.Usage() return } diff --git a/cmd/agent/monitor/monitor.go b/cmd/agent/monitor/monitor.go index a8c2f53c06..21a1242115 100644 --- a/cmd/agent/monitor/monitor.go +++ b/cmd/agent/monitor/monitor.go @@ -22,7 +22,8 @@ import ( var Version string = "debug" var netInSpeed, netOutSpeed, netInTransfer, netOutTransfer, lastUpdate uint64 var expectDiskFsTypes = []string{ - "apfs", "ext4", "ext3", "ext2", "f2fs", "reiserfs", "jfs", "btrfs", "fuseblk", "zfs", "simfs", "ntfs", "fat32", "exfat", "xfs", + "apfs", "ext4", "ext3", "ext2", "f2fs", "reiserfs", "jfs", "btrfs", + "fuseblk", "zfs", "simfs", "ntfs", "fat32", "exfat", "xfs", "fuse.rclone", } var excludeNetInterfaces = []string{ "lo", "tun", "docker", "veth", "br-", "vmbr", "vnet", "kube", diff --git a/go.mod b/go.mod index 079e7ee853..1ebe3ab38d 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil/v3 v3.21.7 + github.com/spf13/pflag v1.0.3 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9