예제 #1
0
func (s sigarStatsCollector) GetCpuLoad() (load CpuLoad, err error) {
	l := sigar.LoadAverage{}
	err = l.Get()
	if err != nil {
		return
	}

	load.One = l.One
	load.Five = l.Five
	load.Fifteen = l.Fifteen

	return
}
예제 #2
0
func (p ubuntu) GetCpuLoad() (load CpuLoad, err error) {
	l := sigar.LoadAverage{}
	err = l.Get()
	if err != nil {
		return
	}

	load.One = l.One
	load.Five = l.Five
	load.Fifteen = l.Fifteen

	return
}
예제 #3
0
func (lm *LoadMetrics) Update() {

	load := sigar.LoadAverage{}

	err := load.Get()

	if err == nil {
		lm.One.Update(load.One)
		lm.Five.Update(load.Five)
		lm.Fifteen.Update(load.Fifteen)
	}

}
예제 #4
0
func (s sigarStatsCollector) GetCpuLoad() (load CpuLoad, err error) {
	l := sigar.LoadAverage{}
	err = l.Get()
	if err != nil {
		err = bosherr.WrapError(err, "Getting Sigar Load Average")
		return
	}

	load.One = l.One
	load.Five = l.Five
	load.Fifteen = l.Fifteen

	return
}
예제 #5
0
파일: statsd.go 프로젝트: speedland/agent
func postMetrics() error {
	var metrics = make(map[string]interface{})
	// Runtime Info
	metrics["agent.runtime.numcpu"] = runtime.NumCPU()
	metrics["agent.runtime.numgoroutine"] = runtime.NumGoroutine()

	// System Info
	avg := sigar.LoadAverage{}
	mem := sigar.Mem{}
	swap := sigar.Swap{}
	avg.Get()
	mem.Get()
	swap.Get()

	metrics["agent.system.loadavg.one"] = avg.One
	metrics["agent.system.loadavg.five"] = avg.Five
	metrics["agent.system.loadavg.fifteen"] = avg.Fifteen
	metrics["agent.system.mem.total"] = mem.Total
	metrics["agent.system.mem.used"] = mem.Used
	metrics["agent.system.mem.free"] = mem.Free
	metrics["agent.system.mem.actual_used"] = mem.ActualUsed
	metrics["agent.system.mem.actual_free"] = mem.ActualFree
	metrics["agent.system.swap.total"] = swap.Total
	metrics["agent.system.swap.used"] = swap.Used
	metrics["agent.system.swap.free"] = swap.Free

	// Disk Info
	fslist := sigar.FileSystemList{}
	fslist.Get()
	for _, fs := range fslist.List {
		if strings.HasPrefix(fs.DevName, "/") {
			dirname := fs.DirName
			usage := sigar.FileSystemUsage{}
			usage.Get(dirname)
			metrics[fmt.Sprintf("agent.disk.%s.total", dirname)] = usage.Total
			metrics[fmt.Sprintf("agent.disk.%s.used", dirname)] = usage.Used
			metrics[fmt.Sprintf("agent.disk.%s.avail", dirname)] = usage.Avail
			metrics[fmt.Sprintf("agent.disk.%s.used_percent", dirname)] = usage.UsePercent()
		}
	}

	if client, err := models.NewCounterClient(nil); err != nil {
		return err
	} else {
		return client.PostMany("statsd", metrics)
	}
}