Exemple #1
0
// NewPerDiskStat registers with metriccontext for a particular disk (block device)
func NewPerDiskStat(m *metrics.MetricContext, blkdev string) *PerDiskStat {
	s := new(PerDiskStat)
	s.Name = blkdev
	// initialize all metrics and register them
	misc.InitializeMetrics(s, m, "diskstat."+blkdev, true)
	return s
}
Exemple #2
0
// NewPerCPU returns a struct representing counters for
// per CPU statistics
func NewPerCPU(m *metrics.MetricContext, name string) *PerCPU {
	o := new(PerCPU)

	// initialize all metrics and register them
	misc.InitializeMetrics(o, m, "cpustat."+name, true)
	return o
}
// NewPerInterfaceStat initializes and registers metrics with metriccontext
// for an interface
func NewPerInterfaceStat(m *metrics.MetricContext, dev string) *PerInterfaceStat {
	c := new(PerInterfaceStat)
	c.Name = dev
	c.Metrics = new(PerInterfaceStatMetrics)
	// initialize all metrics and register them
	misc.InitializeMetrics(c.Metrics, m, "interfacestat."+dev, true)
	return c
}
Exemple #4
0
// NewPerFSStat registers with metriccontext for the particular filesystem
func NewPerFSStat(m *metrics.MetricContext, mp string) *PerFSStat {
	fs := new(PerFSStat)
	fs.m = m
	fs.mp = mp
	fs.Name = mp
	misc.InitializeMetrics(fs, m, "fsstat."+mp, true)
	return fs
}
Exemple #5
0
// New starts metrics collection every Step and registers with
// metricscontext
func New(m *metrics.MetricContext, Step time.Duration) *TCPStat {
	s := new(TCPStat)
	s.m = m
	s.Extended = new(ExtendedMetrics)
	// initialize all metrics and register them
	misc.InitializeMetrics(s, m, "tcpstat", true)
	misc.InitializeMetrics(s.Extended, m, "tcpstat.ext", true)
	// collect once
	s.Collect()
	// collect metrics every Step
	ticker := time.NewTicker(Step)
	go func() {
		for _ = range ticker.C {
			s.Collect()
		}
	}()
	return s
}
Exemple #6
0
//checks for initialization of lock mode metrics
func (s *PostgresStat) checkMode(name string) {
	s.modeLock.Lock()
	if _, ok := s.Modes[name]; !ok {
		o := new(ModeMetrics)
		misc.InitializeMetrics(o, s.m, "postgresstat.lock"+name, true)
		s.Modes[name] = o
	}
	s.modeLock.Unlock()
}
Exemple #7
0
// PerCPUNew returns a struct representing counters for
// per CPU statistics
func PerCPUNew(m *metrics.MetricContext, cpu string) *PerCPU {
	o := new(PerCPU)
	// 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
}
Exemple #8
0
//checks for intialization of table metrics
func (s *PostgresStat) checkTable(dbname, tblname string) {
	s.checkDB(dbname)
	s.dbLock.Lock()
	if _, ok := s.DBs[dbname].Tables[tblname]; !ok {
		o := new(TableMetrics)
		misc.InitializeMetrics(o, s.m, "postgresstat."+dbname+"."+tblname, true)
		s.DBs[dbname].Tables[tblname] = o
	}
	s.dbLock.Unlock()
}
Exemple #9
0
//checks for initialization of db metrics
func (s *PostgresStat) checkDB(dbname string) {
	s.dbLock.Lock()
	if _, ok := s.DBs[dbname]; !ok {
		o := new(DBMetrics)
		o.Tables = make(map[string]*TableMetrics)
		misc.InitializeMetrics(o, s.m, "postgresstat."+dbname, true)
		s.DBs[dbname] = o
	}
	s.dbLock.Unlock()
}
// NewPerCgroupStat registers with metriccontext for a particular cgroup
func NewPerCgroupStat(m *metrics.MetricContext, path string, mp string) *PerCgroupStat {
	c := new(PerCgroupStat)
	c.m = m
	c.path = path
	rel, _ := filepath.Rel(mp, path)
	// initialize all metrics and register them
	c.prefix = "memstat.cgroup." + rel
	misc.InitializeMetrics(c, m, c.prefix, true)
	return c
}
Exemple #11
0
// NewPerProcessStatMetrics registers with metricscontext
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
}
Exemple #12
0
// New starts metrics collection every Step and registers with
// metricscontext
func New(m *metrics.MetricContext, Step time.Duration) *LoadStat {
	s := new(LoadStat)
	s.m = m
	// initialize all metrics and register them
	misc.InitializeMetrics(s, m, "loadstat", true)
	// collect once
	s.Collect()
	// collect metrics every Step
	ticker := time.NewTicker(Step)
	go func() {
		for _ = range ticker.C {
			s.Collect()
		}
	}()
	return s
}
Exemple #13
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
}
Exemple #14
0
// NewPerProcessStatMetrics registers with metricscontext
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
}
Exemple #15
0
// Initialize per user metrics
func newMysqlStatPerUser(m *metrics.MetricContext, user string) *MysqlStatPerUser {
	o := new(MysqlStatPerUser)
	misc.InitializeMetrics(o, m, "mysqlstat."+user, true)
	return o
}
Exemple #16
0
// MysqlStatMetricsNew initializes metrics and registers with metriccontext
func MysqlStatMetricsNew(m *metrics.MetricContext) *MysqlStatMetrics {
	c := new(MysqlStatMetrics)
	misc.InitializeMetrics(c, m, "mysqlstat", true)
	return c
}
Exemple #17
0
// PostgresStatMetricsNew initializes PostgresStatMetrics
func PostgresStatMetricsNew(m *metrics.MetricContext) *PostgresStatMetrics {
	c := new(PostgresStatMetrics)
	misc.InitializeMetrics(c, m, "postgresstat", true)
	return c
}