Win32::MachineInfo - Basic Windows NT/2000/XP OS and Hardware Info
use Win32::MachineInfo; my $host = shift || ""; if (Win32::MachineInfo::GetMachineInfo($host, \%info)) { for $key (sort keys %info) { print "$key=", $info{$key}, "\n"; } } else { print "Error: $^E\n"; }
Win32::MachineInfo is a module that retrieves basic OS, CPU, Memory, and Video information from a remote Windows NT/2000/XP machine. It uses Win32::TieRegistry to retrieve the information, which it returns as a hash structure.
where $host is the target machine and %info the hash that will contain the collected information if the function executes successfully. $host can be "HOST1", "\\\\HOST1", or "192.168.0.1". The function will return true if it completes successfully, false otherwise. If the function fails, it will probably be because it cannot connect to the remote machine's registry; the error will available through Win32::GetLastError.
The following fields are returned in %info:
use Win32::MachineInfo; @fields = qw/computer_name osversion display_resolution/; print join(",", @fields), "\n"; while (<DATA>) { chomp; Win32::MachineInfo::GetMachineInfo($_, \%info); print join ",", @info{@fields}; print "\n"; } __DATA__ HOST1 HOST2 HOST3
James Macfarlane, <jmacfarla@cpan.org>
Win32::TieRegistry
Paul Popour's SRVCPUMEM.PL script was an inspiration and I am indebted to him for the formula that calculates memory from the value of the ".Translated" key.
I found the following sites helpful in compiling the translation tables that determine the 'processor_name' field from the processor_vendor and processor_identifier fields:
www.paradicesoftware.com/specs/cpuid/cpuid.htm
grafi.ii.pw.edu.pl/gbm/x86/cpuid.html
www.microflextech.com/support/intel/intel.htm
To install Win32::MachineInfo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::MachineInfo
CPAN shell
perl -MCPAN -e shell install Win32::MachineInfo
For more information on module installation, please visit the detailed CPAN module installation guide.