From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,2c2d4effaf5003c1 X-Google-Attributes: gid1164f8,public From: klaus@axp4.physik.fu-berlin.de (Wolfram Klaus) Subject: Re: finding sys info, processor bits, mem size, etc Date: 1999/07/16 Message-ID: #1/1 X-Deja-AN: 501660818 Content-Transfer-Encoding: 8bit References: <378E27A5.B71A6E1D@roguewave.com> X-Trace: fu-berlin.de 932113698 26551 (none) 160.45.32.195 Organization: Freie Universitaet Berlin X-Access: 16 17 19 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 Newsgroups: comp.sys.dec Erik Lindberg 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 #include #include #include #include #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