Sha256: 7bc6dfb65dccf9935a2af118ddb15c045c0ca791fcb2fd214a804ae6a07976ec

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

module Adminix
  module Entities
    class SysloadStamp

      attr_reader :memory_usage_mb, :cpu_load_percents, :disk_usage_mb,
                  :temperature, :created_at

      def initialize
        create_stamp
        @created_at = Time.now
      end

      def create_stamp
        case Adminix.os
        when 'linux'
          @memory_usage_mb, = Helpers::Command.debian_memory_load
          @cpu_load_percents = Helpers::Command.debian_cpu_load
          @disk_usage_mb, = Helpers::Command.debian_disk_usage
          @temperature = Helpers::Command.debian_temperature
        when 'mac'
          @cpu_load_percents = Helpers::Command.darwin_cpu_load
          @disk_usage_mb, = Helpers::Command.darwin_disk_usage
        end
      end

      def to_api
        {
          memory: memory_usage_mb,
          cpu: cpu_load_percents,
          disk: disk_usage_mb,
          temperature: temperature,
          created_at: created_at
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adminix-0.2 lib/adminix/entities/sysload_stamp.rb