1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # ident "@(#)tp_getsysinfo.ksh  1.2     08/12/19 SMI"
  27 #
  28 
  29 
  30 LOGFILE=${LOGDIR}/mkdir.out
  31 
  32 #
  33 # NAME
  34 #       gather_system_info
  35 #
  36 # SYNOPSIS
  37 #       gather_system_info
  38 #
  39 # DESCRIPTION
  40 #       This function gathers various hardware/software configuration
  41 #       information about the system and places it in the TET execution
  42 #       log.
  43 #
  44 # RETURN VALUE
  45 #       undefined
  46 #
  47 function gather_system_info {
  48         #
  49         # Paths to system commands called by this script
  50         #
  51         CAT=/usr/bin/cat
  52         ISAINFO=/usr/bin/isainfo
  53         LS=/usr/bin/ls
  54         NAWK=/usr/bin/nawk
  55         NM=/usr/ccs/bin/nm
  56         PRTCONF=/usr/sbin/prtconf
  57         PSRINFO=/usr/sbin/psrinfo
  58         TMPDIR=/tmp
  59         UNAME=/usr/bin/uname
  60 
  61         # File to store temporary data in
  62         TMPFILE=${TMPDIR}/newinfo_tmp_$$
  63         
  64         # File to write output to
  65         OUTPUT=${TMPDIR}/sysinfo_$$
  66         
  67         # Divider for visual formatting
  68         DIVIDER="----------------------------------------------------------------------"
  69         
  70 
  71         #
  72         # Datestamp
  73         #
  74         DATE=`/usr/bin/date`
  75         echo "Date:         $DATE" >$OUTPUT
  76         
  77         #
  78         # Hostname
  79         #
  80         HOSTNAME=`/usr/bin/hostname`
  81         echo "System Name:  $HOSTNAME" >>$OUTPUT
  82         echo $DIVIDER >>$OUTPUT
  83         
  84         #
  85         # Identify the operating system.  Use 'uname -a' output and the
  86         # contents of /etc/release if it exists (present on 2.6 and later).
  87         #
  88         echo "Operating System:" >>$OUTPUT
  89         echo "  'uname -a' output:\n    \c" >>$OUTPUT
  90         $UNAME -a >>$OUTPUT
  91         if [[ -r /etc/release ]]; then
  92                 echo "  Contents of /etc/release" >>$OUTPUT
  93                 cat /etc/release >>$OUTPUT
  94         fi
  95         #
  96         # Use 'isainfo' to determine what version of the OS is running (32 or
  97         # 64 bit) on sparc systems.  This command doesn't exist prior to
  98         # Solaris 7, so make sure it exists before attempting to run it.
  99         #
 100         echo "  'isainfo' output:  \c" >>$OUTPUT
 101         if [[ -x $ISAINFO ]]; then
 102                 ARCH=`$ISAINFO`
 103                 echo $ARCH >>$OUTPUT
 104         else
 105                 echo "Not available." >>$OUTPUT
 106         fi
 107         #
 108         # Try to determine if we're running a debug or non-debug kernel.  In
 109         # order to do so we need /usr/ccs/bin/nm which may or may not be
 110         # present depending on what install cluster was applied.
 111         #
 112         echo "  Kernel type (debug or non-debug):  \c" >>$OUTPUT
 113         if [[ -n "$ARCH" && -x $NM ]]; then
 114                 if [[ "$ARCH" = "sparcv9 sparc" ]]; then
 115                         MD_FILE=/kernel/drv/sparcv9/md
 116                 elif [[ "$ARCH" = "amd64 i386" ]]; then
 117                         MD_FILE=/kernel/drv/amd64/md
 118                 else
 119                         MD_FILE=/kernel/drv/md
 120                 fi
 121                 if /usr/ccs/bin/nm $MD_FILE | grep md_in_mx >/dev/null
 122                 then
 123                         echo "debug" >>$OUTPUT
 124                 else
 125                         echo "non-debug" >>$OUTPUT
 126                 fi
 127         else
 128                 echo "unknown (need $ISAINFO and $NM to determine)" >>$OUTPUT
 129         fi
 130 
 131         echo $DIVIDER >>$OUTPUT
 132         
 133         echo "Hardware:" >> $OUTPUT
 134         
 135         #
 136         # System type
 137         #
 138         $PRTCONF > $TMPFILE
 139         SYSTEM=`grep "^SUNW" $TMPFILE|$NAWK ' BEGIN { FS = "," } { print $2 } ' - `
 140         if [[ -z "$SYSTEM" ]]; then
 141                 SYSTEM="(No Sun system hardware ID found in prtconf output)"
 142         fi
 143         echo "  System Type:  $SYSTEM" >>$OUTPUT
 144         
 145         #
 146         # Memory size
 147         #
 148         MEMORY=`grep "Memory size:" $TMPFILE|$NAWK ' BEGIN { FS = ":" } { print $2 }' -`
 149         echo "  Memory Size: $MEMORY" >>$OUTPUT
 150         
 151         #
 152         # Retrieve processor information
 153         #
 154         echo "CPU(s):       #      Type        Speed" >>$OUTPUT
 155         echo "|             ---  ----------  -------" >>$OUTPUT
 156         $PSRINFO -v >$TMPFILE
 157         $NAWK ' BEGIN { proc_count = 0 } { if ( $1 == "Status" )
 158                  {
 159                    arr[proc_count,0] = $5
 160                    proc_count++
 161                  }
 162                  if ( $3 == "processor" && $4 == "operates" )
 163                  {
 164                    arr[proc_count -1,1] = $2
 165                    arr[proc_count -1,2] = $6
 166                  }
 167                }
 168                END {
 169                  for ( i = 0; i < proc_count; i++ )
 170                  {
 171                         printf("|             %-3d  %-10s  %s MHz\n",arr[i,0],arr[i,1],arr[i,2]);
 172                  }
 173                } ' $TMPFILE >>$OUTPUT
 174         echo $DIVIDER >>$OUTPUT
 175         
 176         cti_reportfile $OUTPUT
 177         rm -f $TMPFILE $OUTPUT
 178 }
 179 
 180 
 181 #
 182 # TET 'test purpose' function that's actually just a wrapper for the
 183 # gather_system_info function.
 184 #
 185 function getsysinfo {
 186         cti_assert getsysinfo "Gather general system info for lofi tests"
 187         gather_system_info
 188 
 189         cti_pass
 190 }