How do I get the software/hardware information of a linux system (this has to work for Fedora, Ubuntu etc) in Ruby?
How do I get linux system information in Ruby
7.2k views Asked by jrg At
3
There are 3 answers
1
On
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
0
On
You could try the sys-uname gem, which provides some access to OS information. That guy also has a few other gems for other system info, like cpu, user groups, etc.
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).