Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: klaus@axp4.physik.fu-berlin.de (Wolfram Klaus)
Subject: Re: finding sys info, processor bits, mem size, etc
Date: 1999/07/16	[thread overview]
Message-ID: <klaus.932111377@axp4.physik.fu-berlin.de> (raw)
In-Reply-To: 378E27A5.B71A6E1D@roguewave.com

Erik Lindberg <lindberg@roguewave.com> writes:

>Im looking for ways to find various DEC sys info such as physical memory
>size, number of processors, etc, hopefully in the form of one or more
>clever unix commands (like hinv for SGI) or utility scripts.  Got any
>ideas?
>Thanks

If you don't mind a C-Program instead of a script, here is what I
hacked together some time ago. It works at least under 4.0x {x>=B}. 
If you invoke it as
    sysinfo AUTO_ACTION
for example it prints out the value of the AUTO_ACTION console
variable in addition to the system information, it noramlly prints out
when invoked without any arguments. Some but not all of the console
variables can be displayed this way.

Here is the code, have fun with it:

/* sysinfo: get system configuration. Args: try to get PROM-Variable */

#include <sys/sysinfo.h>
#include <machine/hal_sysinfo.h>
#include <machine/hal/cpuconf.h>
#include <stdio.h>
#include <stdlib.h>

#define MEM 0
#define CPU 1

/* Sometimes MHZ or MEM or off by 1 (or more?) 
 * Well, not really off, but 600MHz looks better 
 * in the output than 599MHz.
 * The issue with the memory seems to be that, memory 
 * used by the PAL or whatever is substracted from the 
 * physical memory. It looks odd to me having 511MB of RAM.
 * This little ugly helper routine takes care of these two 
 * issues.
 */ 
int normalize (int what, int type)
{
  if (type==MEM)
    return ((what+8)/16)*16;
  else if (type==CPU)
    {
      int actdist,mindist,min,
	trueMHZ[]={0,25,33,50,66,75,100};
      int numMHZ=sizeof(trueMHZ)/sizeof(trueMHZ[0]);
      div_t cpu_MHZ=div(what,100);
      
      min=0;
      mindist=abs(cpu_MHZ.rem-trueMHZ[0]);
      
      while (--numMHZ)
	if ( (actdist=abs(cpu_MHZ.rem-trueMHZ[numMHZ]) ) < mindist)
	  {
	    mindist=actdist;
	    min=numMHZ;
	  }
      
      return 100*cpu_MHZ.quot+trueMHZ[min];
    }
  else
    return what;
}

int main (int argc, char* argv[])
{
  caddr_t buffer[1024];
  char *cpu_name;
  int start, prev_start;
  long proc_type;
  struct cpu_info cpu;
  struct {
    int width;
    int height;
  } res_buffer ={0,0};

  int env;

  /* Machine Name */
  start=0;
  getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &start);
  printf("Machine-Type\t %s\n", buffer);

  /* CPU */
  start=0;
  getsysinfo(GSI_CPU_INFO, &cpu, sizeof(cpu), &start);
  start=0;
  getsysinfo(GSI_PROC_TYPE, &proc_type, sizeof(proc_type), &start);
  proc_type&=0x0000ffff;
  CPU_TYPE_TO_TEXT(proc_type, cpu_name);
  printf("CPUs    \t %d\n"
	 "CPU-type\t %s\n"
	 "Speed   \t %d MHz\n", 
	 cpu.cpus_in_box, cpu_name,  normalize(cpu.mhz, CPU));

  /* Memory */
  start=0;
  getsysinfo(GSI_PHYSMEM, buffer, sizeof(buffer), &start);
  printf("Memory\t\t %d MB\n",  normalize(((int) *buffer) >>10,MEM) );

  /* Graphics */
  start=0;
  getsysinfo(GSI_GRAPHICTYPE, buffer, sizeof(buffer), &start);
  buffer[8]=0;
  start=0;
  getsysinfo(GSI_GRAPHIC_RES, &res_buffer, sizeof(res_buffer), &start);
  if (res_buffer.width!=0) /* Maybe no graphics at all */
    printf("Graphics\t %s (%dx%d)\n", 
	   buffer, res_buffer.width, res_buffer.height);
  /* More Graphics ? */
  while (start)
    {
      prev_start=start;
      getsysinfo(GSI_GRAPHICTYPE, buffer, sizeof(buffer), &start);
      buffer[8]=0;
      printf("Graphics\t %s", buffer);
      getsysinfo(GSI_GRAPHIC_RES, &res_buffer, sizeof(res_buffer), &prev_start);
      printf(" (%dx%d)\n", res_buffer.width, res_buffer.height);
    }

  /* System disk */
  start=0;
  getsysinfo(GSI_BOOTDEV, buffer, sizeof(buffer), &start);
  printf("boot device\t %s\n", buffer);

  /* If command line optins were given, these are prom-variables to be asked */
  for (env=1;  env<argc; env++)
    {
      start=0;
      if ( getsysinfo(GSI_PROM_ENV, buffer, sizeof(buffer), &start, argv[env])
	   !=-1)
	printf("%s\t %s\n", argv[env], buffer);
      else
	printf("%s\t Not in PROM\n", argv[env]);
    }

}

/* End of sysinfo.c */

Bye,
   Wolfram
--
                                       """
                                      (o o)
+---------------------------------oOO--(_)--OOo-------------------------------+
|  Wolfram Klaus     (klaus@physik.fu-berlin.de)        FU Berlin, FB Physik  |



  reply	other threads:[~1999-07-16  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-15  4:00 finding sys info, processor bits, mem size, etc Erik Lindberg
1999-07-16  4:00 ` Wolfram Klaus [this message]
1999-07-17  4:00 ` Adam Price
1999-07-23  4:00 ` Stuart R. Fuller
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox