Sha256: e20e2e287554dd4bd74e7e2e2b16d5c670d10b9c371061e4a091512ab8a3d59f

Contents?: true

Size: 475 Bytes

Versions: 7

Compression:

Stored size: 475 Bytes

Contents

# frozen_string_literal: true

require 'ffi'

module Facter
  module Bsd
    module FfiHelper
      module Libc
        extend FFI::Library

        ffi_lib 'c'
        attach_function :getloadavg, %i[pointer int], :int
      end

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

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

        raw_loadavg.read_array_of_double(res)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facter-4.0.26 lib/resolvers/bsd/ffi/ffi_helper.rb
facter-4.0.25 lib/resolvers/bsd/ffi/ffi_helper.rb
facter-4.0.24 lib/resolvers/bsd/ffi/ffi_helper.rb
facter-4.0.23 lib/resolvers/bsd/ffi/ffi_helper.rb
facter-4.0.22 lib/resolvers/bsd/ffi/ffi_helper.rb
facter-4.0.21 lib/resolvers/bsd/ffi/ffi_helper.rb
facter-4.0.20 lib/resolvers/bsd/ffi/ffi_helper.rb