Sha256: b03fc0835959a657df6008ee75ebb319587b02c0d4b56729d4181fae79314f46

Contents?: true

Size: 676 Bytes

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
ganymed-0.4.3 lib/ganymed/collectors/disk.rb