Skip to content

Commit

Permalink
✨ agent: 统计rclone挂载
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Aug 27, 2021
1 parent a368923 commit ff15dfb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -224,7 +224,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
<details>
<summary>如何禁用网络连接数监控?</summary>

编辑 `/etc/systemd/system/nezha-agent.service`,在 `ExecStart=` 这一行的末尾加上 `-kconn` 就是不监控连接数
编辑 `/etc/systemd/system/nezha-agent.service`,在 `ExecStart=` 这一行的末尾加上 `--skip-conn` 就是不监控连接数

</details>

Expand Down
14 changes: 7 additions & 7 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/tls"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"log"
Expand All @@ -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"
Expand All @@ -35,6 +35,7 @@ import (
func init() {
cert.TimeoutSeconds = 30
http.DefaultClient.Timeout = time.Second * 5
flag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
}

var (
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/agent/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff15dfb

Please sign in to comment.