diff options
author | Diego <diegolparra@gmail.com> | 2014-08-16 23:13:56 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-08-16 23:13:56 -0300 |
commit | 92a258f5f5e54cde7c7c85bfd76a2f9d7c532551 (patch) | |
tree | 644f83355041021b3ed7a1e342bf50a740880ad5 /kamon-system-metrics/src/main/scala/kamon/system/sigar | |
parent | 9fe3750f7cf8b3a85f7db8ebd1cc8daff097935e (diff) | |
download | Kamon-92a258f5f5e54cde7c7c85bfd76a2f9d7c532551.tar.gz Kamon-92a258f5f5e54cde7c7c85bfd76a2f9d7c532551.tar.bz2 Kamon-92a258f5f5e54cde7c7c85bfd76a2f9d7c532551.zip |
+ log-reporter: include Process Cpu metrics and closes #72
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/system/sigar')
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala | 29 |
1 files changed, 26 insertions, 3 deletions
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 |