Example #1
0
File: info.go Project: jarpy/beats
func (m *MetricSeter) Fetch(ms *helper.MetricSet) (events []common.MapStr, err error) {

	for _, host := range ms.Config.Hosts {

		conn, err := redis.Connect(host)
		if err != nil {
			return nil, err
		}

		out, err := rd.String(conn.Do("INFO"))
		if err != nil {
			logp.Err("Error converting to string: %v", err)
		}

		event := eventMapping(parseRedisInfo(out))
		events = append(events, event)
	}

	return events, nil
}
Example #2
0
File: info.go Project: junk16/beats
func (m MetricSeter) Fetch() (events []common.MapStr, err error) {

	hosts := MetricSet.Module.GetHosts()

	for _, host := range hosts {

		conn, err := redis.Connect(host)
		if err != nil {
			return nil, err
		}

		out, err := rd.String(conn.Do("INFO"))
		if err != nil {
			logp.Err("Error converting to string: %v", err)
		}

		// Feed every line into
		result := strings.Split(out, "\r\n")

		// Load redis info values into array
		values := map[string]string{}

		for _, value := range result {
			// Values are separated by :
			parts := strings.Split(value, ":")
			if len(parts) == 2 {
				values[parts[0]] = parts[1]
			}
		}

		event := eventMapping(values)

		events = append(events, event)
	}

	return events, nil
}