本文整理汇总了Golang中github.com/intelsdi-x/snap/control/plugin.ConfigType.Table方法的典型用法代码示例。如果您正苦于以下问题:Golang ConfigType.Table方法的具体用法?Golang ConfigType.Table怎么用?Golang ConfigType.Table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/intelsdi-x/snap/control/plugin.ConfigType
的用法示例。
在下文中一共展示了ConfigType.Table方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetMetricTypes
// GetMetricTypes returns metric types for testing
func (f *AnotherMock) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) {
mts := []plugin.MetricType{}
if _, ok := cfg.Table()["test-fail"]; ok {
return mts, fmt.Errorf("testing")
}
if _, ok := cfg.Table()["test"]; ok {
mts = append(mts, plugin.MetricType{
Namespace_: core.NewNamespace("intel", "anothermock", "test"),
Description_: "anothermock description",
Unit_: "anothermock unit",
})
}
mts = append(mts, plugin.MetricType{
Namespace_: core.NewNamespace("intel", "anothermock", "foo"),
Description_: "anothermock description",
Unit_: "anothermock unit",
})
mts = append(mts, plugin.MetricType{
Namespace_: core.NewNamespace("intel", "anothermock", "bar"),
Description_: "anothermock description",
Unit_: "anothermock unit",
})
mts = append(mts, plugin.MetricType{
Namespace_: core.NewNamespace("intel", "anothermock").
AddDynamicElement("host", "name of the host").
AddStaticElement("baz"),
Description_: "anothermock description",
Unit_: "anothermock unit",
})
return mts, nil
}
示例2: GetGlobalConfigItem
// GetGlobalConfigItem returns value of config item specified by `name` defined in Plugin Global Config
// Notes: GetGlobalConfigItem() will be helpful to access and get configuration item's value in GetMetricTypes()
func GetGlobalConfigItem(cfg plugin.ConfigType, name string) (interface{}, error) {
if cfg.ConfigDataNode != nil && len(cfg.Table()) > 0 {
if item, ok := cfg.Table()[name]; ok {
return getConfigItemValue(item)
}
}
return nil, fmt.Errorf("Cannot find %v in Global Config", name)
}
示例3: GetMetricTypes
func (a *Apache) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) {
webservercfg, ok := cfg.Table()["apache_mod_status_url"]
if !ok {
return getMetrics("http://127.0.0.1:80/server-status?auto", []string{})
}
webserver, ok := webservercfg.(ctypes.ConfigValueStr)
if !ok {
return nil, errBadWebserver
}
return getMetrics(webserver.Value, []string{})
}
示例4: GetMetricTypes
//GetMetricTypes returns metric types for testing
func (e *Etcd) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) {
hostcfg, ok := cfg.Table()["etcd_host"]
if !ok {
return nil, errNoHost
}
host, ok := hostcfg.(ctypes.ConfigValueStr)
if !ok {
return nil, errBadHost
}
return gathermts(host.Value, []string{})
}
示例5: GetMetricTypes
//GetMetricTypes returns metric types for testing
func (f *Mock) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) {
mts := []plugin.MetricType{}
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.MetricType{Namespace_: core.NewNamespace("intel", "mock", "test")})
}
mts = append(mts, plugin.MetricType{Namespace_: core.NewNamespace("intel", "mock", "foo")})
mts = append(mts, plugin.MetricType{Namespace_: core.NewNamespace("intel", "mock", "bar")})
mts = append(mts, plugin.MetricType{Namespace_: core.NewNamespace("intel", "mock").
AddDynamicElement("host", "name of the host").
AddStaticElement("baz")})
return mts, nil
}
示例6: GetMetricTypes
func (g *grpcClient) GetMetricTypes(config plugin.ConfigType) ([]core.Metric, error) {
arg := &rpc.GetMetricTypesArg{
Config: common.ToConfigMap(config.Table()),
}
reply, err := g.collector.GetMetricTypes(getContext(g.timeout), arg)
if err != nil {
return nil, err
}
if reply.Error != "" {
return nil, errors.New(reply.Error)
}
results := common.ToCoreMetrics(reply.Metrics)
return results, nil
}
示例7: GetMetricTypes
// GetMetricTypes returns list of available metric types
// It returns error in case retrieval was not successful
func (p *Plugin) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) {
if !p.initialized {
if err := p.init(cfg.Table()); err != nil {
return nil, err
}
}
if err := getStats(p.proc_path, p.stats, p.prevMetricsSum, p.cpuMetricsNumber,
p.snapMetricsNames, p.procStatMetricsNames); err != nil {
return nil, err
}
metricTypes := []plugin.MetricType{}
namespaces := []string{}
prefix := filepath.Join(vendor, fs, pluginName)
for cpu, stats := range p.stats {
for metric, _ := range stats {
namespaces = append(namespaces, prefix+"/"+cpu+"/"+metric)
}
}
// List of terminal metric names
mList := make(map[string]bool)
for _, namespace := range namespaces {
namespace = strings.TrimRight(namespace, string(os.PathSeparator))
metricType := plugin.MetricType{
Namespace_: core.NewNamespace(strings.Split(namespace, string(os.PathSeparator))...)}
ns := metricType.Namespace()
// CPU metric (aka last element in namespace)
mItem := ns[len(ns)-1]
// Keep it if not already seen before
if !mList[mItem.Value] {
mList[mItem.Value] = true
metricTypes = append(metricTypes, plugin.MetricType{
Namespace_: core.NewNamespace(strings.Split(prefix, string(os.PathSeparator))...).
AddDynamicElement("cpuID", "ID of CPU ('all' for aggregate)").
AddStaticElement(mItem.Value),
Description_: "dynamic CPU metric: " + mItem.Value,
})
}
}
return metricTypes, nil
}
示例8: GetMetricTypes
// GetMetricTypes Returns list of metrics available for current vendor.
func (ic *IpmiCollector) GetMetricTypes(cfg plugin.ConfigType) ([]plugin.MetricType, error) {
ic.construct(cfg.Table())
var mts []plugin.MetricType
mts = make([]plugin.MetricType, 0)
if ic.IpmiLayer == nil {
ic.Initialized = false
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.MetricType{Namespace_: makeName(path), Tags_: map[string]string{"source": host}})
}
}
}
ic.Initialized = true
return mts, nil
}
示例9: GetMetricTypes
func (g *grpcClient) GetMetricTypes(config plugin.ConfigType) ([]core.Metric, error) {
arg := &rpc.GetMetricTypesArg{
Config: ToConfigMap(config.Table()),
}
reply, err := g.collector.GetMetricTypes(getContext(g.timeout), arg)
if err != nil {
return nil, err
}
if reply.Error != "" {
return nil, errors.New(reply.Error)
}
for _, metric := range reply.Metrics {
metric.LastAdvertisedTime = ToTime(time.Now())
}
results := ToCoreMetrics(reply.Metrics)
return results, nil
}
示例10: GetGlobalConfigItems
// GetGlobalConfigItems returns map to values of multiple configuration items defined in Plugin Global Config and specified in 'names' slice
// Notes: GetGlobalConfigItems() will be helpful to access and get multiple configuration items' values in GetMetricTypes()
func GetGlobalConfigItems(cfg plugin.ConfigType, names []string) (map[string]interface{}, error) {
result := make(map[string]interface{})
for _, name := range names {
if cfg.ConfigDataNode != nil && len(cfg.Table()) > 0 {
item, ok := cfg.Table()[name]
if !ok {
return nil, fmt.Errorf("Cannot find %v in Global Config", name)
}
val, err := getConfigItemValue(item)
if err != nil {
return nil, err
}
result[name] = val
} else {
return nil, fmt.Errorf("Cannot find %v in Global Config", name)
}
}
return result, nil
}