AIX-SysInfo

 view release on metacpan or  search on metacpan

SysInfo.pm  view on Meta::CPAN

######################################################
package AIX::SysInfo;
######################################################
#
# Author: Sergey Leonovich, sleonov@cpan.org
# Architecture: AIX
#

use strict;
our (@ISA, @EXPORT, $VERSION);
require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw( get_sysinfo );
$VERSION = "1.2";

#--------------------------------------------------------
# Module code begins
#--------------------------------------------------------
# 
my $UNAME='/usr/bin/uname';
my $OSLEVEL='/usr/bin/oslevel';

my $PRTCONF='/usr/sbin/prtconf';
my %sysinfo = ();
my @pconf_array;

#--------------------------------------------------------
# Simple functions to populate the hash
#--------------------------------------------------------
sub prtconf_param {
        my $param = shift @_;
        my @result = grep {/$param/} @pconf_array;
        return undef unless ( scalar @result );
        ($_ = pop @result) =~ /:\s*(.*)/;
        return $1;
}
sub get_total_ram {
        my $hash = shift @_;
        my $memory = prtconf_param( '^Memory Size:' );
        $memory =~ /(\d+)\D+/; $hash->{total_ram} = $1;
        return 1;
}
sub get_hostname {
        my $hash = shift @_;
        chomp ( $hash->{hostname} = `$UNAME -n` );
        return 1;
}
sub get_aix_version {
        my $hash = shift @_;
        chomp ( $hash->{aix_version} = `$OSLEVEL -r` );
        return 1;
}
sub get_serial_num {
        my $hash = shift @_;
        $hash->{serial_num} = prtconf_param( '^Machine Serial Number:' );
        return 1;
}
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:' );



( run in 1.290 second using v1.01-cache-2.11-cpan-13bb782fe5a )