diff options
author | Boris Giftge <bgiftge@kixeye.com> | 2014-10-15 15:01:53 -0700 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-10-19 23:16:57 +0200 |
commit | 371011cff23f5fef5c755a29430f8e8d0fef4263 (patch) | |
tree | b48a9da35629a2e61c470230b7f4989395939f03 /kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala | |
parent | 51def4163a909bd4677795741f844fc757e1004e (diff) | |
download | Kamon-371011cff23f5fef5c755a29430f8e8d0fef4263.tar.gz Kamon-371011cff23f5fef5c755a29430f8e8d0fef4263.tar.bz2 Kamon-371011cff23f5fef5c755a29430f8e8d0fef4263.zip |
= system-metrics: handling sigar.getLoadAverage gracefully on unsupported systems
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala')
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala | 12 |
1 files changed, 9 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 36e62756..607ebe13 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 @@ -22,7 +22,7 @@ import java.util import java.util.logging.Logger import java.util.{ ArrayList, Date, List } -import org.hyperic.sigar.{ OperatingSystem, Sigar, SigarProxy } +import org.hyperic.sigar._ import scala.annotation.tailrec import scala.collection.JavaConversions._ @@ -137,8 +137,14 @@ object SigarLoader { val os = OperatingSystem.getInstance def loadAverage(sigar: Sigar) = { - val average = sigar.getLoadAverage - (average(0), average(1), average(2)) + try { + val average = sigar.getLoadAverage + (average(0), average(1), average(2)) + } catch { + case s: org.hyperic.sigar.SigarNotImplementedException ⇒ { + (0d, 0d, 0d) + } + } } def uptime(sigar: Sigar) = { |