• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang plugins.Accumulator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/toorop/telegraf/plugins.Accumulator的典型用法代码示例。如果您正苦于以下问题:Golang Accumulator类的具体用法?Golang Accumulator怎么用?Golang Accumulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Accumulator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: processResponse

func processResponse(acc plugins.Accumulator, prefix string, tags map[string]string, v interface{}) {
	switch t := v.(type) {
	case map[string]interface{}:
		for k, v := range t {
			processResponse(acc, prefix+"_"+k, tags, v)
		}
	case float64:
		acc.Add(prefix, v, tags)
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:10,代码来源:exec.go


示例2: AddEngineStats

func (e *Engine) AddEngineStats(keys []string, acc plugins.Accumulator, tags map[string]string) {
	engine := reflect.ValueOf(e).Elem()
	for _, key := range keys {
		acc.Add(
			key,
			engine.FieldByName(engineStats[key]).Interface(),
			tags,
		)
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:10,代码来源:rethinkdb_data.go


示例3: Gather

func (s *NetIOStats) Gather(acc plugins.Accumulator) error {
	netio, err := s.ps.NetIO()
	if err != nil {
		return fmt.Errorf("error getting net io info: %s", err)
	}

	for _, io := range netio {
		if len(s.Interfaces) != 0 {
			var found bool

			for _, name := range s.Interfaces {
				if name == io.Name {
					found = true
					break
				}
			}

			if !found {
				continue
			}
		} else if !s.skipChecks {
			iface, err := net.InterfaceByName(io.Name)
			if err != nil {
				continue
			}

			if iface.Flags&net.FlagLoopback == net.FlagLoopback {
				continue
			}

			if iface.Flags&net.FlagUp == 0 {
				continue
			}
		}

		tags := map[string]string{
			"interface": io.Name,
		}

		acc.Add("bytes_sent", io.BytesSent, tags)
		acc.Add("bytes_recv", io.BytesRecv, tags)
		acc.Add("packets_sent", io.PacketsSent, tags)
		acc.Add("packets_recv", io.PacketsRecv, tags)
		acc.Add("err_in", io.Errin, tags)
		acc.Add("err_out", io.Errout, tags)
		acc.Add("drop_in", io.Dropin, tags)
		acc.Add("drop_out", io.Dropout, tags)
	}

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:51,代码来源:net.go


示例4: GetLustreProcStats

func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc plugins.Accumulator) error {
	files, err := filepath.Glob(fileglob)
	if err != nil {
		return err
	}

	for _, file := range files {
		/* Turn /proc/fs/lustre/obdfilter/<ost_name>/stats and similar
		 * into just the object store target name
		 * Assumpion: the target name is always second to last,
		 * which is true in Lustre 2.1->2.5
		 */
		path := strings.Split(file, "/")
		name := path[len(path)-2]
		tags := map[string]string{
			"name": name,
		}

		lines, err := common.ReadLines(file)
		if err != nil {
			return err
		}

		for _, line := range lines {
			fields := strings.Fields(line)

			for _, wanted := range wanted_fields {
				var data uint64
				if fields[0] == wanted.inProc {
					wanted_field := wanted.field
					// if not set, assume field[1]. Shouldn't be field[0], as
					// that's a string
					if wanted_field == 0 {
						wanted_field = 1
					}
					data, err = strconv.ParseUint((fields[wanted_field]), 10, 64)
					if err != nil {
						return err
					}
					report_name := wanted.inProc
					if wanted.reportAs != "" {
						report_name = wanted.reportAs
					}
					acc.Add(report_name, data, tags)

				}
			}
		}
	}
	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:51,代码来源:lustre2.go


示例5: Gather

func (s *SwapStats) Gather(acc plugins.Accumulator) error {
	swap, err := s.ps.SwapStat()
	if err != nil {
		return fmt.Errorf("error getting swap memory info: %s", err)
	}

	swaptags := map[string]string(nil)

	acc.Add("total", swap.Total, swaptags)
	acc.Add("used", swap.Used, swaptags)
	acc.Add("free", swap.Free, swaptags)
	acc.Add("used_perc", swap.UsedPercent, swaptags)
	acc.Add("in", swap.Sin, swaptags)
	acc.Add("out", swap.Sout, swaptags)

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:17,代码来源:memory.go


示例6: parseInterface

func (e *Elasticsearch) parseInterface(acc plugins.Accumulator, prefix string, tags map[string]string, v interface{}) error {
	switch t := v.(type) {
	case map[string]interface{}:
		for k, v := range t {
			if err := e.parseInterface(acc, prefix+"_"+k, tags, v); err != nil {
				return err
			}
		}
	case float64:
		acc.Add(prefix, t, tags)
	case bool, string, []interface{}:
		// ignored types
		return nil
	default:
		return fmt.Errorf("elasticsearch: got unexpected type %T with value %v (%s)", t, t, prefix)
	}
	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:18,代码来源:elasticsearch.go


示例7: Gather

func (_ *SystemStats) Gather(acc plugins.Accumulator) error {
	loadavg := sigar.LoadAverage{}
	if err := loadavg.Get(); err != nil {
		return err
	}

	uptime := sigar.Uptime{}
	if err := uptime.Get(); err != nil {
		return err
	}

	acc.Add("load1", loadavg.One, nil)
	acc.Add("load5", loadavg.Five, nil)
	acc.Add("load15", loadavg.Fifteen, nil)
	acc.Add("uptime", uptime.Length, nil)
	acc.Add("uptime_format", uptime.Format(), nil)

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:19,代码来源:system.go


示例8: emitMetrics

func emitMetrics(k *Kafka, acc plugins.Accumulator, metricConsumer <-chan []byte) error {
	timeout := time.After(1 * time.Second)

	for {
		select {
		case batch := <-metricConsumer:
			var points []tsdb.Point
			var err error
			if points, err = tsdb.ParsePoints(batch); err != nil {
				return err
			}

			for _, point := range points {
				acc.AddValuesWithTime(point.Name(), point.Fields(), point.Tags(), point.Time())
			}
		case <-timeout:
			return nil
		}
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:20,代码来源:kafka_consumer.go


示例9: Gather

func (p *Ping) Gather(acc plugins.Accumulator) error {

	var wg sync.WaitGroup
	errorChannel := make(chan error, len(p.Urls)*2)

	// Spin off a go routine for each url to ping
	for _, url := range p.Urls {
		wg.Add(1)
		go func(url string, acc plugins.Accumulator) {
			defer wg.Done()
			args := p.args(url)
			out, err := p.pingHost(args...)
			if err != nil {
				// Combine go err + stderr output
				errorChannel <- errors.New(
					strings.TrimSpace(out) + ", " + err.Error())
			}
			tags := map[string]string{"url": url}
			trans, rec, avg, err := processPingOutput(out)
			if err != nil {
				// fatal error
				errorChannel <- err
				return
			}
			// Calculate packet loss percentage
			loss := float64(trans-rec) / float64(trans) * 100.0
			acc.Add("packets_transmitted", trans, tags)
			acc.Add("packets_received", rec, tags)
			acc.Add("percent_packet_loss", loss, tags)
			acc.Add("average_response_ms", avg, tags)
		}(url, acc)
	}

	wg.Wait()
	close(errorChannel)

	// Get all errors and return them as one giant error
	errorStrings := []string{}
	for err := range errorChannel {
		errorStrings = append(errorStrings, err.Error())
	}

	if len(errorStrings) == 0 {
		return nil
	}
	return errors.New(strings.Join(errorStrings, "\n"))
}
开发者ID:toorop,项目名称:telegraf,代码行数:47,代码来源:ping.go


示例10: gatherServer

func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc plugins.Accumulator) error {
	cmd := exec.Command("snmpwalk", "-v2c", "-cpublic", endpoint, oid)
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return err
	}
	cmd.Start()
	defer cmd.Wait()
	scanner := bufio.NewScanner(stdout)
	if !scanner.Scan() {
		return fmt.Errorf("Unable to retrieve the node name")
	}
	nodeName, err := retrieveTokenAfterColon(scanner.Text())
	if err != nil {
		return err
	}
	nodeNameTrimmed := strings.Trim(nodeName, "\"")
	tags := map[string]string{
		"node": nodeNameTrimmed,
	}
	i := 0
	for scanner.Scan() {
		key := KeyMapping[serverType][i]
		val, err := retrieveTokenAfterColon(scanner.Text())
		if err != nil {
			return err
		}
		fVal, err := strconv.ParseFloat(val, 64)
		if err != nil {
			return fmt.Errorf("Unable to parse the value:%s, err:%s", val, err)
		}
		acc.Add(key, fVal, tags)
		i++
	}
	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:36,代码来源:leofs.go


示例11: gatherUrl

func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
	resp, err := client.Get(addr.String())
	if err != nil {
		return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("%s returned HTTP status %s", addr.String(), resp.Status)
	}

	tags := getTags(addr)

	sc := bufio.NewScanner(resp.Body)
	for sc.Scan() {
		line := sc.Text()
		if strings.Contains(line, ":") {

			parts := strings.SplitN(line, ":", 2)
			key, part := strings.Replace(parts[0], " ", "", -1), strings.TrimSpace(parts[1])

			switch key {

			case "Scoreboard":
				n.gatherScores(part, acc, tags)
			default:
				value, err := strconv.ParseFloat(part, 32)
				if err != nil {
					continue
				}
				acc.Add(key, value, tags)
			}
		}
	}

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:36,代码来源:apache.go


示例12: importCsvResult

func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) ([][]string, error) {
	csv := csv.NewReader(r)
	result, err := csv.ReadAll()

	for _, row := range result {

		for field, v := range row {
			tags := map[string]string{
				"host":  host,
				"proxy": row[HF_PXNAME],
				"sv":    row[HF_SVNAME],
			}
			switch field {
			case HF_QCUR:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("qcur", ival, tags)
				}
			case HF_QMAX:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("qmax", ival, tags)
				}
			case HF_SCUR:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("scur", ival, tags)
				}
			case HF_SMAX:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("smax", ival, tags)
				}
			case HF_BIN:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("bin", ival, tags)
				}
			case HF_BOUT:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("bout", ival, tags)
				}
			case HF_DREQ:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("dreq", ival, tags)
				}
			case HF_DRESP:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("dresp", ival, tags)
				}
			case HF_RATE:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("rate", ival, tags)
				}
			case HF_RATE_MAX:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("rate_max", ival, tags)
				}
			case HF_STOT:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("stot", ival, tags)
				}
			case HF_HRSP_1xx:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("http_response.1xx", ival, tags)
				}
			case HF_HRSP_2xx:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("http_response.2xx", ival, tags)
				}
			case HF_HRSP_3xx:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("http_response.3xx", ival, tags)
				}
			case HF_HRSP_4xx:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("http_response.4xx", ival, tags)
				}
			case HF_EREQ:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("ereq", ival, tags)
				}
			case HF_ERESP:
				ival, err := strconv.ParseUint(v, 10, 64)
				if err == nil {
					acc.Add("eresp", ival, tags)
				}
			case HF_ECON:
				ival, err := strconv.ParseUint(v, 10, 64)
//.........这里部分代码省略.........
开发者ID:toorop,项目名称:telegraf,代码行数:101,代码来源:haproxy.go


示例13: gatherServer

func (g *Disque) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
	if g.c == nil {

		_, _, err := net.SplitHostPort(addr.Host)
		if err != nil {
			addr.Host = addr.Host + ":" + defaultPort
		}

		c, err := net.Dial("tcp", addr.Host)
		if err != nil {
			return fmt.Errorf("Unable to connect to disque server '%s': %s", addr.Host, err)
		}

		if addr.User != nil {
			pwd, set := addr.User.Password()
			if set && pwd != "" {
				c.Write([]byte(fmt.Sprintf("AUTH %s\r\n", pwd)))

				r := bufio.NewReader(c)

				line, err := r.ReadString('\n')
				if err != nil {
					return err
				}
				if line[0] != '+' {
					return fmt.Errorf("%s", strings.TrimSpace(line)[1:])
				}
			}
		}

		g.c = c
	}

	g.c.Write([]byte("info\r\n"))

	r := bufio.NewReader(g.c)

	line, err := r.ReadString('\n')
	if err != nil {
		return err
	}

	if line[0] != '$' {
		return fmt.Errorf("bad line start: %s", ErrProtocolError)
	}

	line = strings.TrimSpace(line)

	szStr := line[1:]

	sz, err := strconv.Atoi(szStr)
	if err != nil {
		return fmt.Errorf("bad size string <<%s>>: %s", szStr, ErrProtocolError)
	}

	var read int

	for read < sz {
		line, err := r.ReadString('\n')
		if err != nil {
			return err
		}

		read += len(line)

		if len(line) == 1 || line[0] == '#' {
			continue
		}

		parts := strings.SplitN(line, ":", 2)

		name := string(parts[0])

		metric, ok := Tracking[name]
		if !ok {
			continue
		}

		tags := map[string]string{"host": addr.String()}
		val := strings.TrimSpace(parts[1])

		ival, err := strconv.ParseUint(val, 10, 64)
		if err == nil {
			acc.Add(metric, ival, tags)
			continue
		}

		fval, err := strconv.ParseFloat(val, 64)
		if err != nil {
			return err
		}

		acc.Add(metric, fval, tags)
	}

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:97,代码来源:disque.go


示例14: Gather

func (s *DockerStats) Gather(acc plugins.Accumulator) error {
	containers, err := s.ps.DockerStat()
	if err != nil {
		return fmt.Errorf("error getting docker info: %s", err)
	}

	for _, cont := range containers {
		tags := map[string]string{
			"id":      cont.Id,
			"name":    cont.Name,
			"command": cont.Command,
		}

		cts := cont.CPU

		acc.Add("user", cts.User, tags)
		acc.Add("system", cts.System, tags)
		acc.Add("idle", cts.Idle, tags)
		acc.Add("nice", cts.Nice, tags)
		acc.Add("iowait", cts.Iowait, tags)
		acc.Add("irq", cts.Irq, tags)
		acc.Add("softirq", cts.Softirq, tags)
		acc.Add("steal", cts.Steal, tags)
		acc.Add("guest", cts.Guest, tags)
		acc.Add("guestNice", cts.GuestNice, tags)
		acc.Add("stolen", cts.Stolen, tags)

		acc.Add("cache", cont.Mem.Cache, tags)
		acc.Add("rss", cont.Mem.RSS, tags)
		acc.Add("rss_huge", cont.Mem.RSSHuge, tags)
		acc.Add("mapped_file", cont.Mem.MappedFile, tags)
		acc.Add("swap_in", cont.Mem.Pgpgin, tags)
		acc.Add("swap_out", cont.Mem.Pgpgout, tags)
		acc.Add("page_fault", cont.Mem.Pgfault, tags)
		acc.Add("page_major_fault", cont.Mem.Pgmajfault, tags)
		acc.Add("inactive_anon", cont.Mem.InactiveAnon, tags)
		acc.Add("active_anon", cont.Mem.ActiveAnon, tags)
		acc.Add("inactive_file", cont.Mem.InactiveFile, tags)
		acc.Add("active_file", cont.Mem.ActiveFile, tags)
		acc.Add("unevictable", cont.Mem.Unevictable, tags)
		acc.Add("memory_limit", cont.Mem.HierarchicalMemoryLimit, tags)
		acc.Add("total_cache", cont.Mem.TotalCache, tags)
		acc.Add("total_rss", cont.Mem.TotalRSS, tags)
		acc.Add("total_rss_huge", cont.Mem.TotalRSSHuge, tags)
		acc.Add("total_mapped_file", cont.Mem.TotalMappedFile, tags)
		acc.Add("total_swap_in", cont.Mem.TotalPgpgIn, tags)
		acc.Add("total_swap_out", cont.Mem.TotalPgpgOut, tags)
		acc.Add("total_page_fault", cont.Mem.TotalPgFault, tags)
		acc.Add("total_page_major_fault", cont.Mem.TotalPgMajFault, tags)
		acc.Add("total_inactive_anon", cont.Mem.TotalInactiveAnon, tags)
		acc.Add("total_active_anon", cont.Mem.TotalActiveAnon, tags)
		acc.Add("total_inactive_file", cont.Mem.TotalInactiveFile, tags)
		acc.Add("total_active_file", cont.Mem.TotalActiveFile, tags)
		acc.Add("total_unevictable", cont.Mem.TotalUnevictable, tags)
	}

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:58,代码来源:docker.go


示例15: gatherUrl

func (n *Nginx) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
	resp, err := client.Get(addr.String())
	if err != nil {
		return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("%s returned HTTP status %s", addr.String(), resp.Status)
	}
	r := bufio.NewReader(resp.Body)

	// Active connections
	_, err = r.ReadString(':')
	if err != nil {
		return err
	}
	line, err := r.ReadString('\n')
	if err != nil {
		return err
	}
	active, err := strconv.ParseUint(strings.TrimSpace(line), 10, 64)
	if err != nil {
		return err
	}

	// Server accepts handled requests
	_, err = r.ReadString('\n')
	if err != nil {
		return err
	}
	line, err = r.ReadString('\n')
	if err != nil {
		return err
	}
	data := strings.SplitN(strings.TrimSpace(line), " ", 3)
	accepts, err := strconv.ParseUint(data[0], 10, 64)
	if err != nil {
		return err
	}
	handled, err := strconv.ParseUint(data[1], 10, 64)
	if err != nil {
		return err
	}
	requests, err := strconv.ParseUint(data[2], 10, 64)
	if err != nil {
		return err
	}

	// Reading/Writing/Waiting
	line, err = r.ReadString('\n')
	if err != nil {
		return err
	}
	data = strings.SplitN(strings.TrimSpace(line), " ", 6)
	reading, err := strconv.ParseUint(data[1], 10, 64)
	if err != nil {
		return err
	}
	writing, err := strconv.ParseUint(data[3], 10, 64)
	if err != nil {
		return err
	}
	waiting, err := strconv.ParseUint(data[5], 10, 64)
	if err != nil {
		return err
	}

	tags := getTags(addr)

	acc.Add("active", active, tags)
	acc.Add("accepts", accepts, tags)
	acc.Add("handled", handled, tags)
	acc.Add("requests", requests, tags)
	acc.Add("reading", reading, tags)
	acc.Add("writing", writing, tags)
	acc.Add("waiting", waiting, tags)

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:79,代码来源:nginx.go


示例16: AddStats

func (s *Storage) AddStats(acc plugins.Accumulator, tags map[string]string) {
	acc.Add("cache_bytes_in_use", s.Cache.BytesInUse, tags)
	acc.Add("disk_read_bytes_per_sec", s.Disk.ReadBytesPerSec, tags)
	acc.Add("disk_read_bytes_total", s.Disk.ReadBytesTotal, tags)
	acc.Add("disk_written_bytes_per_sec", s.Disk.WriteBytesPerSec, tags)
	acc.Add("disk_written_bytes_total", s.Disk.WriteBytesTotal, tags)
	acc.Add("disk_usage_data_bytes", s.Disk.SpaceUsage.Data, tags)
	acc.Add("disk_usage_garbage_bytes", s.Disk.SpaceUsage.Garbage, tags)
	acc.Add("disk_usage_metadata_bytes", s.Disk.SpaceUsage.Metadata, tags)
	acc.Add("disk_usage_preallocated_bytes", s.Disk.SpaceUsage.Prealloc, tags)
}
开发者ID:toorop,项目名称:telegraf,代码行数:11,代码来源:rethinkdb_data.go


示例17: accRow

func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator, server string) error {
	var ignore interface{}
	var name string
	var commit, rollback, read, hit int64
	var returned, fetched, inserted, updated, deleted int64
	var conflicts, temp_files, temp_bytes, deadlocks int64
	var read_time, write_time float64

	err := row.Scan(&ignore, &name, &ignore,
		&commit, &rollback,
		&read, &hit,
		&returned, &fetched, &inserted, &updated, &deleted,
		&conflicts, &temp_files, &temp_bytes,
		&deadlocks, &read_time, &write_time,
		&ignore,
	)

	if err != nil {
		return err
	}

	tags := map[string]string{"server": server, "db": name}

	acc.Add("xact_commit", commit, tags)
	acc.Add("xact_rollback", rollback, tags)
	acc.Add("blks_read", read, tags)
	acc.Add("blks_hit", hit, tags)
	acc.Add("tup_returned", returned, tags)
	acc.Add("tup_fetched", fetched, tags)
	acc.Add("tup_inserted", inserted, tags)
	acc.Add("tup_updated", updated, tags)
	acc.Add("tup_deleted", deleted, tags)
	acc.Add("conflicts", conflicts, tags)
	acc.Add("temp_files", temp_files, tags)
	acc.Add("temp_bytes", temp_bytes, tags)
	acc.Add("deadlocks", deadlocks, tags)
	acc.Add("blk_read_time", read_time, tags)
	acc.Add("blk_write_time", read_time, tags)

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:41,代码来源:postgresql.go


示例18: gatherScores

func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[string]string) {

	var waiting, open int = 0, 0
	var S, R, W, K, D, C, L, G, I int = 0, 0, 0, 0, 0, 0, 0, 0, 0

	for _, s := range strings.Split(data, "") {

		switch s {
		case "_":
			waiting++
		case "S":
			S++
		case "R":
			R++
		case "W":
			W++
		case "K":
			K++
		case "D":
			D++
		case "C":
			C++
		case "L":
			L++
		case "G":
			G++
		case "I":
			I++
		case ".":
			open++
		}
	}

	acc.Add("scboard_waiting", float64(waiting), tags)
	acc.Add("scboard_starting", float64(S), tags)
	acc.Add("scboard_reading", float64(R), tags)
	acc.Add("scboard_sending", float64(W), tags)
	acc.Add("scboard_keepalive", float64(K), tags)
	acc.Add("scboard_dnslookup", float64(D), tags)
	acc.Add("scboard_closing", float64(C), tags)
	acc.Add("scboard_logging", float64(L), tags)
	acc.Add("scboard_finishing", float64(G), tags)
	acc.Add("scboard_idle_cleanup", float64(I), tags)
	acc.Add("scboard_open", float64(open), tags)
}
开发者ID:toorop,项目名称:telegraf,代码行数:45,代码来源:apache.go


示例19: Gather

func (s *DiskIOStats) Gather(acc plugins.Accumulator) error {
	diskio, err := s.ps.DiskIO()
	if err != nil {
		return fmt.Errorf("error getting disk io info: %s", err)
	}

	for _, io := range diskio {
		tags := map[string]string{}
		if len(io.Name) != 0 {
			tags["name"] = io.Name
		}
		if len(io.SerialNumber) != 0 {
			tags["serial"] = io.SerialNumber
		}

		acc.Add("reads", io.ReadCount, tags)
		acc.Add("writes", io.WriteCount, tags)
		acc.Add("read_bytes", io.ReadBytes, tags)
		acc.Add("write_bytes", io.WriteBytes, tags)
		acc.Add("read_time", io.ReadTime, tags)
		acc.Add("write_time", io.WriteTime, tags)
		acc.Add("io_time", io.IoTime, tags)
	}

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:26,代码来源:disk.go


示例20: gatherServer

func (r *RabbitMQ) gatherServer(serv *Server, acc plugins.Accumulator) error {
	overview := &OverviewResponse{}

	err := r.requestJSON(serv, "/api/overview", &overview)
	if err != nil {
		return err
	}

	tags := map[string]string{}

	acc.Add("messages", overview.QueueTotals.Messages, tags)
	acc.Add("messages_ready", overview.QueueTotals.MessagesReady, tags)
	acc.Add("messages_unacked", overview.QueueTotals.MessagesUnacknowledged, tags)

	acc.Add("channels", overview.ObjectTotals.Channels, tags)
	acc.Add("connections", overview.ObjectTotals.Connections, tags)
	acc.Add("consumers", overview.ObjectTotals.Consumers, tags)
	acc.Add("exchanges", overview.ObjectTotals.Exchanges, tags)
	acc.Add("queues", overview.ObjectTotals.Queues, tags)

	if overview.MessageStats != nil {
		acc.Add("messages_acked", overview.MessageStats.Ack, tags)
		acc.Add("messages_delivered", overview.MessageStats.Deliver, tags)
		acc.Add("messages_published", overview.MessageStats.Publish, tags)
	}

	nodes := make([]Node, 0)

	err = r.requestJSON(serv, "/api/nodes", &nodes)
	if err != nil {
		return err
	}

	for _, node := range nodes {
		if !shouldGatherNode(node, serv) {
			continue
		}

		tags = map[string]string{"node": node.Name}

		acc.Add("disk_free", node.DiskFree, tags)
		acc.Add("disk_free_limit", node.DiskFreeLimit, tags)
		acc.Add("fd_total", node.FdTotal, tags)
		acc.Add("fd_used", node.FdUsed, tags)
		acc.Add("mem_limit", node.MemLimit, tags)
		acc.Add("mem_used", node.MemUsed, tags)
		acc.Add("proc_total", node.ProcTotal, tags)
		acc.Add("proc_used", node.ProcUsed, tags)
		acc.Add("run_queue", node.RunQueue, tags)
		acc.Add("sockets_total", node.SocketsTotal, tags)
		acc.Add("sockets_used", node.SocketsUsed, tags)
	}

	return nil
}
开发者ID:toorop,项目名称:telegraf,代码行数:55,代码来源:rabbitmq.go



注:本文中的github.com/toorop/telegraf/plugins.Accumulator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testutil.Accumulator类代码示例发布时间:2022-05-28
下一篇:
Golang event.IEvent类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap