1 Star 0 Fork 0

liucxer / ceph-tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cluster_log.go 792 Bytes
一键复制 编辑 原始数据 按行查看 历史
刘昌喜 提交于 2023-11-20 19:23 . update
package monitor
import (
"encoding/json"
"fmt"
"io/ioutil"
"strings"
)
func ClusterLogReadFile() error {
path := "/Users/liucx/Documents/gopath/src/gitee.com/liucxer/ceph-tools/pkg/monitor/cluster.log"
bts, err := ioutil.ReadFile(path)
if err != nil {
return err
}
list := strings.Split(string(bts), "\n")
for _, item := range list {
if !strings.Contains(item, "client_request") {
continue
}
if strings.Contains(item, "dump_historic_ops") {
continue
}
var ops Ops
err = json.Unmarshal([]byte(item), &ops)
if err != nil {
return err
}
if ops.Duration < 5 {
continue
}
if strings.Contains(ops.Description, "readdir") {
bts, err := json.Marshal(ops)
if err != nil {
return err
}
fmt.Println(string(bts))
}
}
return err
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liucxer/ceph-tools.git
git@gitee.com:liucxer/ceph-tools.git
liucxer
ceph-tools
ceph-tools
ecdc69b73bfe

搜索帮助

344bd9b3 5694891 D2dac590 5694891