Retrieve system info from networked PCs
Anonymous Monk
created: 2004-06-16 05:47:45
Hello Monks,

I'm not very experienced with network stuff and was wondering if you could offer any help with this.

Basically I want to script a program that will allow me to specify either a domain name and machine name, or supply an IP address, username, password and confirm password, that will allow me to look at a machine and pull some information off it. This should include OS, OS version, Service packs, CPU type, CPU clock, memory and HD total & free space. Very much like a simple auditing system.

If you could point me in the direction of things I need to look at in order to do this I would be very grateful.

Thank you for all you help,
Kwun Cheung.

Re: Retrieve system info from networked PCs
dba
created: 2004-06-16 09:31:45
Net::Telnet would be the starting point for unix systems. (if telnet open, otherwise Net::SSH if ssh setup) Based on uname you should issue appropriate commands for the OS to get the information.
For windows you should probably use Win32 module
Update:
You could also check WshRemote and WshNetwork objects of Windows scripting. Is there one ? :)
Re: Retrieve system info from networked PCs
created: 2004-06-16 11:12:31
Not a perl solution but it sounds like something that nagios will do quite well. www.nagios.org. It will monitor a bunch of different statistics about machines on your network, throw alerts if something breaks and keep a history of what was broken etc. Decent software.
Re: Retrieve system info from networked PCs
created: 2004-06-16 13:26:11
You're question is rather vague.. From the terminology you used in the question I'm guessing you're in a windows environment, wanting to know what type of windows OS a machine is, what service packs it has, etc..

There are many available options, but a general question deserves a general answer. Look into WMI (Windows Management Instrumentation) - it can be accessed using Win32::OLE. As part of SDK/administration packs from Microsoft there are examples of how to tap WMI from various scripting languages.(including perl)
Re: Retrieve system info from networked PCs
created: 2004-06-16 13:38:51
Here's something to get you started:

use strict;
use Win32::OLE qw(in);

my $host = 'serverABC';
my $username = 'adminaccount';
my $password = 'secret';

my $WMI = Win32::OLE->new('WbemScripting.SWbemLocator');
my $WMIServices = $WMI->ConnectServer($host, 'root/cimv2', $username, $password)
	or die ("Could not connect to $host");

$WMIServices->{Security_}->{ImpersonationLevel} = 3;

my $os_set = $WMIServices->InstancesOf("Win32_OperatingSystem");

my ($os_name, $os_version, $os_sp);

foreach my $os (in($os_set)) {
	$os_name	= $os->{'Caption'};
	$os_version	= $os->{'Version'};
	$os_sp		= $os->{'CSDVersion'};
}

print "OS = $os_name $os_version $os_sp\n";

Documentation for other Win32 WMI classes can be found here:

[http://msdn.microsoft.com/library/en-us/wmisdk/wmi/wmi_classes.asp]

perlmonks.org content © perlmonks.org and amw1, Anonymous Monk, blueAdept, dba, meetraz

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03