#!/bin/sh # $Id: suntype,v 1.10 1999/04/16 22:45:33 jdd Exp $ # # hosttype: Figure out what sort of sun this is. # # Version 2.1 August 14, 1998 # John DiMarco # University of Toronto, Computer Science Laboratory (CSLab) PATH="/bin:/usr/bin:/usr/etc:/usr/sbin:/usr/ucb"; export PATH VERBOSE="VERBOSE no" PROMINFO="yes" # use prtconf/devinfo. Otherwise use hostid only. while getopts vH c; do case $c in v) VERBOSE="VERBOSE yes" ;; H) PROMINFO="no" ;; *) echo "Usage $0 [-v][-H]" 1>&2; exit 3 ;; esac done export VERBOSE PROMINFO # misc function definitions get_hostid() { # Output the host id, if possible echo HOSTID if [ -x /usr/bin/hostid ]; then /usr/bin/hostid 2>/dev/null elif [ -x /usr/ucb/hostid ]; then /usr/ucb/hostid 2>/dev/null fi } get_prominfo() { # Output the output of prtconf/devinfo -pv, if possible echo PROMINFO if [ "yes" = "$PROMINFO" ]; then if [ -x /usr/sbin/prtconf ]; then /usr/sbin/prtconf -pv 2>/dev/null elif [ -x /usr/etc/devinfo ]; then /usr/etc/devinfo -pv 2>/dev/null fi fi } ( echo $VERBOSE cat <0;i--){ digit=substr($2, i, 1); if("a"==digit) digit=10; else if("b"==digit) digit=11; else if("c"==digit) digit=12; else if("d"==digit) digit=13; else if("e"==digit) digit=14; else if("f"==digit) digit=15; clock += digit*pwr; pwr *= 16; } if(!systemclock) systemclock=clock/M } else if($1=="ecache-line-size:" || $1=="cache-line-size:"){ # again, hex to dec. If I was using nawk, I would make # this a function, but early SunOS is nawkless pwr=1; clinesize=0; for(i=8;i>0;i--){ digit=substr($2, i, 1); if("a"==digit) digit=10; else if("b"==digit) digit=11; else if("c"==digit) digit=12; else if("d"==digit) digit=13; else if("e"==digit) digit=14; else if("f"==digit) digit=15; clinesize += digit*pwr; pwr *= 16; } } else if($1=="ecache-nlines:" || $1=="cache-nlines:"){ # again, hex to dec. If I was using nawk, I would make # this a function, but early SunOS is nawkless pwr=1; cnlines=0; for(i=8;i>0;i--){ digit=substr($2, i, 1); if("a"==digit) digit=10; else if("b"==digit) digit=11; else if("c"==digit) digit=12; else if("d"==digit) digit=13; else if("e"==digit) digit=14; else if("f"==digit) digit=15; cnlines += digit*pwr; pwr *= 16; } } else if($1=="name:"){ # process name: # first, concatenate all the pieces name=$2 for(i=3;i<=NF;i++) name=name" "$i # strip off end quotes name = substr(name, 2, length(name)-2) # strip off leading "SUNW," if present if("SUNW,"==substr(name, 1, 5)) name=substr(name, 6, length(name)-5) # strip off leading "Sun " if present if("Sun "==substr(name, 1, 4)) name=substr(name, 5, length(name)-4) if(!systemname){ # the first "name:" is the system name systemname = name } } else if($1=="device_type:"){ if("cpu" == substr($2,2,3)){ iscpu="yes" cpucount++ } } else if($1=="Node"){ if("yes"==iscpu){ if(clock) { cpuclock=clock/M } else { cpuclock=systemclock } cpucache=clinesize*cnlines cpuname=name } iscpu="no" clock=0 } else if($1=="banner-name:"){ i=index($0, ":")+3; banner=substr($0, i+1, length($0)-i-1) } } END{ # process last remaining cpu, if applicable if("yes"==iscpu){ if(clock) { cpuclock=clock/M } else { cpuclock=systemclock } cpucache=clinesize*cnlines cpuname=name } if(0==cpucount) cpucount=1 if(hostid<"80" && "72"!=hostid) { # look up hostid in table if(id[hostid]) { developname=devname[id[hostid]] modelname=model[id[hostid]] if (!cpuname) cpuname=cpu[id[hostid]] if (!systemname || systemname==modelname) systemname=sysname[id[hostid]] if (!cpuclock) cpuclock=clk[id[hostid]] } } else { # look up system name in table if(systemname) { if(nm[systemname]){ developname=devname[nm[systemname]] modelname=model[nm[systemname]] if (!cpuname) cpuname=cpu[id[hostid]] if (!cpuclock) cpuclock=clk[id[hostid]] } } } if(!cpucount) cpucount=1 # Compute known model names. if("_MBUS" == modelname){ # SS10/20/600: Ross 605 or SuperSPARC processors. if(ROSS==ptype[cpuname]) { modelname=1""cpucount""0 } else if("SuperSPARC"==ptype[cpuname]){ if(cpucount==1) cpucount="" if(mtype[cpuclock]) { modelname=mtype[cpuclock]""cpucache/MB""cpucount } } if("_MBUS" == modelname) modelname = "unknown" } else if("_SS5" == modelname || "_SS4" == modelname){ # SPARCstation 4/5: modelname is simply the CPU clock rate modelname=cpuclock } else if ("_XDBUS" == modelname){ # SPARCcenter 1000 or 2000. ccount=cpucount; if(ccount<10) ccount="0"ccount modelname=substr(systemname,13,1)""cpucache/MB""ccount } else if (cpuname ~ /UltraSPARC.*/){ if("Ultra-1"==systemname || "Ultra-5_10"==systemname){ # modelname is clock speed rounded to nearest 10MHz. modelname=10*sprintf "%d\n", ((cpuclock/10)+0.5) } else { # modelname is number of cpus followed by clock speed rounded to # nearest 10MHz modelname=cpucount""10*sprintf "%d\n", ((cpuclock/10)+0.5) } } if(!systemname) systemname="unknown" if(!modelname) modelname=systemname if(!developname) developname="unknown" if(!cpuname) cpuname="unknown" if(!cpuclock) cpuclock="unknown" if(ptype[cpuname]) cpuname=cpuname" ("ptype[cpuname]")" if(cpucache) { if(cpucache>=MB) { cpucache=cpucache/MB" MB" } else { cpucache=cpucache/KB" KB" } } if(!systemclock) systemclock=cpuclock if("yes"==verbose){ # output what we have discovered print "System name:", systemname print "Description:", banner print "Development name:", developname if("_NA"!=modelname) print "Model:", modelname print "Number of cpus:", cpucount print "Cpu name:", cpuname if(systemclock == cpuclock) { print "System/Cpu clock rate (MHz):", cpuclock } else { print "System clock rate (MHz):", systemclock print "Cpu clock rate (MHz):", cpuclock } if(cpucache) print "External cache:", cpucache } else { if("_NA"==modelname) { modelname="" } else { modelname=": "modelname } print systemname, modelname } } '