Exemplo n.º 1
0
func (c *Container) network() {
	pn := c.prevStats.Network
	n := c.stats.Network

	c.dropper.Drop(report.NewReport("Net.Rx.Bytes",
		fmt.Sprintf("%d", n.RxBytes-pn.RxBytes), c.stats.Read))
	c.dropper.Drop(report.NewReport("Net.Tx.Bytes",
		fmt.Sprintf("%d", n.TxBytes-pn.TxBytes), c.stats.Read))
}
Exemplo n.º 2
0
func (c *Container) cpu() {
	var (
		previousCPU    uint64 = c.prevStats.CPUStats.CPUUsage.TotalUsage
		previousSystem uint64 = c.prevStats.CPUStats.SystemCPUUsage
		cpuPercent            = 0.0
		cpuDelta              = float64(c.stats.CPUStats.CPUUsage.TotalUsage - previousCPU)
		systemDelta           = float64(c.stats.CPUStats.SystemCPUUsage - previousSystem)
	)

	if systemDelta > 0.0 && cpuDelta > 0.0 {
		cpuPercent = (cpuDelta / systemDelta) * float64(
			len(c.stats.CPUStats.CPUUsage.PercpuUsage)) * 100.0
	}

	c.dropper.Drop(report.NewReport("Cpu.Percent",
		fmt.Sprintf("%f", cpuPercent), c.stats.Read))
}
Exemplo n.º 3
0
func (c *Container) mem() {
	m := c.stats.MemoryStats
	c.dropper.Drop(report.NewReport("Mem.Usage",
		fmt.Sprintf("%d", m.Usage), c.stats.Read))
}
Exemplo n.º 4
0
func (c *Container) Emit(when time.Time, what string) {
	a := report.NewMetaReporter([]string{what}, c.annotator)
	go a.Drop(report.NewReport(c.name, what, when))
}