本文整理汇总了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;未经允许,请勿转载。 |
请发表评论