未验证 提交 a1130b0e 编写于 作者: P Paul Chu 提交者: GitHub

MOD: agent 文件系统 rw 探测 (#465)

上级 8bba55e4
......@@ -10,7 +10,6 @@ import (
"github.com/didi/nightingale/src/common/loggeri"
"github.com/didi/nightingale/src/modules/agent/cache"
"github.com/didi/nightingale/src/modules/agent/config"
"github.com/didi/nightingale/src/modules/agent/core"
"github.com/didi/nightingale/src/modules/agent/http"
"github.com/didi/nightingale/src/modules/agent/log/worker"
"github.com/didi/nightingale/src/modules/agent/report"
......@@ -85,7 +84,6 @@ func main() {
udp.Start()
}
core.InitRpcClients()
http.Start()
endingProc()
......
......@@ -12,7 +12,7 @@ type RpcClientContainer struct {
var rpcClients *RpcClientContainer
func InitRpcClients() {
func init() {
rpcClients = &RpcClientContainer{
M: make(map[string]*rpc.Client),
}
......
......@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"time"
......@@ -68,7 +69,7 @@ func FsRWMetrics() []*dataobj.MetricValue {
continue
}
file := filepath.Join(du.FsFile, ".fs-detect")
file := filepath.Join(du.FsFile, ".fs-detect."+genRandStr())
now := time.Now().Format("2006-01-02 15:04:05")
content := "FS-RW" + now
err = CheckFS(file, content)
......@@ -114,3 +115,20 @@ func CheckFS(file string, content string) error {
}
return nil
}
func genRandStr() string {
const len = 5
var letters []byte = []byte("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
randBytes := make([]byte, len)
if _, err := rand.Read(randBytes); err != nil {
return fmt.Sprintf("%d", rand.Int63())
}
for i := 0; i < len; i++ {
pos := randBytes[i] % 62
randBytes[i] = letters[pos]
}
return string(randBytes)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册