コード例 #1
0
ファイル: helper.go プロジェクト: ruflin/beats
func (n *NetService) getNetworkStats(nameInterface string, rawNetStats *dc.NetworkStats, myRawstats *docker.Stat) NetStats {
	newNetworkStats := createNetRaw(myRawstats.Stats.Read, rawNetStats)
	oldNetworkStat, exist := n.NetworkStatPerContainer[myRawstats.Container.ID][nameInterface]

	netStats := NetStats{
		Container:     docker.NewContainer(&myRawstats.Container),
		Time:          myRawstats.Stats.Read,
		NameInterface: nameInterface,
	}

	if exist {
		netStats.RxBytes = n.getRxBytesPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.RxDropped = n.getRxDroppedPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.RxErrors = n.getRxErrorsPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.RxPackets = n.getRxPacketsPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.TxBytes = n.getTxBytesPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.TxDropped = n.getTxDroppedPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.TxErrors = n.getTxErrorsPerSecond(&newNetworkStats, &oldNetworkStat)
		netStats.TxPackets = n.getTxPacketsPerSecond(&newNetworkStats, &oldNetworkStat)
	} else {
		n.NetworkStatPerContainer[myRawstats.Container.ID] = make(map[string]NetRaw)
	}

	n.NetworkStatPerContainer[myRawstats.Container.ID][nameInterface] = newNetworkStats

	return netStats
}
コード例 #2
0
ファイル: helper.go プロジェクト: andrewkroh/beats
func (c *CPUService) getCpuStats(myRawStat *docker.DockerStat) CPUStats {

	return CPUStats{
		Time:              common.Time(myRawStat.Stats.Read),
		Container:         docker.NewContainer(&myRawStat.Container),
		PerCpuUsage:       c.perCpuUsage(&myRawStat.Stats),
		TotalUsage:        c.totalUsage(&myRawStat.Stats),
		UsageInKernelmode: c.usageInKernelmode(&myRawStat.Stats),
		UsageInUsermode:   c.usageInUsermode(&myRawStat.Stats),
	}
}
コード例 #3
0
ファイル: helper.go プロジェクト: ruflin/beats
func (s *MemoryService) GetMemoryStats(myRawStat docker.Stat) MemoryData {
	return MemoryData{
		Time:      common.Time(myRawStat.Stats.Read),
		Container: docker.NewContainer(&myRawStat.Container),
		Failcnt:   myRawStat.Stats.MemoryStats.Failcnt,
		Limit:     myRawStat.Stats.MemoryStats.Limit,
		MaxUsage:  myRawStat.Stats.MemoryStats.MaxUsage,
		TotalRss:  myRawStat.Stats.MemoryStats.Stats.TotalRss,
		TotalRssP: float64(myRawStat.Stats.MemoryStats.Stats.TotalRss) / float64(myRawStat.Stats.MemoryStats.Limit),
		Usage:     myRawStat.Stats.MemoryStats.Usage,
		UsageP:    float64(myRawStat.Stats.MemoryStats.Usage) / float64(myRawStat.Stats.MemoryStats.Limit),
	}
}
コード例 #4
0
ファイル: helper.go プロジェクト: ruflin/beats
func (c *CPUService) getCpuStats(myRawStat *docker.Stat) CPUStats {

	return CPUStats{
		Time:                        common.Time(myRawStat.Stats.Read),
		Container:                   docker.NewContainer(&myRawStat.Container),
		PerCpuUsage:                 perCpuUsage(&myRawStat.Stats),
		TotalUsage:                  totalUsage(&myRawStat.Stats),
		UsageInKernelmode:           myRawStat.Stats.CPUStats.CPUUsage.UsageInKernelmode,
		UsageInKernelmodePercentage: usageInKernelmode(&myRawStat.Stats),
		UsageInUsermode:             myRawStat.Stats.CPUStats.CPUUsage.UsageInUsermode,
		UsageInUsermodePercentage:   usageInUsermode(&myRawStat.Stats),
		SystemUsage:                 myRawStat.Stats.CPUStats.SystemCPUUsage,
		SystemUsagePercentage:       systemUsage(&myRawStat.Stats),
	}
}
コード例 #5
0
ファイル: helper.go プロジェクト: ruflin/beats
func (io *BLkioService) getBlkioStats(myRawStat *docker.Stat) BlkioStats {
	newBlkioStats := io.getNewStats(myRawStat.Stats.Read, myRawStat.Stats.BlkioStats.IOServicedRecursive)
	oldBlkioStats, exist := io.BlkioSTatsPerContainer[myRawStat.Container.ID]

	myBlkioStats := BlkioStats{
		Time:      myRawStat.Stats.Read,
		Container: docker.NewContainer(&myRawStat.Container),
	}

	if exist {
		myBlkioStats.reads = io.getReadPs(&oldBlkioStats, &newBlkioStats)
		myBlkioStats.writes = io.getWritePs(&oldBlkioStats, &newBlkioStats)
		myBlkioStats.totals = io.getReadPs(&oldBlkioStats, &newBlkioStats)
	} else {
		io.BlkioSTatsPerContainer = make(map[string]BlkioRaw)
	}

	io.BlkioSTatsPerContainer[myRawStat.Container.ID] = newBlkioStats

	return myBlkioStats
}