Giter VIP home page Giter VIP logo

nacos_check's Introduction

nacos_check's People

Contributors

typ431127 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nacos_check's Issues

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

老兄,这工具挺不错的。在使用中遇到这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)
				}
			}
		}
	}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.