Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-f 不支持多组模糊查询 ,也不支持指定namespaceid 查询 #2

Open
qinxingnet opened this issue Mar 24, 2023 · 2 comments

Comments

@qinxingnet
Copy link

老兄,这工具挺不错的。在使用中遇到这2个问题。

  1. -f 不支持多组模糊查询 ,如:
    ./nacos_check web --url http://10.0.5.157:8848 -f service,domain,gateway
  2. 不支持指定namespaceid查询,主要因为我们的nacos 有namespace隔离,所以就会出现多个的情况,但真实网络却是隔离的,所以需要指定一个命名空间查询,并生成json,或web
    如: ./nacos_check web --url http://10.0.5.157:8848 -a "3b19f3ca-6f5f-4d96-b7ff-a9116fa06f63" -b “DEMO环境”
func (d *Nacos) GetNameSpace() {
	if d.DefaultNamespace != "" {
		//fmt.Println(d.DefaultNamespace)
		arrNamespace := make([]NamespaceServer, 0)
		arrNamespace = append(arrNamespace, NamespaceServer{
			Namespace:         d.DefaultNamespace,
			NamespaceShowName: d.DefaultSpaceNamd,
			ConfigCount:       500,
		})

		d.Namespaces = &Namespaces{
			Code: 200,
			// Message: types.Nil{},
			Data: arrNamespace,
		}
	} else {
		_url := fmt.Sprintf("%s/nacos/v1/console/namespaces", d.DefaultUlr)
		res := d.HttpReq(_url)
		err := json.Unmarshal(res, &d.Namespaces)
		if err != nil {
			fmt.Println("获取命名空间json异常")
		}
	}
	fmt.Println(len(d.Namespaces.Data))
	// fmt.Println(cap(d.Namespaces.Data))
	for _, v := range d.Namespaces.Data {
		fmt.Println(fmt.Sprintf("ns:%s ,name=%s ,count: %d,quota=%d, type=%d", v.Namespace, v.NamespaceShowName, v.ConfigCount, v.Quota, v.Type))
	}

}







func (d *Nacos) TableRender() {
	nacos_server := d.Clusterdata[d.Host]
	tabletitle := []string{"命名空间", "服务名称", "实例", "健康状态", "主机名", "权重", "PID", "容器"}
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader(tabletitle)
	for _, v := range nacos_server.HealthInstance {
		tabledata := v[0:8]
		if FIND == "" {
			table.Append(tabledata)
		} else {
			if strings.Contains(FIND, ",") {
				array2 := strings.Split(FIND, ",")
				for _, v2 := range array2 {
					if strings.Contains(v[0], v2) {
						table.Append(tabledata)
					}
					if strings.Contains(v[1], v2) {
						table.Append(tabledata)
					}
					if strings.Contains(v[2], v2) {
						table.Append(tabledata)
					}
				}
			} else {
				if strings.Contains(v[0], FIND) {
					table.Append(tabledata)
				}
				if strings.Contains(v[1], FIND) {
					table.Append(tabledata)
				}
				if strings.Contains(v[2], FIND) {
					table.Append(tabledata)
				}
			}
		}
	}
@typ431127
Copy link
Owner

感谢大佬指点反馈,最新代码已实现上述功能

@qinxingnet
Copy link
Author

老兄的动作真快,点赞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants