How do I get the software/hardware information of a linux system (this has to work for Fedora, Ubuntu etc) in Ruby?
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).
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With