Sha256: 47ff29385dca81d9d13948c85a249fbe83ed0429a89bd3d4e4526e2971a56ff9

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

require 'sys/filesystem'

collect do
  Sys::Filesystem.mounts do |mount|
    st = Sys::Filesystem.stat(mount.mount_point)
    next if st.blocks == 0 or st.files == 0

    case mp = mount.mount_point
    when '/'
      'rootfs'
    when /^\/.+$/
      mp[1..-1].tr('^[a-z][0-9]', '-')
    else
      'unknown'
    end.tap do |name|
      next if config.exclude.map {|e| Regexp.new(e).match(name)}.any?

      block_pc = 1.0 - (st.blocks_free.to_f / st.blocks.to_f)
      sampler.emit(:gauge, "os.disk.#{name}.blocks", block_pc)

      files_pc = 1.0 - (st.files_free.to_f / st.files.to_f)
      sampler.emit(:gauge, "os.disk.#{name}.files", files_pc)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ganymed-0.3.4 lib/ganymed/collectors/disk.rb
ganymed-0.3.3 lib/ganymed/collectors/disk.rb
ganymed-0.3.2 lib/ganymed/collectors/disk.rb