Esempio n. 1
0
func CPULoad(c redis.Client) (Metric, error) {
	infoMap, err := c.Info()
	if err != nil {
		return Metric{}, err
	}

	value, err := strconv.ParseFloat(infoMap["used_cpu_sys"], 64)
	if err != nil {
		return Metric{}, err
	}

	return Metric{"cpu_load", value, "load"}, nil
}
		})

		Describe(".Info", func() {
			var redis client.Client

			BeforeEach(func() {
				var err error
				redis, err = client.Connect(
					client.Host(host),
					client.Port(port),
				)
				Expect(err).ToNot(HaveOccurred())
			})

			It("does not return an error", func() {
				_, err := redis.Info()
				Expect(err).ToNot(HaveOccurred())
			})

			It("returns a map with multiple entries", func() {
				info, _ := redis.Info()
				Expect(len(info)).To(BeNumerically(">", 1))
			})

			It("returns a map that contains expected entries", func() {
				info, _ := redis.Info()
				Expect(info["aof_enabled"]).To(Equal("0"))
			})
		})

		Describe("querying info fields", func() {