How do I get the software/hardware information of a linux system (this has to work for Fedora, Ubuntu etc) in Ruby?
Asked
Active
Viewed 7,126 times
3 Answers
12
The wonderful people behind Chef, have an excellent gem called Ohai https://github.com/opscode/ohai that returns system info such as OS, kernel, specs, fqdn, disks, space, memory, users, interfaces, ssh keys etc. as a hash. It is quite complete and very good. It also installs a command line binary (also called ohai).

Erik Hinton
- 1,948
- 10
- 15
6
You could try the sysinfo gem. If that doesn't work you might be able to try making a system call, parse the output, and then call the relevant command to get further information.
For example, on OS X, uname -a
gives me the following output, which then allows me to know what other distro-specific commands are likely available.
$ uname -a
Darwin [machine-name].local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64
-
1For that `uname -s` is often sufficient (or `RUBY_PLATFORM` inside Ruby) :-) – Michael Kohl Oct 24 '11 at 22:35