Sha256: ebefcc3c4a9acc60cbc9fc0fc031108e43e4d74a6c951333f0414a20ff4570a1

Contents?: true

Size: 574 Bytes

Versions: 39

Compression:

Stored size: 574 Bytes

Contents

# frozen_string_literal: true

require 'ffi'

module Facter
  module Util
    module Resolvers
      module Ffi
        module LoadAverages
          extend ::FFI::Library
          ffi_lib ::FFI::Library::LIBC

          attach_function :getloadavg, %i[pointer int], :int

          def self.read_load_averages
            raw_loadavg = ::FFI::MemoryPointer.new(:double, 3)

            res = LoadAverages.getloadavg(raw_loadavg, 3)
            return unless res == 3

            raw_loadavg.read_array_of_double(res)
          end
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
facter-4.10.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.9.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.8.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.7.1 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.7.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.6.1 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.6.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.5.2 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.5.1 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.5.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.4.3 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.4.2 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.4.1 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.4.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.3.1 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.3.0 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.2.14 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.2.13 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.2.12 lib/facter/util/resolvers/ffi/load_averages.rb
facter-4.2.11 lib/facter/util/resolvers/ffi/load_averages.rb