AIX-SysInfo
view release on metacpan or search on metacpan
Revision history for Perl extension AIX::SysInfo.
1.2 2009-06-17
- Fixed the bug with packaging of the module
- Added these keys: kernel_type, firmware_ver, proc_type
1.1 2009-06-16
sleonov@cpan.org SLEONOV
- Rewritten from scratch
- Added lpar_info and lpar_id
- Changed many functions on how they obtain system information
- Dropped support for original sys_arch and model_type due to
the fact it is useless for newer pSeries hardware.
Instead I simply use "uname -M"
1.0 2001-07-03
- first public release
sub get_total_swap {
my $hash = shift @_;
my $swap = prtconf_param( 'Total Paging Space:' );
$swap =~ /(\d+)\D+/; $hash->{total_swap} = $1;
return 1;
}
sub get_hardware_info {
my $hash = shift @_;
chomp ( my $model_data = `$UNAME -M` );
$model_data =~ /(.*),(.*)/;
( $hash->{sys_arch}, $hash->{model_type} ) = ( $1, $2 );
return 1;
}
sub get_proc_data {
my $hash = shift @_;
$hash->{num_procs} = prtconf_param( '^Number Of Processors:' );
my $speed = prtconf_param( '^Processor Clock Speed:' );
$speed =~ /(\d+)\D+/; $hash->{proc_speed} = $1;
$hash->{proc_type} = prtconf_param( '^Processor Type:' );
return 1;
}
sub get_lpar_info {
my $hash = shift @_;
my $lpar = prtconf_param( '^LPAR Info:' );
$lpar =~ /(\S+)\s+(\S+)/;
$hash->{lpar_id} = $1;
$hash->{lpar_name} = $2;
return 1;
}
sub get_firmware_ver {
my $hash = shift @_;
$hash->{firmware_ver} = prtconf_param( '^Firmware Version:' );
return 1;
}
sub get_kernel_type {
my $hash = shift @_;
$hash->{kernel_type} = prtconf_param( '^Kernel Type:' );
return 1;
}
#-------------------------------------------------------------
# Module's function - get_sysinfo
#-------------------------------------------------------------
sub get_sysinfo {
%sysinfo = ();
my $s_ref = \%sysinfo;
return () unless( $^O eq 'aix');
&get_hostname ( $s_ref );
&get_aix_version ( $s_ref );
&get_hardware_info( $s_ref );
&get_serial_num ( $s_ref );
&get_proc_data ( $s_ref );
&get_firmware_ver ( $s_ref );
&get_total_ram ( $s_ref );
&get_total_swap ( $s_ref );
&get_lpar_info ( $s_ref );
&get_kernel_type ( $s_ref );
return %sysinfo;
}
1;
#------------------------------------------------------
# Module code ends
#------------------------------------------------------
__END__
=pod
The value of this key contains the unique ID number for the system.
=item B<num_procs>
The value of this key contains the number of processors in the system.
=item B<proc_speed>
The value of this key contains the speed of the processors in the system.
=item B<proc_type>
The value of this key contains the processor type (PowerPC_POWER5)
=item B<total_ram>
The value of this key contains the total amount of RAM in the system, in megabytes.
=item B<total_swap>
The value of this key contains the total amount of swap space in the system, in megabytes.
=item B<aix_version>
The value of this key contains the version of AIX and the latest complete maintenance level on ths system, in the form "VRMF-ML".
=item B<model_type>
The value of this key contains the hardware model as reported by uname -M (9117-570)
=item B<sys_arch>
The value of this key contains information on hrdware architecture. It is taken from uname -M and on most modern systems it is simply IBM
=item B<firmware_ver>
t/get_sysinfo.t view on Meta::CPAN
use Test::More tests => 14; # currently 14 keys are populated
use AIX::SysInfo;
my %hash = get_sysinfo();
my @items = qw/ hostname
serial_num
num_procs
total_ram
total_swap
aix_version
model_type
proc_speed
proc_type
firmware_ver
sys_arch
lpar_name
lpar_id
kernel_type
/;
ok( defined $hash{"$_"}, "$_" ) foreach @items;
print "=================================================\n";
print "$_ = $hash{$_}\n" foreach @items;
( run in 1.921 second using v1.01-cache-2.11-cpan-df04353d9ac )