1 Star 0 Fork 0

liucxer / ceph-tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mon.go 646 Bytes
一键复制 编辑 原始数据 按行查看 历史
liu.changxi@datatom.com 提交于 2021-11-03 11:08 . init
package ceph
import (
"encoding/json"
"gitee.com/liucxer/ceph-tools/pkg/interfacer"
"strings"
)
func GetAllIps(worker interfacer.Worker) ([]string, error) {
var (
ips []string
err error
)
type Resp struct {
MonMap struct {
Mons []struct {
PublicAddr string `json:"public_addr"`
} `json:"mons"`
} `json:"monmap"`
}
bts, err := worker.ExecCmd("ceph mon_status")
if err != nil {
return nil, err
}
var res Resp
err = json.Unmarshal(bts, &res)
if err != nil {
return nil, err
}
for _, mon := range res.MonMap.Mons {
ip := strings.Split(mon.PublicAddr, ":")[0]
ips = append(ips, ip)
}
return ips, 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