#5 HPUX Not Displaying Installed Memory

open
nobody
None
5
2003-12-05
2003-12-05
Philip Reyniers
No

******************************************
** Description:
******************************************
remstats 1.0.13a cannot determine the installed physical
memory for HPUX 10.x and 11.x and is displayed on the
server status page as 'unknown'.

******************************************
** Solution:
******************************************

I have written get_hpux_memoryinfo function, keeping
the authors development style, for the unix-status-
server program. This will allow the unix-status-server to
support getting the physically installed memory for both
HPUX 10.x and 11.x. Additionally the
get_hpux_memoryinfo function is called from the
do_uname function inside the unix-status-server.

******************************************
** MODIFIED SOURCE FOR THE unix-status-server:
******************************************
#--------------------------------------- do_uname ---
sub do_uname {
my ($now, $hw, $mem, $os, $rel, $ver);

unless (defined $main::uname) {
&debug("no uname program found") if
($main::debug);
return;
}
&debug("starting UNAME") if( $main::debug);
&debug("using '$main::uname' for uname") if
($main::debug);

# Invoke each part separately, in case some-one
forgot one of them
# Also, the printing of '-a' is unparseable.
$hw = `$main::uname -m`;
if (defined $hw) { chomp $hw; } else { $hw
= 'unknown'; }

$os = `$main::uname -s`; chomp $os;
if (defined $os) { chomp $os; } else { $os
= 'unknown'; }

$rel = `$main::uname -r`; chomp $rel;
if (defined $rel) { chomp $rel; } else { $rel
= 'unknown'; }

$ver = `$main::uname -v`; chomp $ver;
if (defined $ver) { chomp $ver; } else { $ver
= 'unknown'; }

$now = time - $main::remote_time_difference;

# Now OS-specific other identification
if( $os eq 'Linux') {
$hw = &get_linux_cpuinfo( $hw );
$mem = &get_linux_memoryinfo();
}
elsif( $os eq 'SunOS') {
$hw = &get_sunos_cpuinfo( $hw );
$mem = &get_sunos_memoryinfo();
}
elsif( $os eq 'HP-UX' ){
$mem = &get_hpux_memoryinfo( $rel );
}
else {
$hw = 'unknown';
$mem = 'unknown';
}

# Show whatever we've got
print <<"EOD_UNAME";
$now machine $hw
$now os_name $os
$now os_release $rel
$now os_version $ver
$now memory_size $mem
EOD_UNAME
$main::os_name = $os;
$main::os_release = $rel;
}

#---------------------------- get_hpux_memoryinfo ---
sub get_hpux_memoryinfo {
#-----------------------------------------------
# get_hpux_memoryifo is designed to obtain the
# installed memory from from a hpux server.
# Created By:
# P. Reyniers
# Senior Solutions Architect
# Hewlett-Packard
#-----------------------------------------------

my $str_rel = shift @_;
my $memory = '';
my $str_req_val = '';
my $str_vmunix = '/stand/vmunix';
my $str_kmem = '/dev/kmem';
my $str_echo = '/usr/bin/echo';
my $str_adb = '/usr/bin/adb';
if ( $str_rel =~ m/\w{1}.11.\d{2}/g ) {
$str_req_val = '"phys_mem_pages/D"'; # HP-
UX 11.x Only.
}elsif ( $str_rel =~ m/\w{1}.10.\d{2}/g ) {
$str_req_val = '"physmem/D"'; # HP-UX
10.x Only.
}else {
$memory = 'unknown';
return $memory;
}

if ( !-e $str_vmunix ) {
&debug( "can't open $str_vmunix: $!" ) if (
$main::debug );
return $memory;
}
if ( !-e $str_kmem ) {
&debug( "can't open $str_kmem: $!" ) if (
$main::debug );
return $memory;
}
my $str_cmd = "$str_echo $str_req_val \|
$str_adb $str_vmunix $str_kmem";
open( MEMINFO, "$str_cmd|" ) or do {
&debug( "can't open $str_cmd: $!" ) if(
$main::debug);
return $memory;
};
while(<MEMINFO>) {
chomp;
if( /^phys_mem_pages:\s+(\d+)/) {
$memory = $1;
$memory = $memory / 256 if (
$memory ne '' );
last;
}
}
close(MEMINFO);
return $memory;
}
******************************************
** END MODIFIED SOURCE FOR THE unix-status-server:
******************************************

How about adding this code into the next release.

Peace Out.
:)

Discussion

  • Logged In: YES
    user_id=899237

    One other thing to add, in order to access /dev/kmem on
    HPUX you will either have to grant sys access to remstats or
    configure sudo to allow the command to run. Your choice!

    Peace Out.

    :)