Skip to content
/ sysinfo Public

All your system-independent infoz in one handy (Ruby) class

License

Notifications You must be signed in to change notification settings

delano/sysinfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SysInfo - v0.10

All your system-independent infoz in one handy class.

SysInfo does a takes a very quick glance at the system it's running on and exposes the results as YAML, JSON, CSV, or TSV. It also determines a platform identifier for the system that takes the form: VM-OS-IMPLEMENTATION-ARCHITECTURE.

Platform Identifier Examples

  • ruby-unix-osx-arm64
  • ruby-unix-osx-x86_64
  • ruby-unix-linux-x86_64
  • java-win32-windows-x86_64
  • java-win32-mingw-ia64

For the complete list of operating systems, implementations and architectures that SysInfo is aware of, see:

  • $ sysinfo os
  • $ sysinfo impl
  • $ sysinfo arch

Usage -- Library

sysinfo = SysInfo.new
sysinfo.vm                    # => ruby
sysinfo.os                    # => unix
sysinfo.impl                  # => osx
sysinfo.arch                  # => i386
sysinfo.platform              # => ruby-unix
sysinfo.to_s                  # => ruby-unix-osx-i386

sysinfo.user                  # => delano
sysinfo.home                  # => /Users/delano
sysinfo.uptime                # => 290.429              (hours)
sysinfo.shell                 # => /bin/bash
sysinfo.paths                 # => [/sbin, /bin, /usr/bin, ...]

sysinfo.hostname              # => walter
sysinfo.ipaddress_internal    # => 10.0.1.2
sysinfo.uptime                # => 290.573655656974
sysinfo.ruby                  # => [1,9,1]

Usage -- Executable

  $ sysinfo
  ruby-unix-osx-i386

  $ /usr/jruby/bin/sysinfo
  java-unix-osx-x86_64

  $ sysinfo -f yaml
  :vm: :ruby
  :os: :unix
  :impl: :osx
  ...
  :shell: :"/bin/bash"
  :user: delano

  $ sysinfo -f json
  {"vm":"ruby","os":"unix","impl":"osx", ..., "shell":"\/bin\/bash","user":"delano"}

  $ sysinfo -f csv
  ruby,unix,osx, ... /bin/bash,delano

Installation

  $ sudo gem install sysinfo

Prerequisites

  • Ruby 3.0.2+
  • Ruby 2.6.8+
  • Ruby 1.9+
  • JRuby 1.2+
  • Storable