SUMMARY: Old SunOS questions.

From: Matthew Atkinson (m.atkinson@csl.gov.uk)
Date: Mon Apr 19 1999 - 09:08:38 CDT


Dear All,

Thanks to everyone for the answers to my SunOS memory and swap
questions. I think I now know what I need to know to monitor my
firewall.

My questions were:

1. How to find out the amount of physical memory in the computer.

   Many people told me either to use dmesg or to look in the file
   /usr/adm/messages. However, both of these only work if your last
   boot is still recorded in the messages file. The machine I am
   trying to work on produces around 20MB of messages per day, and
   the files are renamed and gzipped every day. Even doing this, I
   still only keep one months worth of messages, so I didn't have
   a reboot in these files.

   Some suggested sysinfo, but I didn't really have the time to go
   downloading utilities just to find out how much memory I had.

   However, the star of the show was Jay Lessert of Lattice
   Semiconductor Corp. in America, who sent me a short C program
   which just reports on memory. A quick cc, a.out and I had my
   answer. Quite why they didn't build this into SunOS is beyond
   me! Thanks a lot Jay, and I've attached the program in case
   anyone else is interested.

2. How to find out how much swap space there is?

   The answer is pstat -s, which gives the same type of output as
   swap -s, although SunOS seems to lack the equivalent of swap -l,
   so you can't find out the number, names or sizes of the swap
   files.

3. How to add and/or delete swap files?

   The answer is that to add a swap file, you make it with mkfile
   (or use a raw partition of a disc), and then add it using swapon,
   which appears to be the equivalent of swap -a. You can also add
   it to /etc/fstab, for permanent addition.

   Jochen Bern reminded me of a long distant memory, that SunOS has
   an error in calculating the available memory, such that 64MB RAM
   plus a 64MB swap file = 64MB, rather than 128MB. I assume that
   this means if I expand the memory to 128MB, I will also need to
   expand my swap partition, therefore meaning that I have to
   either add a new disc, or repartition the existing one. Oh joy
   of joys! The wonders of SunOS! Clarification of this point would
   be gladly received.

   Most people told me that SunOS does not have a command for
   removing swap space (except for re-booting), so once you've added
   it you're stuck. Someone however told me about swapoff, which
   appears to me a figment of his imagination.

After all this, I'm still not quite sure how low my machine is on
memory. A snapshot gives me 49016k available on pstat -s, vmstat
under the column memory fre gives 6696 (k), and top tells me 7376K
availble. If top and vmstat are right, I need more memory, but if
pstat -s is right, I've got plenty. Thanks to previous respondents
I now know that the machine has 64MB physical memory, and 64MB swap
in one partition.

Thanks for the help, and looking forward to any more memory
assistance.

Matthew.

P.S. I can't wait for the firewall software to be upgraded to
     Solaris! At least I'll be able to administer it.

-- 
-------------------------------------------------------------------
Matthew Atkinson                      Phone:  +44 (0) 1904 462120
Sun Systems Technical Administrator   Fax:    +44 (0) 1904 462111
Information Systems Team
Central Science Laboratory            E-mail: m.atkinson@csl.gov.uk
Sand Hutton, York, YO41 1LZ, England  Web:    http://www.csl.gov.uk
-------------------------------------------------------------------

/*
 * $Header: /galileo0/jayl/pdsrc/mem/RCS/mem.c,v 1.5 1993/04/09 17:24:06 jayl Exp $
 * Figure out how much memory there is on a machine. This works under
 * Berkeley UNIX. It should work under System V if you change the
 * UNIX define to "/unix" instead of "/vmunix".
 *
 * Of course, if you don't have read permission on the kernel and
 * kernel memory, this won't work.
 *
 * Dave Curry
 * Purdue University
 * Engineering Computer Network
 *
 * Hacked by Larry Breniser 10/1/91
 * Pagesize is now determied dynamically, not at copile
 * time, as it varies from host to host (server vs workstation)
 *
 * davy@intrepid.ecn.purdue.edu
 * $Header: /galileo0/jayl/pdsrc/mem/RCS/mem.c,v 1.5 1993/04/09 17:24:06 jayl Exp $
 * $Log: mem.c,v $
 * Revision 1.5 1993/04/09 17:24:06 jayl
 * add -v (verbose) flag, report single physmem in KB by default. JDL
 *
 * Revision 1.4 1991/12/20 00:22:53 jdd
 * Initial revision
 *
 * Revision 1.3 91/10/02 17:51:10 larryb
 * Added Version string to executable for ident.
 *
 * Revision 1.2 91/10/02 17:46:21 larryb
 * Added RCS log comments.
 *
 */
#include <sys/param.h>
#include <sys/types.h>
#include <nlist.h>
#include <stdio.h>
#include <string.h>

char version[] = "$Header: /galileo0/jayl/pdsrc/mem/RCS/mem.c,v 1.5 1993/04/09 17:24:06 jayl Exp $";

#define UNIX "/vmunix"
#define KMEM "/dev/kmem"

struct nlist nl[] = {
#define X_PHYSMEM 0
        { "_physmem" },
#define X_MAXMEM 1
        { "_maxmem" },
        { NULL }
};

main(argc,argv)
int argc;
char *argv[];
{
        int kmem;
        int maxmem, physmem;
        int pagesize;
        int verbose = 0;
        /*
         * check command line arguments
         */
        if (argc > 1) {
                    if (strcmp(argv[1], "-v")==0) {
                            verbose++;
                }
                else {
                        printf("Usage: %s [-v]\n", argv[0]);
                        exit(1);
                }
        }
        /*
         * Look up addresses of variables.
         */
        if ((nlist(UNIX, nl) < 0) || (nl[0].n_type == 0)) {
                fprintf(stderr, "%s: no namelist.\n", UNIX);
                exit(1);
        }
        /*
         * Open kernel memory.
         */
        if ((kmem = open(KMEM, 0)) < 0) {
                perror(KMEM);
                exit(1);
        }
        /*
         * Read variables.
         */
        lseek(kmem, (long) nl[X_PHYSMEM].n_value, 0);
        read(kmem, (char *) &physmem, sizeof(int));
        lseek(kmem, (long) nl[X_MAXMEM].n_value, 0);
        read(kmem, (char *) &maxmem, sizeof(int));
        close(kmem);
        pagesize=getpagesize();
        /*
         * Print the numbers. The internal representation is
         * in units of core clicks; convert to Kbytes for default
         # or bytes for verbose.
         */
        if (verbose) {
                printf("Pagesize: %d\n", pagesize);
                printf("Physical machine memory: %d\n", pagesize * physmem);
                printf("Max memory available to a process: %d\n", pagesize * maxmem);
        }
        else {
                printf("%d\n", pagesize * physmem / 1024);
        }
        exit(0);
}





This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:13:18 CDT