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.
- 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
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]
$ 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
$ sudo gem install sysinfo
- Ruby 3.0.2+
- Ruby 2.6.8+
- Ruby 1.9+
- JRuby 1.2+
- Storable