aboutsummaryrefslogtreecommitdiff
path: root/kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala')
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala12
1 files changed, 6 insertions, 6 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala
index d34b6415..28e40469 100644
--- a/kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala
+++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/FileSystemMetrics.scala
@@ -5,23 +5,23 @@ import kamon.metric.instrument.{ Memory, InstrumentFactory }
import org.hyperic.sigar.{ DiskUsage, FileSystem, Sigar }
import scala.util.Try
-class FileSystemMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) with SigarMetric {
+class FileSystemMetrics(sigar: Sigar, instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) with SigarMetric {
val reads = DiffRecordingHistogram(histogram("file-system-reads", Memory.Bytes))
val writes = DiffRecordingHistogram(histogram("file-system-writes", Memory.Bytes))
+ val fileSystems = sigar.getFileSystemList.filter(_.getType == FileSystem.TYPE_LOCAL_DISK).map(_.getDevName).toSet
+
def sumOfAllFileSystems(sigar: Sigar, thunk: DiskUsage ⇒ Long): Long = Try {
- val fileSystems = sigar.getFileSystemList.filter(_.getType == FileSystem.TYPE_LOCAL_DISK).map(_.getDevName).toSet
fileSystems.map(i ⇒ thunk(sigar.getDiskUsage(i))).fold(0L)(_ + _)
-
} getOrElse (0L)
- def update(sigar: Sigar): Unit = {
+ def update(): Unit = {
reads.record(sumOfAllFileSystems(sigar, _.getReadBytes))
writes.record(sumOfAllFileSystems(sigar, _.getWriteBytes))
}
}
object FileSystemMetrics extends SigarMetricRecorderCompanion("file-system") {
- def apply(instrumentFactory: InstrumentFactory): FileSystemMetrics =
- new FileSystemMetrics(instrumentFactory)
+ def apply(sigar: Sigar, instrumentFactory: InstrumentFactory): FileSystemMetrics =
+ new FileSystemMetrics(sigar, instrumentFactory)
}