SUMMARY: How much RAM do I have??

From: David Bremer <DaveB_at_healthotago.co.nz>
Date: Sat, 1 Feb 1997 15:52:41 +1300

Sorry this has taken so long.

The question was:

>HOW do I find out how much
>RAM I have. Someone's just asked me & I realised that while I've been
>told "256M" I've got no idea how to confirm that.
>
>There's gotta be a simple query command somewhere (yes, I've looked
>through "man -k ram" & "man -k mem")

NB I was after physical - not virtual - memory

I was stunned by the number of responses & some specific help from one
person who checked my results against her system to make sure my
understanding was correct (Thanks again for that Pam).

Most of the replies were variations of a theme so I've just summarized
them. Alternative scripts / C-code are included as sent, for others
interest.

Thanks to:
========
Alan alan_at_nabeth.cxo.dec.com
Anil Khullar Anil.Khullar_at_mailhub.gc.cuny.edu
Andreas atoalu2_at_ato.abb.se
Becki Kain beckers_at_josephus.furph.com
Brian H. Mayo brian.mayo_at_brynmawr.edu
Brian Sherwood sherwood_at_esu.edu
Cliff Krieger ckrieger_at_latrade.com
Dave Golden golden_at_falcon.invincible.com
David Warren warren_at_atmos.washington.edu
Dick Abraham abrahad_at_govonca.gov.on.ca
Thomas Eisele eisele_at_pfa.research.philips.com
Fergal Mc Carthy fergal_at_ilo.dec.com
Guy Dallaire dallaire_at_total.net
James Soh jamessoh_at_post1.com
Jean Schuller schuller_at_crnal4.in2p3.fr
Jerome Fenal fenal_at_dcmc.creditlyonnais.fr
Joe Spanicek joe_at_resptk.bhp.com.au
Joel Healy jsh_at_mentor.co.nz
Kurt Knochner Kurt.Knochner_at_Physik.TU-Muenchen.DE
Lucio Chiappetti lucio_at_ifctr.mi.cnr.it
Martin E. Lally mel1003_at_phy.cam.ac.uk
Nick Hill N.M.Hill_at_rl.ac.uk
Pam Woods axsymgr_at_UAA.ALASKA.EDU
Paul Crittenden crittend_at_storm.simpson.edu
Paul Henderson henderson_at_unx.dec.com
Palo paulo_at_dexel.co.za
Peter Stern peter_at_wiscpa.weizmann.ac.il
Rainer Landes Computer-Administration_at_Physik.uni-karlsruhe.de
Randy M. Hayman haymanr_at_icefog.alaska.edu
Richard Tame Richard.Tame_at_asx.com.au
Rick Muse m6u_at_oaunx1.ctd.ornl.gov
                        rioux_at_ip6480nl.ce.utexas.edu
Rob Hamm hammr_at_ucfv.bc.ca
Robert L. McMillin rlm_at_netcom.com
Jennifer Salcher salcherj_at_cistech.com
Andreas schuenem_at_rz5.rz.fh-wilhelmshaven.de
Theis Jean-Marie theis_at_drfc.cad.cea.fr
Tom Webster webster_at_ssdpdc.mdc.com
Bruce Whittaker bruce.whittaker_at_ansto.gov.au
Yizhong Zhou zhou_at_mathworks.com

<whew!!!>


Now for the solution(s)

The most suggested themes were around the UERF & /var/adm/messages logs.
As root try:
#uerf -Rr 300 | more

& look for the physical memory

or as any user try
$more /var/adm/messages

Of course you could grep either of these for "mem" or "memory" if you
want. The UERF one is reversed to ensure that you are looking at the
most recent - I was stumped for a while as my log hadn't been cleared
since a memory upgrade ages ago, so I saw, first, the original memory
size.

=========
A few people mentioned :
Try (as root):
# vmstat -P

At the frimware prompt you could try:
>>>>show config
or
>>>>show memory
(or is that "show mem"?)

But I had no intention of bringing the system down for such a query -
could be handy if its shutdown for some other reason though

or

use monitor and magnify the "memory" item (run monitor, type "m", arrow
down to "memory" and type "s")

or use "top" (I don't have it)


Other suggestions were:

Alan:
====
Count the number of bytes in memory:
# wc -c /dev/mem
(I got nervous when I it took a while and after running syd found it to
be the highest process - so killed it - Dave)

Get the number of pages and multiply by the page size:
        # dbx -k /vmunix /dev/mem
        (dbx) print physmem
(I got some error messages with the first line & the response from the
dbx command was different from that obtained from uerf & messages - but
then I don't know much about dbx)

Thomas Eisele:
===========
for the csh:
        dd bs=1048576 if=/dev/mem of=/dev/null |& tail -1 | sed -e 's/\+.*$/
MB/'

and for sh:
        dd bs=1048576 if=/dev/mem of=/dev/null 2>&1 | tail -1 | sed -e
's/\+.*$/ MB/'


Jean Schuller
==========
I remember I wrote a shell script using uerf and I called it CONFIG :
It shows Ethernet address, devices, memory size and unix version .

--------------------------------- 8< cut here -------------------

#!/bin/ksh
#
# Show configuration
#
acc=`whoami`
if [ $acc != "root" ]
then
  echo "You must be root for this instructions "
  return
fi
machine=`hostname`
clear
echo " $machine : Configuration"
echo
echo
"-----------------------------------------------------------------------
--"
#
# 1) Ethernet address
#
echo "Ethernet address"
echo "================"
uerf -r 300 | grep -i "_hardware address" | sort -u
echo
"-----------------------------------------------------------------------
--"
#
# 2) Show devices
#
echo "Devices : "
echo "=========="
let i=0
while [ $i -lt 11 ]
do
  dev="/dev/rrz"$i"c"
  file $dev 2>/dev/null | grep character
  let i=i+1
done
echo
"-----------------------------------------------------------------------
--"
#
# 3) memory size
#
echo "Memoy size"
echo "=========="
uerf -r 300 | grep -i 'physical memory ' | sort -u
echo
"-----------------------------------------------------------------------
--"
#
# 4) Unix Versions
#
echo "Successive Digital Unix Versions"
echo "================================"
uerf -r 300 | egrep -i 'DEC OSF/1 V|Digital UNIX V' | sort -u
echo
"-----------------------------------------------------------------------
--"
--------------------------------- 8< cut here -------------------


Martin E. Lally
==========
Here is the C source code for displaying system RAM size. Compile with
# cc -o memsize filename.c

------------------------------- CUT HERE -------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysinfo.h>

main(argc, argv)
int argc;
char **argv;
{
    int memsize,err;

    err=getsysinfo(GSI_PHYSMEM, &memsize, sizeof(memsize), 0, NULL);

    printf("Total Real Memory: %d Mb\n", memsize/1024);
    exit(0);
}
------------------------------- CUT HERE -------------------------------

Randy M. Hayman
=============
A variation of that theme is:

compile with: cc -o show_mem show_mem.c
------------------------------- CUT HERE -------------------------------
#include <stdio.h>
#include <sys/sysinfo.h>

int status, *int_buff;

main()
{
if( -1 == (status = getsysinfo(GSI_PHYSMEM, &int_buff, sizeof(int_buff),
0, 0)) )
        fprintf(stdout, "error %d getting GSI_PHYSMEM\n", status);
else
        fprintf(stdout, "Physical memory in use: %d KB\n",
(int)int_buff);
}
------------------------------- CUT HERE -------------------------------

Theis Jean-Marie
============
(I'm afraid I haven't had a chance to check this - but as Theis was kind
enough to pass it to me, I thought it may be of interest to others in
the list - Dave)

If you are interested I have done a script called cnfg which describes
 your configuration (OSF station 2100 or 3000) The drawback of it is
that it is reserved to root , and need editing when a new device
 appears (it already knows a lot of them).


------------------------------- CUT HERE -------------------------------
if [ `whoami` != root ]
then
 echo "Vous devez etre root pour cette commande . Bye..."
 exit 1
fi
trap 'rm -f /tmp/cnfg.tmp 2>/dev/null' 0 1 2 15
PATH="$PATH:/etc:/sbin:/usr/sbin"
nodate=false
long=false
while [ "$1" ]
do
 case $1 in
 -nodate)nodate=true
         shift;;
 -l)long=true
    shift;;
 esac
done
export PATH
hostname=`hostname | awk -F\. '{print $1}'`
HOSTNAME=`echo $hostname | tr 'a-z' 'A-Z'`
adresseIP=`arp $hostname | sed 's/^.*(//;s/).*$//'`
ADRESSEIP=`arp $HOSTNAME 2>/dev/null | sed 's/^.*(//;s/).*$//'`
[ `machine` = "alpha" ] || echo "wait..."
uerf -R -r 300 | head -200 | sed '
s/ //
s/OCCURRED ON SYSTEM/Nom du systeme :/
s/OCCURRED.LOGGED ON/Dernier boot le :/
s/(DEC //
s/RZ25./device:& : disque de 0,42 Gbyte/
s/RZ26./device:& : disque de 1 Gbyte/
s/ST32430./device:& : disque de 2 Gbyte/
s/DSP3105./device:& : disque de 1 Gbyte/
s/DPES-31080./device:& : disque de 1 Gbyte/
s/RZ28./device:& : disque de 2,1 Gbyte/
s/RZ55./device:& : disque de 0,33 Gbyte/
s/RZ56./device:& : disque de 0,6 Gbyte/
s/RZ58./device:& : disque de 1,4 Gbyte/
s/RZ29./device:& : disque de 4 Gbyte/
s/RX26./device:& : floppy 2,8 Mbyte externe/
s/fd[0-1] at fdi[0-1] unit [0-1]/ _ device:& : floppy interne/
s/RRD43./device:& : disque CD-rom/
s/RRD42./device:& : disque CD-rom/
s/RRD40./device:& : disque CD-rom/
s/CD-ROM./device:& : disque CD-rom/
s/IMPRIMIS94601.* /device:& : disque de 1 Gbyte/
s/HEXABYTE./device:& : Bande hexabyte/
s/EXABYTE./device:& : Bande exabyte/
s/gd[0-9][0-9]*:/ _ device:& : Graveur CDrom/
' > /tmp/cnfg.tmp
ed - /tmp/cnfg.tmp <<_at__at_ >/dev/null
/ENTRY *2./,\$d
w
q
_at__at_
egrep -s 'ENTRY *1' /tmp/cnfg.tmp
if [ $? -eq 1 ]
then
 echo "Anomalie dans les fichiers log lus par la commande uerf"
 echo operation annulee
 echo Bye...
 exit 1
fi
if [ `machine` = "alpha" ]
then
 #swapon -s | tail -5 >> /tmp/cnfg.tmp
 swapon -s | egrep "partition|Allocated" >> /tmp/cnfg.tmp
elif [ `machine` = "mips" ]
then
 swap=`pstat -s | head -1 | sed 's/k.*//'`
 echo " Taille du swap = `expr $swap \/ 1000`
MB" >> /tmp/cnfg.tmp
fi
#sed -f config.sed /tmp/cnfg.tmp
if [ "$long" = true ]
then
 cat /tmp/cnfg.tmp
fi
echo
------------------------------------------------------------------------
--------------------
grep "Nom du systeme" /tmp/cnfg.tmp
echo
------------------------------------------------------------------------
--------------------
echo "Version Operating system : `uname -a`"
if [ `machine` = "alpha" ]
then
 psrinfo -n | sed 's/number of .*=/nombre de CPU : /'
else
 echo "nombre de CPU : 1"
fi
[ "$nodate" = "false" ] && grep "Dernier boot" /tmp/cnfg.tmp
grep "CPU TYPE" /tmp/cnfg.tmp
echo
echo "Ethernet interfaces :"
egrep "Ethernet|address" /tmp/cnfg.tmp
echo "Adresse IP : $adresseIP"
if [ "$ADRESSEIP" != "$adresseIP" -a "$ADRESSEIP" ]
then
 echo "Adresse IP : $ADRESSEIP"
fi
echo
------------------------------------------------------------------------
--------
echo "Devices:"
egrep "rz[0-9][0-9]*|tz[0-9][0-9]*|device:|gd[0-9][0-9]*" /tmp/cnfg.tmp
#grep device: /tmp/cnfg.tmp
echo
echo
------------------------------------------------------------------------
--------
echo "Memoire et swap"
if egrep -s "real mem" /tmp/cnfg.tmp
then
   memoire=`grep "real mem" /tmp/cnfg.tmp | sed 's/real mem *= //'`
   echo " physical memory = `expr $memoire \/
1048576`.00 megabytes" >> /tmp/cnfg.tmp
fi
grep "physical memory" /tmp/cnfg.tmp
grep Taille /tmp/cnfg.tmp
grep "partition" /tmp/cnfg.tmp | sed 's/^/ /'
tail -1 /tmp/cnfg.tmp | grep "Allocated" | sed 's/ *Allocated space:.*(/
                           Taille du swap = /;s/)//'
#grep "Allocated space:" /tmp/cnfg.tmp | sed 's/ *Allocated space:.*(/
                         Taille du swap = /;s/)//'
#rm /tmp/cnfg.tmp
echo
------------------------------------------------------------------------
--------

------------------------------- CUT HERE -------------------------------

Again,
Many thanks for ALL replies,


Dave

--
Clinical Account Manager, Information Systems
Healthcare Otago (Dunedin NZ)
Ph internal: 8453 External: 64-3-4747699
email: daveb_at_healthotago.co.nz
Pretentious quote of the week:
"SQL is the Fortran of databases - nobody likes it much, the language is
ugly and ad hoc, every database supports it, and we all use it "
John Levine et al. lex & yacc
Received on Sat Feb 01 1997 - 04:04:43 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:47 NZDT