diff options
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/system')
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala | 5 | ||||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala | 29 |
2 files changed, 29 insertions, 5 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala index 31963487..725f634d 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala @@ -64,9 +64,10 @@ class SystemMetricsCollector(collectInterval: FiniteDuration) extends Actor with private def recordProcessCpu(pcpur: ProcessCPUMetricsRecorder) = { val procCpu = sigar.getProcCpu(pid) + val procTime = sigar.getProcTime(pid) - pcpur.user.record(procCpu.getUser) - pcpur.system.record(procCpu.getSys) + pcpur.cpuPercent.record(toLong(procCpu.getPercent)) + pcpur.totalProcessTime.record(procTime.getTotal) // gives an idea of what is really measured and then interpreted as % } private def recordMemory(mr: MemoryMetricRecorder) = { diff --git a/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala index af49fca5..36e62756 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala @@ -142,10 +142,33 @@ object SigarLoader { } def uptime(sigar: Sigar) = { - val sdf = new SimpleDateFormat("yyyy-MM-dd") + def formatUptime(uptime: Double): String = { + var retval: String = "" + val days: Int = uptime.toInt / (60 * 60 * 24) + var minutes: Int = 0 + var hours: Int = 0 + + if (days != 0) { + retval += s"$days ${(if ((days > 1)) "days" else "day")}, " + } + + minutes = uptime.toInt / 60 + hours = minutes / 60 + hours %= 24 + minutes %= 60 + + if (hours != 0) { + retval += hours + ":" + minutes + } else { + retval += minutes + " min" + } + retval + } + val uptime = sigar.getUptime val now = System.currentTimeMillis() - sdf.format(new Date(now - (uptime.getUptime() * 1000).toLong)) + + s"up ${formatUptime(uptime.getUptime())}" } val message = @@ -162,7 +185,7 @@ object SigarLoader { | | [System Status] [OS Information] | |--------------------------------| |----------------------------------------| - | Boot Time: %-10s Description: %s + | Up Time: %-10s Description: %s | Load Average: %-16s Name: %s | Version: %s | Arch: %s |