blob: 0a5f6494520d73346fb629ebab911df5151fef8b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package kamon.system.sigar
import kamon.metric.GenericEntityRecorder
import kamon.metric.instrument.InstrumentFactory
import org.hyperic.sigar.Sigar
class CpuMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) with SigarMetric {
val user = histogram("cpu-user")
val system = histogram("cpu-system")
val Wait = histogram("cpu-wait")
val idle = histogram("cpu-idle")
val stolen = histogram("cpu-stolen")
def update(sigar: Sigar): Unit = {
val cpuPerc = sigar.getCpuPerc
user.record((cpuPerc.getUser * 100L).toLong)
system.record((cpuPerc.getSys * 100L).toLong)
Wait.record((cpuPerc.getWait * 100L).toLong)
idle.record((cpuPerc.getIdle * 100L).toLong)
stolen.record((cpuPerc.getStolen * 100L).toLong)
}
}
object CpuMetrics extends SigarMetricRecorderCompanion("cpu") {
def apply(instrumentFactory: InstrumentFactory): CpuMetrics =
new CpuMetrics(instrumentFactory)
}
|