Sha256: bd435ff2782058ecf887717c3572044503d1de68bc1d6ef161ca954893b17e4e

Contents?: true

Size: 676 Bytes

Versions: 3

Compression:

Stored size: 676 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)
      Metriks.histogram("os.disk.#{name}.blocks").update(block_pc)

      files_pc = 1.0 - (st.files_free.to_f / st.files.to_f)
      Metriks.histogram("os.disk.#{name}.files").update(files_pc)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ganymed-0.4.2 lib/ganymed/collectors/disk.rb
ganymed-0.4.1 lib/ganymed/collectors/disk.rb
ganymed-0.4.0 lib/ganymed/collectors/disk.rb