# Collecting remote system information

**URL:** <https://www.ruby-forum.com/t/collecting-remote-system-information/113354>\
**Category:** Ruby\
**Created:** [August 30, 2007, 10:05am UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354 "2007-08-30T10:05:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 30, 2007, 10:05am UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354/1 "2007-08-30T10:05:35Z")

</div>

I am relatively new to coding and to ruby.

I have seen programs like IBM Director installs an agent on a client  
machine and gather all kinds of information remotely; eg. amount of  
ram, processor type and speed, machine type and serial number, OS  
running, netbios name etc.

Would it be possible to write something like this with ruby. Ideally,  
the ruby program will run on Fedora or OpenBSD and the clients are  
Windows XP machines. Once the program is being run it will ask for the  
Windows box’s user name and password to gather all the information and  
will dump it in STDOUT.

Any hints or tips on where to start looking to write something like  
this would be much appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 30, 2007, 3:54pm UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354/2 "2007-08-30T15:54:33Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Chris H. wrote:

> Windows box’s user name and password to gather all the information and  
> will dump it in STDOUT.
> 
> Any hints or tips on where to start looking to write something like  
> this would be much appreciated.
> 
> Thanks.

This is complicated enough that I’d recommend buying a package that  
already works rather than building something. This isn’t a particularly  
good beginner’s project, and I’m not sure how you’d test it. And I have  
concerns about anybody going off and asking for my user ID and password.  
_Real_ IT solutions just don’t work that way.

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.7 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFG1svp8fKMegVjSM8RAl8YAKDCpOTJc4MwLcuHpb5weZAy78BKRQCgnaA+  
v09+cu4cFJd4+goR+wCQDK0=  
=uLer  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 30, 2007, 5:38pm UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354/3 "2007-08-30T17:38:47Z")

</div>

Kyle S. wrote:

> There’s a MS command line app some where on the MSDN site (complete  
> with sample code) that can be used to gather lots of info for ms OSes  
> (no I don’t remember the name of the app, sorry), and then, depending  
> on the unicies you’re dealing with, data will be exposed by different  
> system calls or virtual file systems.
> 
> –Kyle

There are a couple of packages on RubyForge that are cross-platform Ruby  
libraries for returning some of the basic information about the  
system. The URL is: [http://rubyforge.org/projects/sysutils](http://rubyforge.org/projects/sysutils)

I just downloaded some of these for adding more information to one of  
the regular scripts that I run for gathering statistics about the  
running environment of some largely unattended scripts and to alert me  
if the status changes (mostly, I was interested in finding free disk  
space).

I’m not sure if these packages will give you something that helps.

Cheers,  
Mohit.  
8/30/2007 | 11:36 PM.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 30, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354/4 "2007-08-30T22:11:42Z")

</div>

On Aug 30, 7:36 am, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> system. The URL is:[http://rubyforge.org/projects/sysutils](http://rubyforge.org/projects/sysutils)  
> 8/30/2007 | 11:36 PM.  
> Also, what about the possibility of using something like  
> Puppet(because it’s ruby),CFengine or even Capistrano (also ruby)?

Mike B.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 30, 2007, 5:04pm UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354/5 "2007-08-30T17:04:43Z")

</div>

I’ve worked on some projects before for this sort of thing, and Ed is  
right.

It’s not pretty.

The only way to do it without really mucking about on each system is  
to get the data in the system-specific format, then munge it together  
into whatever global format you design.

This means writing system specific code for … well each system to  
test.

There’s a MS command line app some where on the MSDN site (complete  
with sample code) that can be used to gather lots of info for ms OSes  
(no I don’t remember the name of the app, sorry), and then, depending  
on the unicies you’re dealing with, data will be exposed by different  
system calls or virtual file systems.

–Kyle

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 31, 2007, 12:21am UTC](https://www.ruby-forum.com/t/collecting-remote-system-information/113354/6 "2007-08-31T00:21:02Z")

</div>

On Aug 30, 1:04 am, “Chris H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Windows box’s user name and password to gather all the information and  
> will dump it in STDOUT.
> 
> Any hints or tips on where to start looking to write something like  
> this would be much appreciated.
> 
> Thanks.

If your program is running on a Windows computer, it’s actually pretty  
easy to get reams of information from remote Windows computers.  
Windows Management Instrumentation (WMUI), part of Microsoft’s  
implementation of the Web-based Enterprise Management (WBEM) standard,  
is built in to all Windows versions since Windows 2000, I think, and  
it can be added onto Windows 98. To query remote computers, you have  
to be a member of a security group that includes local administrator  
authority for the remote computers, e.g. domain admins. If you’re not  
a member of such a group, you probably shouldn’t be querying those  
computers. Using WMI, you can collect far more information than is  
practical to display to the terminal.

To get an idea of the information that’s available, download  
Microsoft’s Scriptomatic 2.0 at  
[http://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&DisplayLang=en](http://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&DisplayLang=en)  
and run some of the built-in queries on your own computer.  
Scriptomatic generate scripts in VB Script and Perl, among others, and  
it’s not hard to translate them to ruby once you know how. In ruby,  
the basic WMI calls are executed with win320le. Take a look at the  
example programs [http://snippets.dzone.com/posts/show/4280](http://snippets.dzone.com/posts/show/4280) and  
[Ruby on Windows: Using Ruby & WMI to Detect a USB Drive](http://rubyonwindows.blogspot.com/2007/06/using-ruby-wmi-to-detect-usb-drive.html).  
[Ruby on Windows: From VB to Ruby - Creating Objects via COM](http://rubyonwindows.blogspot.com/2007/02/from-vb-to-ruby-creating-objects-via.html)  
explains some of the basic translations from vbscript to win32ole in  
ruby. There’s a lot of other helpful information at  
[http://rubyonwindows.blogspot.com](http://rubyonwindows.blogspot.com)  
showing you how to interface to other Microsoft products. The pickaxe  
book provides some good examples for manipulating Excel with  
win32ole. The Microsoft Scripting Guys did some great webcasts on WMI  
scripting on the Microsoft Technet site.

I think that should be enough to get you started. Good luck.

Mike
