Sha256: d6574dc52d1eda888e8c48224ba889a63070337ec91b5cafbe4118bda931d28a
Contents?: true
Size: 1.88 KB
Versions: 8
Compression:
Stored size: 1.88 KB
Contents
# encoding: utf-8 module LocalPac module Actions class GetSystemInformation private attr_reader :options public def initialize(options = {}) @options = options end def run printf( "%#{max_field_length}s | %s\n", 'Information', 'Value') printf( "%s + %s\n", '-' * max_field_length, '-' * 40) data.sort_by { |key, value| key }.each { |key, value| printf( "%#{max_field_length}s | %s\n", key, value) } end private def data Timeout::timeout(10) do Facter.to_hash.keep_if { |key,_| fields.include?(key.to_s) } end rescue Timeout::Error LocalPac.ui_logger.warn 'Getting environment information took to long. Please make sure the name resolver is available. This might cause the latency.' {} end def max_field_length fields.inject(0) { |memo, f| memo = f.size if f.size > memo ; memo} end def fields %w[ architecture filesystems hardwareisa hardwaremodel is_virtual kernel kernelmajversion kernelrelease kernelversion memoryfree memoryfree_mb memorysize memorysize_mb memorytotal operatingsystem operatingsystemrelease osfamily path physicalprocessorcount processor0 processor1 processorcount ps rubysitedir rubyversion selinux swapfree swapfree_mb swapsize swapsize_mb timezone uptime uptime_days uptime_hours uptime_seconds virtual ] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems