當前位置: 首頁>>代碼示例>>Golang>>正文


Golang plugin.PluginConfigType類代碼示例

本文整理匯總了Golang中github.com/intelsdi-x/snap/control/plugin.PluginConfigType的典型用法代碼示例。如果您正苦於以下問題:Golang PluginConfigType類的具體用法?Golang PluginConfigType怎麽用?Golang PluginConfigType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PluginConfigType類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetMetricTypes

// GetMetricTypes returns metric types that can be collected
func (p *Libvirt) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.PluginMetricType, error) {

	conn, err := libvirt.NewVirConnection(getHypervisorURI(cfg.Table()))

	if err != nil {
		handleErr(err)
	}

	var metrics []plugin.PluginMetricType

	domains, err := conn.ListDomains()
	if err != nil {
		handleErr(err)
	}

	hostname, err := conn.GetHostname()
	if err != nil {
		handleErr(err)
	}

	defer conn.CloseConnection()
	for j := 0; j < domainCount(domains); j++ {
		dom, err := conn.LookupDomainById(domains[j])
		if err != nil {
			handleErr(err)
		}
		defer dom.Free()

		netMts, err := getNetMetricTypes(dom, hostname)
		if err != nil {
			handleErr(err)
		}
		metrics = append(metrics, netMts...)
		cpuMts, err := getCPUMetricTypes(dom, hostname)
		if err != nil {
			handleErr(err)
		}
		metrics = append(metrics, cpuMts...)
		memMts, err := getMemMetricTypes(dom, hostname)
		if err != nil {
			handleErr(err)
		}
		metrics = append(metrics, memMts...)
		diskMts, err := getDiskMetricTypes(dom, hostname)
		if err != nil {
			handleErr(err)
		}
		metrics = append(metrics, diskMts...)
	}
	for _, metric := range cpuMetricsTypes {
		metrics = append(metrics, plugin.PluginMetricType{Namespace_: []string{"libvirt", hostname, "*", "cpu", metric}})
	}
	for _, metric := range memoryMetricsTypes {
		metrics = append(metrics, plugin.PluginMetricType{Namespace_: []string{"libvirt", hostname, "*", "mem", metric}})
	}
	return metrics, nil
}
開發者ID:geauxvirtual,項目名稱:snap-plugin-collector-libvirt,代碼行數:58,代碼來源:libvirt.go

示例2: GetMetricTypes

// GetMetricTypes returns the metric types exposed by ceph-daemon sockets
func (ceph *Ceph) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.PluginMetricType, error) {
	// init ceph plugin with Global Config params
	if err := ceph.init(cfg.Table()); err != nil {
		return nil, err
	}

	mts := make([]plugin.PluginMetricType, len(ceph.keys))
	for i, k := range ceph.keys {
		mts[i] = plugin.PluginMetricType{Namespace_: strings.Split(strings.TrimPrefix(k, "/"), "/")}
	}

	return mts, nil
}
開發者ID:geauxvirtual,項目名稱:snap-plugin-collector-ceph,代碼行數:14,代碼來源:ceph.go

示例3: GetMetricTypes

//GetMetricTypes returns metric types for testing
func (f *Mock) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.PluginMetricType, error) {
	mts := []plugin.PluginMetricType{}
	if _, ok := cfg.Table()["test-fail"]; ok {
		return mts, fmt.Errorf("missing on-load plugin config entry 'test'")
	}
	if _, ok := cfg.Table()["test"]; ok {
		mts = append(mts, plugin.PluginMetricType{Namespace_: []string{"intel", "mock", "test"}})
	}
	mts = append(mts, plugin.PluginMetricType{Namespace_: []string{"intel", "mock", "foo"}})
	mts = append(mts, plugin.PluginMetricType{Namespace_: []string{"intel", "mock", "bar"}})
	mts = append(mts, plugin.PluginMetricType{
		Namespace_: []string{"intel", "mock", "*", "baz"},
		Labels_:    []core.Label{core.Label{Index: 2, Name: "host"}},
	})
	return mts, nil
}
開發者ID:gitter-badger,項目名稱:snap-1,代碼行數:17,代碼來源:mock.go

示例4: GetMetricTypes

// GetMetricTypes Returns list of metrics available for current vendor.
func (ic *IpmiCollector) GetMetricTypes(cfg plugin.PluginConfigType) ([]plugin.PluginMetricType, error) {
	ic.construct(cfg.Table())
	var mts []plugin.PluginMetricType
	mts = make([]plugin.PluginMetricType, 0)
	if ic.IpmiLayer == nil {
		return mts, fmt.Errorf("Wrong mode configuration")
	}
	for _, host := range ic.Hosts {
		for _, req := range ic.Vendor[host] {
			for _, metric := range req.Format.GetMetrics() {
				path := extendPath(req.MetricsRoot, metric)
				mts = append(mts, plugin.PluginMetricType{Namespace_: makeName(path), Source_: host})
			}
		}
	}
	ic.Initialized = true
	return mts, nil
}
開發者ID:geauxvirtual,項目名稱:snap-plugin-collector-node-manager,代碼行數:19,代碼來源:plugin.go


注:本文中的github.com/intelsdi-x/snap/control/plugin.PluginConfigType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。