# SRVCPUMEM.PL - Reports the speed, brand and number of processors
# as well as the amount of RAM for servers in a domain
#
# This script was written by Paul Popour (ppopour@infoave.net) in 08/2000.
# It is released into the public domain. You may use it freely, however,
# if you make any modifications and redistribute, please list your name
# and describe the changes. This script is distributed without any warranty,
# express or implied.
#
# SYNTAX - perl srvcpumem.pl [domainname]
#
# Example
#
# perl srvcpumem.pl (uses the domain you are currently logged into)
# or
# perl srvcpumem.pl DOMAIN1
#
# Primary use for this script is to record the amount of processors
# and RAM memory in your servers. The numbers are close on the
# processor speed and RAM but not deadly acurate.
# This is due to the fact that a 550 MHZ processor might
# report to be a 549 MHZ while a 500 processor reports as 498 etc.,.
# You could build a hash to cross reference the actual numbers but....
#
# This script requires the Win32::TieRegistry available at the following URL
#
# http://www.activestate.com/Packages/:
#
# Thanks to Peter Guzis for coming up with an improved method for reading
# a translated registry key
#
use Win32::TieRegistry( Delimiter=>"/" );
use Win32::NetAdmin;
use POSIX;
$output = "c:\\temp\\srvdata.txt";
if (-e $output){unlink $output;}
if (@ARGV[0] ne ""){$domain = @ARGV[0];} else {$domain = Win32::DomainName;}
unless (Win32::NetAdmin::GetDomainController("", $domain, $pdc)) {die "Unable to PDC for $domain.";}
unless (Win32::NetAdmin::GetServers($pdc, $domain, 0x00000008, \@servers1)) {print "Unable to read NetBios 0008.";}
unless (Win32::NetAdmin::GetServers($pdc, $domain, 0x00000010, \@servers2)) {print "Unable to read NetBios 0010.";}
unless (Win32::NetAdmin::GetServers($pdc, $domain, 0x00008000, \@servers3)) {print "Unable to read NetBios 8000.";}
@servers1 = (@servers1, @servers2, @servers3);
foreach $server (@servers1)
{
my ($key, $realname, $speed, $numproc, $data);
print ".";
if ($key = $Registry->Open("//$server/LMachine/SYSTEM/CurrentControlSet/Control/ComputerName/ComputerName/", {Access=>KEY_READ}))
{
unless ($realname = $key->GetValue("ComputerName"))
{
print "\nCan't attach to read value of ComputerName on $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to read value of ComputerName on $server\n";
close OUTPUT;
next;
}
}
else
{
print "\nCan't attach to registry key 1 of $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to registry key 1 of $server\n";
close OUTPUT;
next;
}
next if ($server ne $realname);
print ".";
if ($key = $Registry->Open("//$server/LMachine/HARDWARE/DESCRIPTION/System/CentralProcessor/0/", {Access=>KEY_READ}))
{
unless ($speed = $key->GetValue("~MHZ"))
{
print "\nCan't attach to read value of ~MHZ on $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to read value of ~MHZ on $server\n";
close OUTPUT;
next;
}
$speed = int (((int(hex ($speed) /5) + 1) * 5));
}
else
{
print "\nCan't attach to registry key 2 of $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to registry key 2 of $server\n";
close OUTPUT;
next;
}
print ".";
if ($key = $Registry->Open("//$server/LMachine/SYSTEM/CurrentControlSet/Control/Session Manager/Environment/", {Access=>KEY_READ}))
{
unless ($numproc = $key->GetValue("NUMBER_OF_PROCESSORS"))
{
print "\nCan't attach to read value of NUMBER_OF_PROCESSORS on $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to read value of NUMBER_OF_PROCESSORS on $server\n";
close OUTPUT;
next;
}
}
else
{
print "\nCan't attach to registry key 3 of $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to registry key 3 of $server\n";
close OUTPUT;
next;
}
print ".";
if ($key = $Registry->Open("//$server/LMachine/HARDWARE/DESCRIPTION/System/CentralProcessor/0/", {Access=>KEY_READ}))
{
unless ($brand = $key->GetValue("VendorIdentifier"))
{
print "\nCan't attach to read value of VendorIdentifier on $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to read value of VendorIdentifier on $server\n";
close OUTPUT;
next;
}
}
else
{
print "\nCan't attach to registry key 4 of $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to registry key 4 of $server\n";
close OUTPUT;
next;
}
print ".";
if ($remoteKey = $Registry->{"//$server/LMachine/HARDWARE/RESOURCEMAP/System Resources/Physical Memory/"})
{
unless ($data = ceil((unpack "L*", $remoteKey->GetValue('.Translated'))[-1] / 1024/ 1024 + 16))
{
print "\nCan't attach to read value of .Translated on $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to read value of .Translated on $server\n";
close OUTPUT;
next;
}
}
else
{
print "\nCan't attach to registry key 5 of $server\n";
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "Can't attach to registry key 5 of $server\n";
close OUTPUT;
next;
}
open(OUTPUT, ">>$output") || die "Can't open $output";
print OUTPUT "$server\t$speed MHZ\t$brand\t$numproc\t$data MB\n";
close OUTPUT;
print "\n\nOutput recorded in $output\n\n";
}
|
Note: Neither Roth Consulting nor its affiliates are responsible for problems resulting
from the misuse, modification or execution of any of the scripts on this web site. It is best that the
the user read over the script carefully to insure that the code is not harmful to his environment.
This page has been viewed 8,447 times.
This site has been hit 8,510,352 times since May 22, 2001
Copyright © 1996 - 2010 Roth Consulting.
Last updated 2010.07.31
.NET, Perl, Python, script, scripting, VB, Visual Basic, java, javascript, perlscript, odbc, database, SQL, Win32, NT, Windows, coding, programing, c, c++, c#,
Linux, Microsoft, IBM, Windows, Exchange, Outlook, Oracle, Sybase,
Windows XP, SP2, Windows Server 2003,
consult, consulting, Dave Roth, David Roth, Adminmisc, Perms, Daemon, Pipe, book, extensions,
IT, administration,
Microsoft Office, Microsoft Word, Microsoft Excel, Microsoft Powerpoint,
security, anti virus, antivirus, firewall, NAT,
WMI, COM, MOM, administration, IT,
network, DSL, Cable, Dial-up, phone, telephone, long distance,
Tablet PC, tabletpc, tablet pcs, tablet pc questions, tablet pc faqs, tablet pc comparisons, tablet pc reviews, Windows XP Tablet PC Edition, popular tablet pc software, Windows XP Tablet PC, utilities, tablet pc games, tabletpc software, tablet pc utilities, windows tablet software
desktop computer, notebook, notebook computer, computer,