Beispiel #1
0
func NewPerFSStat(m *metrics.MetricContext, mp string) *PerFSStat {
	c := new(PerFSStat)
	c.mp = mp
	c.Metrics = new(PerFSStatMetrics)
	misc.InitializeMetrics(c.Metrics, m, "fsstat."+mp, true)
	return c
}
Beispiel #2
0
func NewPerInterfaceStat(m *metrics.MetricContext, dev string) *PerInterfaceStat {
	c := new(PerInterfaceStat)
	c.Metrics = new(PerInterfaceStatMetrics)
	// initialize all metrics and register them
	misc.InitializeMetrics(c.Metrics, m, "interfacestat."+dev, true)
	return c
}
Beispiel #3
0
// NewCPUStatPerCPU returns a struct representing counters for
// per CPU statistics
func NewCPUStatPerCPU(m *metrics.MetricContext, name string) *CPUStatPerCPU {
	o := new(CPUStatPerCPU)

	// initialize all metrics and register them
	misc.InitializeMetrics(o, m, "cpustat."+name, true)
	return o
}
Beispiel #4
0
func NewPerDiskStat(m *metrics.MetricContext, blkdev string) *PerDiskStat {
	c := new(PerDiskStat)
	c.Metrics = new(PerDiskStatMetrics)
	// initialize all metrics and register them
	misc.InitializeMetrics(c.Metrics, m, "diskstat."+blkdev, true)
	return c
}
Beispiel #5
0
// CPUStatPerCPUNew returns a struct representing counters for
// per CPU statistics
func CPUStatPerCPUNew(m *metrics.MetricContext, cpu string) *CPUStatPerCPU {
	o := new(CPUStatPerCPU)
	// initialize metrics and register
	// XXX: need to adopt it to similar to linux and pass
	// cpu name as argument when we are collecting per cpu
	// information
	misc.InitializeMetrics(o, m, "cpustat.cpu", true)
	return o
}
Beispiel #6
0
func NewPerProcessStatMetrics(m *metrics.MetricContext, pid string) *PerProcessStatMetrics {
	s := new(PerProcessStatMetrics)
	s.Pid = pid

	// initialize all metrics
	misc.InitializeMetrics(s, m, "IGNORE")

	return s
}
func NewPerCgroupStatMetrics(m *metrics.MetricContext, path string, mp string) *PerCgroupStatMetrics {
	c := new(PerCgroupStatMetrics)
	c.path = path

	// initialize all metrics and register them
	prefix, _ := filepath.Rel(mp, path)
	misc.InitializeMetrics(c, m, "cpustat.cgroup."+prefix, true)

	return c
}
Beispiel #8
0
func NewPerProcessStatMetrics(m *metrics.MetricContext, pid string) *PerProcessStatMetrics {
	s := new(PerProcessStatMetrics)
	s.Pid = pid
	s.m = m

	// initialize all metrics but do NOT register them
	// registration happens if the objects pass user
	// supplied filter
	misc.InitializeMetrics(s, m, "IGNORE", false)

	return s
}
func NewPerCgroupStatMetrics(m *metrics.MetricContext,
	path string, mp string) *PerCgroupStatMetrics {

	c := new(PerCgroupStatMetrics)
	c.path = path

	prefix, _ := filepath.Rel(mp, path)
	// initialize all metrics
	misc.InitializeMetrics(c, m, "memstat.cgroup."+prefix)

	return c
}
Beispiel #10
0
func MemStatMetricsNew(m *metrics.MetricContext, Step time.Duration) *MemStatMetrics {
	c := new(MemStatMetrics)

	misc.InitializeMetrics(c, m, "memstat")

	// collect once
	c.Collect()

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

	return c
}
Beispiel #11
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
}
Beispiel #12
0
//initializes metrics
func MysqlStatMetricsNew(m *metrics.MetricContext, Step time.Duration) *MysqlStatMetrics {
	c := new(MysqlStatMetrics)
	misc.InitializeMetrics(c, m, "mysqlstat", true)
	return c
}
Beispiel #13
0
// NewCPUStatPerCPU returns a struct representing counters for
// per CPU statistics
func NewCPUStatPerCPU(m *metrics.MetricContext, name string) *CPUStatPerCPU {
	o := new(CPUStatPerCPU)

	misc.InitializeMetrics(o, m, "cpustat."+name)
	return o
}
Beispiel #14
0
func NewPerDiskStat(m *metrics.MetricContext, blkdev string) *PerDiskStat {
	c := new(PerDiskStat)
	c.Metrics = new(PerDiskStatMetrics)
	misc.InitializeMetrics(c.Metrics, m, "diskstat."+blkdev)
	return c
}
Beispiel #15
0
func NewPerProcessStatMetrics(m *metrics.MetricContext, pid string) *PerProcessStatMetrics {
	s := new(PerProcessStatMetrics)
	// initialize all metrics
	misc.InitializeMetrics(s, m, "pidstat."+pid)
	return s
}
Beispiel #16
0
//initialize  per database metrics
func newMysqlStatPerDB(m *metrics.MetricContext, dbname string) *MysqlStatPerDB {
	o := new(MysqlStatPerDB)
	misc.InitializeMetrics(o, m, "mysqldbstat."+dbname, true)
	return o
}
Beispiel #17
0
//initialize per table metrics
func newMysqlStatPerTable(m *metrics.MetricContext, dbname, tblname string) *MysqlStatPerTable {
	o := new(MysqlStatPerTable)

	misc.InitializeMetrics(o, m, "mysqltablestat."+dbname+"."+tblname, true)
	return o
}
Beispiel #18
0
// CPUStatPerCPUNew returns a struct representing counters for
// per CPU statistics
func CPUStatPerCPUNew(m *metrics.MetricContext, cpu string) *CPUStatPerCPU {
	o := new(CPUStatPerCPU)
	misc.InitializeMetrics(o, m, "cpustat."+cpu)
	return o
}
Beispiel #19
0
func NewPerProcessStatMetrics(m *metrics.MetricContext, pid string) *PerProcessStatMetrics {
	s := new(PerProcessStatMetrics)
	// initialize all metrics and do NOT register for now
	misc.InitializeMetrics(s, m, "pidstat.", false)
	return s
}
func NewPerInterfaceStat(m *metrics.MetricContext, dev string) *PerInterfaceStat {
	c := new(PerInterfaceStat)
	c.Metrics = new(PerInterfaceStatMetrics)
	misc.InitializeMetrics(c.Metrics, m, "interfacestat."+dev)
	return c
}