Wow.  Awesome.  Could you add Win 9X/Me too... THis is cool.

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Timothy Johnson
> Sent: Friday, March 29, 2002 9:52 AM
> To: 'Vinod Panikar'; [EMAIL PROTECTED]
> Subject: RE: How do I get processor and memory information?
>
>
>
> Here's something I wrote a while back.  It's full of bad
> coding practices,
> but I think it will give you an idea of where you can get some of this
> information.
>
>
> ####################################################
> ##                                                ##
> ##           CONFIG.PL  v1.5.031502               ##
> ##           written by Tim Johnson               ##
> ##                                                ##
> ##        Retrieves configuration info            ##
> ##          for specified computer(s)             ##
> ##                                                ##
> ####################################################
>
> use Win32::AdminMisc;
> use Win32::TieRegistry(Delimiter=>"/");
> use Win32::Lanman;
> use Net::Ping;
> use Win32::Service;
>
> ###  MAIN  #########################################################
>
> &setPing;      #Sets the protocol and timeout for Net::Ping
> &getClients;   #Gets the list of clients
> print "Retrieving Configuration Info for\:\n";
>
> foreach $client(@clients){
>       if($p->ping($client) == 1){
> #Client is on the network
>               print "     \\\\$client\n";
>               if($reg = $Registry->{"//$client/HKEY_LOCAL_MACHINE/"}){
> #Read access to Registry
>                       &getDDInfo;            #Hard Drive Info
>                       &getMemoryInfo;        #Memory Info
>                       &getSoftInfo;          #Installed Software
>                       &getServices;          #Service Info
>                       &getIPInfo;            #IP Info
>                       &getHWInfo;            #Misc. Hardware Info
>                       &printInfo;            #Print text file
>                       &cleanup;              #undef hashes so
> they can be
> reused
>               }else{
>                       &printInfo;
>               }
>       }else{
>               print "No Ping on $client!\n";
>       }
> }
>
>
>
> ###  SUBS  ##########################################################
>
> sub setPing{
>       $p = Net::Ping->new('icmp',2);
> }
>
> sub getClients{
>       if(@ARGV[0]){
>               foreach $argument(@ARGV){
>                       push @clients,$argument;
>               }
>       }else{
>               open(INFILE,"current_clients.txt") || die "No clients
> specified!\n";
>               @clients = <INFILE>;
>               chomp @clients;
>               close INFILE;
>       }
>       foreach $client(@clients){
>               $client =~ tr/a-z/A-Z/;
>               $client =~ s/^\\//g;
>       }
> }
>
> sub getDDInfo{
>       Win32::Lanman::NetServerDiskEnum("\\\\$client",\@drives);
>       foreach $drive(@drives){
>               $drive =~ s/://g;
>               @drvinfo =
> Win32::AdminMisc::GetDriveSpace("\\\\$client\\$drive\$");
>               $drive = $drive."\:";
>               ${$drive}{'CAPACITY'} =
> sprintf("%5.2f",($drvinfo[0]/1073741824))." GB"; #Convert to GigaBytes
>               ${$drive}{'SPACE'} =
> sprintf("%5.2f",($drvinfo[1]/1073741824))." GB";
>       }
>       for($i = 0;$drives[$i];$i++){
>               if(${$drives[$i]}{'SPACE'} < 0.01){  #Keep
> removable media
> from showing up
>                       delete $drives[$i];
>               }
>       }
> }
>
> sub getMemoryInfo{
>       if($memkey =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/Hardware/ResourceMap/System
> Resources/Physical Memory/"}){
>       $mem = int((unpack 'L*', $memkey->GetValue('.Translated'))[-1]
> /1024/1024+16);
>       }
> }
>
> sub getSoftInfo{
>       $verRoot =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
> NT/CurrentVersion/"};
>       if($verRoot->{'CurrentVersion'} eq '5.0'){         #OS
> Version Info
>               $OS = "Microsoft Windows 2000 ";
>       }elsif($verRoot->{'CurrentVersion'} eq '4.0'){
>               $OS = "Microsoft Windows NT 4.0 ";
>       }elsif($verRoot->{'CurrentVersion'} eq '5.1'){
>               $OS = "Microsoft Windows XP ";
>       }else{
>               $OS = "Unknown Operating System";
>       }
>       $servicepack = $verRoot->{'CSDVersion'};
>       $OSType = $verRoot->{'CurrentType'};
>       $build = $verRoot->{'CurrentBuildNumber'};
>       $uninstall =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/W
> indows/Current
> Version/Uninstall"};
>       @softkeys =keys %{$uninstall};
>       foreach $key(@softkeys){
> #Check Uninstall
> keys to enumerate installed software
>               $softInfo{$key} = $uninstall->{$key}->{'DisplayName'};
>       }
> }
>
> sub getServices{
>       Win32::Service::GetServices($client,\%svcs);
>       @servlist = keys %svcs;
>       @servlist = sort @servlist;
>       foreach $service(@servlist){
>               $shortname = $svcs{$service};
>               $services->{$service}->{'NAME'} = $service;
>               Win32::Service::GetStatus($client,$shortname,\%srvStat);
>               if($srvStat{'CurrentState'} == 4){
>                       $services->{$service}->{'STATUS'} = "Started";
>               }
>               $services->{$service}->{'ACCOUNT'} =
> $Registry->{"//$client/LMachine/SYSTEM/CurrentControlSet/Servi
> ces/$shortname
> /ObjectName"};
>       }
> }
>
> sub getIPInfo{
>       ####  WINDOWS 2000  ####
>
> if($Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsof
> t/Windows
> NT/CurrentVersion/CurrentVersion"} eq "5.0"){
>               $adapterRoot =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
> NT/CurrentVersion/NetworkCards/"};
>               $ipRoot =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/SYSTEM/CurrentContro
> lSet/Services/
> Tcpip/Parameters/Interfaces/"};
>               @adapterKeys = keys %{$adapterRoot};
>               foreach $key(@adapterKeys){
>                       $name = $adapterRoot->{$key}->{'ServiceName'};
>                       $service =
> $adapterRoot->{$key}->{'ServiceName'};
>                       $nics->{$name}{'Description'} =
> $adapterRoot->{$key}->{'Description'};
>                       $nics->{$name}{'ServiceName'} =
> $adapterRoot->{$key}->{'ServiceName'};
>                       $nics->{$name}{'Domain'} =
> $ipRoot->{"$servicename/Domain"};
>                       $nics->{$name}{'DNS'} =
> $ipRoot->{"$servicename/NameServer"};
>                       if($ipRoot->{"$service/EnableDHCP"} eq
> "0x00000000"){
>                               $nics->{$name}{'IPAddress'} =
> $ipRoot->{"$service/IPAddress"};
>                               $nics->{$name}{'Subnet'} =
> $ipRoot->{"$service/SubnetMask"};
>                               $nics->{$name}{'DHCPEnabled'} = "No";
>                               $nics->{$name}{'Gateway'} =
> $ipRoot->{"$service/DefaultGateway"};
>                       }elsif($ipRoot->{"$service/EnableDHCP"} eq
> "0x00000001"){
>                               $nics->{$name}{'DHCPServer'} =
> $ipRoot->{"$service/DhcpServer"};
>                               $nics->{$name}{'Subnet'} =
> $ipRoot->{"$service/DhcpSubnetMask"};
>                               $nics->{$name}{'IPAddress'} =
> $ipRoot->{"$service/DhcpIPAddress"};
>                               $nics->{$name}{'DHCPEnabled'} = "Yes";
>                               $nics->{$name}{'Gateway'} =
> $ipRoot->{"$service/DhcpDefaultGateway"};
>                       }
>               }
>       ####  WINDOWS NT  ####
>
> }elsif($Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Micr
> osoft/Windows
> NT/CurrentVersion/CurrentVersion"} eq "4.0"){
>               $adapterRoot =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
> NT/CurrentVersion/NetworkCards/"};
>               foreach $key(keys %{$adapterRoot}){
>                       $name = $adapterRoot->{$key}->{'ServiceName'};
>                       $service =
> $adapterRoot->{$key}->{'ServiceName'};
>                       $nics->{$name}{'Description'} =
> $adapterRoot->{$key}->{'Description'};
>                       $nics->{$name}{'ServiceName'} =
> $adapterRoot->{$key}->{'ServiceName'};
>                       $ipRoot =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/SYSTEM/CurrentContro
> lSet/Services/
> $service/Parameters/Tcpip/"};
>                       if($ipRoot->{"EnableDHCP"} eq "0x00000000"){
>                               $nics->{$name}{'IPAddress'} =
> $ipRoot->{"IPAddress"};
>                               $nics->{$name}{'Subnet'} =
> $ipRoot->{"SubnetMask"};
>                               $nics->{$name}{'DHCPEnabled'} = "No";
>                               $nics->{$name}{'Gateway'} =
> $ipRoot->{"DefaultGateway"};
>                       }elsif($ipRoot->{"EnableDHCP"} eq "0x00000001"){
>                               $nics->{$name}{'DHCPServer'} =
> $ipRoot->{"DhcpServer"};
>                               $nics->{$name}{'Subnet'} =
> $ipRoot->{"DhcpSubnetMask"};
>                               $nics->{$name}{'IPAddress'} =
> $ipRoot->{"DhcpIPAddress"};
>                               $nics->{$name}{'DHCPEnabled'} = "Yes";
>                               $nics->{$name}{'Gateway'} =
> $ipRoot->{"DhcpDefaultGateway"};
>                       }else{
>                               print "        DHCP status unknown on
> $name!\n";
>                       }
>               }
>       }
> }
>
>
> sub getHWInfo{
>       $HWRoot =
> $Registry->{"//$client/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/"};
>       for($i = 0;$HWRoot->{'System/CentralProcessor/'.$i."/"};$i++){
> #Processor Info
>               $HWInfo{'PROCESSOR_'.($i + 1).'_SPEED'} =
> $HWRoot->{'System/CentralProcessor/'.$i.'/'}->{'~MHZ'};
>               $HWInfo{'PROCESSOR_'.($i + 1).'_VENDOR'} =
> $HWRoot->{'System/CentralProcessor/'.$i.'/'}->{'VendorIdentifier'};
>               $HWInfo{'PROCESSOR_'.($i + 1).'_TYPE'} =
> $HWRoot->{'System/CentralProcessor/'.$i.'/'}->{'Identifier'};
>       }
>       $HWInfo{'BIOS_DATE'} = $HWRoot->{'System/'}->{'SystemBiosDate'};
> #BIOS Info -- note that the date may appear incorrectly as XX/XX/20.
>       $HWInfo{'BIOS_VER'} =
> $HWRoot->{'System/'}->{'SystemBiosVersion'};#This is the way
> it shows up in
> the Registry...can you say Y2K Compliancy?
> }
>
> sub printInfo{
>       open(OUTFILE,">$client.conf.txt");
>       print OUTFILE "\n";
>       print OUTFILE "CONFIGURATION INFO FOR $client\:
> ".localtime(time)."\n";
>       print OUTFILE
> "#############################################################
> #\n\n\n";
>       print OUTFILE "OPERATING SYSTEM\n";
>       print OUTFILE
> "==============================================================\n\n";
>       print OUTFILE "     OS           -> $OS\n";
>       print OUTFILE "     Type         -> $OSType\n";
>       print OUTFILE "     Build        -> $build\n";
>       print OUTFILE "     Service Pack -> $servicepack\n\n";
>
>       print OUTFILE "PROCESSOR CONFIGURATION\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       for($i = 1;$HWInfo{'PROCESSOR_'.$i.'_SPEED'};$i++){
>               print OUTFILE "Processor $i\:\n";
>               print OUTFILE "--------------\n";
>               print OUTFILE "     Speed   ->
> \~".hex($HWInfo{'PROCESSOR_'.$i.'_SPEED'})."MHZ\n";
>               print OUTFILE "     ID      ->
> ".$HWInfo{'PROCESSOR_'.$i.'_VENDOR'}."
> ".$HWInfo{'PROCESSOR_'.$i.'_TYPE'}."\n";
>       }
>       print OUTFILE "\n";
>       print OUTFILE "BIOS INFO\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       print OUTFILE "     Date    -> ".$HWInfo{'BIOS_DATE'}."\n";
>       print OUTFILE "     Version -> ".$HWInfo{'BIOS_VER'}."\n";
>       print OUTFILE "\n";
>       print OUTFILE "MEMORY CONFIGURATION\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       print OUTFILE "     Physical Memory-> $mem MB\n";
>       print OUTFILE "\n";
>       print OUTFILE "DRIVE CONFIGURATION\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       print OUTFILE "DRIVE LETTER                             SIZE
> FREE\n";
>       print OUTFILE
> "--------------------------------------------------------------\n";
>       foreach $drive(@drives){
>               unless(${$drive}{'SPACE'} < 0.01){
>                       print OUTFILE "$drive ";
>                       for($i = 0;$i < (42 -
> length(${$drive}{'CAPACITY'}));$i++){  #Make sure there are
> the right number
> of dots
>                               print OUTFILE ".";
>                       }
>                       print OUTFILE ${$drive}{'CAPACITY'};
>                       for($i = 0;$i < (17 -
> length(${$drive}{'SPACE'}));$i++){
>                               print OUTFILE ".";
>                       }
>                       print OUTFILE"${$drive}{'SPACE'}\n";
>               }
>       }
>       print OUTFILE "\n";
>       print OUTFILE "INSTALLED SOFTWARE\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       foreach $soft(sort values %softInfo){
>               unless(!$soft){
>                       print OUTFILE "     $soft\n";
>               }
>       }
>       print OUTFILE "\n\n";
>       print OUTFILE "SERVICES\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       foreach $service(@servlist){
>               print OUTFILE "$services->{$service}->{'NAME'}";
>               for($i = 0;$i < (62 -
> length($services->{$service}->{'STATUS'}) -
> length($services->{$service}->{'NAME'}));$i++){
>                       print OUTFILE ".";
>               }
>               print OUTFILE "$services->{$service}->{'STATUS'}\n";
>               if($services->{$service}->{'ACCOUNT'} ne 'LocalSystem'){
>                       print OUTFILE "               Running As:
> $services->{$service}->{'ACCOUNT'}\n";
>               }
>       }
>       print OUTFILE "\n\n";
>       print OUTFILE "IP CONFIGURATION\:\n";
>       print OUTFILE
> "==============================================================\n\n";
>       foreach $nic(keys %{$nics}){
>               print OUTFILE "$nics->{$nic}->{'Description'}\n";
>               print OUTFILE
> "--------------------------------------------------------------\n\n";
>               print OUTFILE "     DHCP Enabled  ->
> ".$nics->{$nic}->{'DHCPEnabled'}."\n";
>               print OUTFILE "     IP Address    ->
> ".$nics->{$nic}->{'IPAddress'}."\n";
>               print OUTFILE "     Subnet Mask   ->
> ".$nics->{$nic}->{'Subnet'}."\n";
>               print OUTFILE "     Gateway       ->
> ".$nics->{$nic}->{'Gateway'}."\n";
>               print OUTFILE "     Service       ->
> ".$nics->{$nic}->{'ServiceName'}."\n\n";
>       }
>       print OUTFILE
> "##############################################################\n";
> }
>
> sub cleanup{    #If you don't remove these values, there will
> be garbage in
> the next machine's data.
>       undef $OS;
>       undef $build;
>       undef $servicepack;
>       undef %HWInfo;
>       undef %softInfo;
>       undef %{$nics};
>       undef $services;
>       undef $verRoot;
>       undef %svcs;
>       undef %srvStat;
>       undef $adapterRoot;
>       undef $ipRoot;
>       close OUTFILE;
> }
>
> -----Original Message-----
> From: Vinod Panikar [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 29, 2002 9:26 AM
> To: [EMAIL PROTECTED]
> Subject: How do I get processor and memory information?
>
>
> Hi there,
>
> How do i retrieve processor,memory,ipaddress etc of a machine?
> AdminMisc module doesn't work for remote machine works only locally.
>
> Any info about any other module availability would be helpful.
>
> Thanks!
> Vinod
> --
>
> _______________________________________________
> Sign-up for your own FREE Personalized E-mail at Mail.com
> http://www.mail.com/?sr=signup
>
> Win the Ultimate Hawaiian Experience from Travelocity.
> http://ad.doubleclick.net/clk;4018363;6991039;n?http://svc.tra
velocity.com/p
romos/winhawaii/

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


----------------------------------------------------------------------------
----
This email may contain confidential and privileged
material for the sole use of the intended recipient.
If you are not the intended recipient, please contact
the sender and delete all copies.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to