예제 #1
0
// New registers with metriccontext and starts metric collection
// every Step
func New(m *metrics.MetricContext, Step time.Duration) *MemStat {
	s := new(MemStat)
	s.m = m
	// initialize all gauges
	misc.InitializeMetrics(s, m, "memstat", true)

	host := C.mach_host_self()
	C.host_page_size(C.host_t(host), &s.Pagesize)

	// collect metrics every Step
	ticker := time.NewTicker(Step)
	go func() {
		for _ = range ticker.C {
			s.Collect()
		}
	}()

	return s
}
예제 #2
0
func MemStatMetricsNew(m *metrics.MetricContext, Step time.Duration) *MemStatMetrics {
	c := new(MemStatMetrics)

	// initialize all gauges
	misc.InitializeMetrics(c, m, "memstat")

	host := C.mach_host_self()
	C.host_page_size(C.host_t(host), &c.Pagesize)

	// collect metrics every Step
	ticker := time.NewTicker(Step)
	go func() {
		for _ = range ticker.C {
			c.Collect()
		}
	}()

	return c
}
예제 #3
0
func (h Host) Pagesize() int {
	var page_size C.vm_size_t
	_ = C.host_page_size(C.host_t(h), &page_size)
	return int(page_size)
}