About the FreeBSD Daemon

Friends


Shepherd Business Group

Andersen Cabinet

Service Sales Corporation

Schmit Prototypes

Floral Merchandising Systems

Diskcopy vom Steinig Tal, Sch2

CSS v2Valid?

Hit Counter

Sintr.sh Bourne Shell Script


The sintr.sh script creates a text file called "/tmp/sintr/mybox.txt" containing important information about the configuration of the PC's hardware and FreeBSD operating system. This report should be copied to removable media for system recovery or informational purposes.


Download sintr.sh.gz

Place the sintr.sh script in your /usr/local/bin/ directory and set the owner/group to root/wheel and the permissions to 0700 (rwx------).

To invoke a sintr.sh session you would enter as root:

# /usr/local/bin/sintr.sh

Best results for sintr.sh are obtained by rebooting and using boot -v at the "ok" boot loader, creating a much more detailed report of detected hardware and settings.

A /boot/loader.conf.local file can be created or edited and adding this following line will cause the system to always use verbose mode when booting:

boot_verbose="YES"

From the sintr.sh startup message:

sintr.sh looks for mounted hard drives devices at /dev/ad[0-9] for IDE, and at /dev/da[0-9] for SCSI. If you have hard drives that are not mounted when sintr.sh is run they will not show up in your report.

Simple non-raid hard drive configurations are assumed, if you have disk devices with names other than /dev/ad* or /dev/da*, or more than 9 SCSI hard drives, the disk drive portions of the report will be incomplete or incorrect.

You may want to bring your network and internet connections up before running sintr.sh for a more complete network report.

Script source for sintr.sh:

#!/bin/sh

# /usr/local/bin/sintr.sh
# Created by Stephen Hilton  nospam@hiltonbsd.com
# Tuned for FreeBSD 4.x, should be adaptable to other *NIX systems.
# Last update: 01-16-2002
# Version: 01.05.00

################################################################################
# All of the documentation and software included in sintr releases
# is copyrighted by Stephen Hilton.
# Copyright 2001 Stephen Hilton. All rights reserved. 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution. 

# THIS SOFTWARE IS PROVIDED BY STEPHEN HILTON AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL STEPHEN HILTON OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
################################################################################


# "System INformation To Report", sintr.sh is a script that collects system
#  information to a text log file, hopefully for safe storage on a backup disk.
# Simple hard drive configurations are assumed, only FreeBSD mounted devices
#  are probed. If you have a disk installed but not mounted, it will not report.
# Mounted IDE devices on /dev/ad[0-9] and mounted SCSI devices on /dev/da[0-9]
#  are what "sintr" probes for disk information.
# If your hard drive configuration is different, or you have more than 9 SCSI
#  drives, or a raid configuration, your results may be incorrect!
# Best results are obtained with a verbose boot dmesg log, you can edit
#  /boot/loader.conf.local and add the entry  boot_verbose="YES" to get
#   a verbose boot everytime.

# Thanks to Jim Conner (SnafuX/NOTJames) for help with this script :-)

#################################
# user editable variables follow.

# your logging directory, no spaces, and no trailing slash please.
mydir="/tmp/myboxreport"

# your log file name, no spaces in log file name please.
mybox="mybox.txt"

# end of user editable variables.

# set the prompt for the report
PS1=`hostname -s`"#"

# create the "target file" name variable.
mylogf="$mydir/$mybox"
#################################


################################
# start my defined functions.
# mybanner, mydash, myerrret, mylogcmd, mylogdrv, mylogit, mypound.


# Function "mybanner" creates up to a 3 line banner for the target file.
mybanner ()
{
     mypound
       if [ `echo $1 | wc -c` -gt "1" ]
         then
             mylogit "$1"
       fi

       if [ `echo $2 | wc -c` -gt "1" ]
         then
             mylogit "$2"
       fi

       if [ `echo $3 | wc -c` -gt "1" ]
         then
             mylogit "$3"
       fi
      mypound
     mylogit
}


# Function "mydash" directs a dash bar into the target file.
mydash ()
{
  mylogit "-----------------------------------------------\
--------------------------------"
}


# Function "myerrret" creates an error return code and text message regarding
#  the specific error. The $1 argument is the return value from $myerrcode
#   the $2 argument is the text message defined in $myerrmsg.
myerrret ()
{
       if [ $myerrcode -ne 0 ]
         then
              echo $2
              exit $1
      fi 
}


# Function "mylogcmd" directs output from the shell commands defined
#  in "$mycmd" into the target file, or displays "Not available",
#   if no command output is forthcoming.
# $mycmd is in the format "mount -p" which would be a command you would run
#  from the command line as root. Optionally you can follow your system command
#   with 3 "at" signs "@@@" then a text comment that will be displayed after
#    the "Command used:" line as a "Comment:" line in the banner.
mylogcmd ()
{
    mycomment=`echo $mycmd | sed "s/^.*@@@//"`
    mycmd=`echo $mycmd | sed "s/@@@.*$//"`

       if [ "$(eval $mycmd | wc -l)" -gt 0 ]
          then
              mydash
               mylogit "Command used: $PS1 $mycmd"

                if [ `echo "$mycomment" | wc -c` -gt 1 ]
                  then
                      if [ "$mycomment" != "$mycmd" ]
                        then
                             mylogit "     Comment: ""$mycomment"
                      fi
                fi

               mylogit
               sh -c "$mycmd 2>/dev/null >> $mylogf"
               mylogit
               mylogit
         else
               mydash
               mylogit "Command used: $PS1 $mycmd"
               mylogit " Not available"
               mylogit
               mylogit
       fi
}


# Function "mylogdrv"
mylogdrv ()
{
          mycmd="fdisk $z"
           if [ `$mycmd > /dev/null 2>&1;echo $?` = 0 ]
             then
                  mylogcmd "$mycmd"
            else
                  mypound
                  mylogit "       \"$mycmd\" failed"
                  mylogit "    Possibly due to no partitions on $z"
                  mypound
                  mylogit
                  mylogit
           fi 

          mycmd="disklabel -r $z"
           if [ `$mycmd > /dev/null 2>&1;echo $?` = 0 ]
             then
                  mylogcmd "$mycmd"
           else
                  mypound
                  mylogit "       \"$mycmd\" failed"
                  mylogit "    Possibly due to no disklabel on $z"
                  mypound
                  mylogit
                  mylogit
           fi 
}


# Function "mylogit" directs text lines to the target file.
mylogit ()
{
      echo -e "$1" >> $mylogf
}


# Function "mypound" directs a hash bar into the target file.
mypound ()
{
  mylogit "#########################################\
######################################"
}
# end my defined functions.
################################


################################
# pull in the static information

# get the name this script is using
myprog=$(/usr/bin/basename $0)

# get the system name.
mysysname=`uname -n`
################################


################################
# write the info screen.

  clear

echo "$myprog looks for mounted hard drives devices at /dev/ad[0-9] for IDE,"
echo "and at /dev/da[0-9] for SCSI. If you have hard drives that are not"
echo "mounted when $myprog is run they will not show up in your report."
echo
echo "Simple non-raid hard drive configurations are assumed, if you have a more"
echo "complex configuration, or more than 9 SCSI hard drives, your report will"
echo "be incomplete or incorrect."
echo
echo "Using the \"boot -v\" option at the \"ok\" boot loader"
echo "will allow a better dmesg report on your hardware."
echo 
echo "You may want to bring the network and internet connections up before\
 starting"
echo "a $myprog session, for a more complete network report."
echo 
echo "Your text report file is named \"$mylogf\"."
echo 

    while true
     do
       echo -n "Enter C to continue, Q to quit: "
        read answer
         answer=`echo $answer | tr "[:lower:]" "[:upper:]"`

          if [ "$answer" = "C" ]
            then
                 echo "  Working ..."
                 break
          fi

          if [ "$answer" = "Q" ]
            then
                exit 0
          fi
    done

# done with info screen
################################


################################
# error, you are not root.
UID=$(/usr/bin/id | cut -d = -f 2 | awk -F '(' '{print $1}')
    if [ $UID != 0 ]
      then
       myerrcode="3"
       myerrmsg="You must be superuser to use $myprog"
       myerrret "$myerrcode" "$myerrmsg"
    fi

# does $mydir exist, if not, create it with perms.
      if [ ! -d "${mydir}" ]
        then
             mkdir -m 0700 "$mydir" > /dev/null 2>&1
      fi

# check/set the directories owner.
    myerrcode=$(chown root.wheel $mydir > /dev/null 2>&1;echo $?)
    myerrmsg="Problem with chown root.wheel $mydir"
    myerrret "$myerrcode" "$myerrmsg"

# check/set the directories permissions.
    myerrcode=$(chmod 0700 $mydir > /dev/null 2>&1;echo $?)
    myerrmsg="Problem with chmod 0700 $mydir"
    myerrret "$myerrcode" "$myerrmsg"

# create or empty the target file.
    myerrcode=$(cat < /dev/null > "$mylogf" > /dev/null 2>&1;echo $?)
    myerrmsg="Problem with writing to $mylogf"
    myerrret "$myerrcode" "$myerrmsg"

# check the target files owner.
    myerrcode=$(chown root.wheel "$mylogf" > /dev/null 2>&1;echo $?)
    myerrmsg="Problem with chown root.wheel $mylogf"
    myerrret "$myerrcode" "$myerrmsg"

# check the target files permissions.
    myerrcode=$(chmod 0600 "$mylogf" > /dev/null 2>&1;echo $?)
    myerrmsg="Problem with chmod 0600 $mylogf"
    myerrret "$myerrcode" "$myerrmsg"

# All set up, target file is perm 0600 owned root.wheel,
#  in a directory perm 0700 owned root.wheel.
################################


################################
# get the date, time, and TZ.
myontime=$(date "+%m-%d-%Y %H:%M:%S %Z")

# run function mybanner
    mybanner "             Started $myprog session at: $myontime"  \
             "              For the computer named: $mysysname"

# Ready to gather storage information.

# you can follow your system command with 3 "at" signs "@@@" then a comment
# that will be displayed after the "Command used:" line as a "Comment:" line.

    for mycmd in  \
       "mount -p@@@What do we have mounted"       \
       "cat /etc/fstab@@@What do we mount"        \
       "df -k@@@Any drive space left?"            \
    ; do
        mylogcmd $mycmd
    done

# get the IDE info.

mydrvtyp="IDE"

mydrvsel=`mount | cut -c6-8 | grep 'ad[0-9]' | uniq | sort`

mydrvnum=`echo $mydrvsel | wc -w`

mydrvnum=`expr $mydrvnum`

 mybanner "                        $mydrvtyp DEVICE INFORMATION"  \
     "               Total number of mounted $mydrvtyp drives found: $mydrvnum"

    for z in $mydrvsel ;
       do
          mylogdrv
    done

# end IDE HD info.

# get the SCSI info.

mydrvtyp="SCSI"

    mydrvsel=`mount | cut -c6-8 | grep 'da[0-9]' | uniq | sort`

mydrvnum=`echo $mydrvsel | wc -w`
mydrvnum=`expr $mydrvnum`

 mybanner "                        $mydrvtyp DEVICE INFORMATION"  \
     "               Total number of mounted $mydrvtyp drives found: $mydrvnum"

    for z in $mydrvsel ;
       do
          mylogdrv
    done

# end SCSI HD info.
################################


################################
    mybanner "                        BASIC SYSTEM INFORMATION"

    for mycmd in                                                        \
       "uname -a@@@System name and version"                             \
       "uptime@@@How long have we been running"                         \
       "set@@@Show roots shell environment"                             \
       "cat /etc/auth.conf@@@Show the /etc/auth.conf file"              \
       "cat /etc/passwd@@@Show the /etc/passwd file without passwords"  \
       "cat /etc/group@@@Show the /etc/group file"                      \
       "cat /etc/rc.conf@@@Show the /etc/rc.conf file"                  \
       "cat /boot/loader.conf@@@Show the /boot/loader.conf file"        \
       "cat /boot/loader.conf.local@@@Show the /boot/loader.conf.local file" \
       "cat /etc/X11/XF86Config@@@Show the /etc/X11/XF86Config file"    \
       "/usr/bin/strings -n 3 /kernel | sed -n "s/^___//p"@@@Use \"options \
        INCLUDE_CONFIG_FILE\" in your kernel configuration"             \
       "ls -lao /@@@Show the / directory"                               \
       "top -S -t -d 1@@@Top system processes"                          \
       "ps -wwaux@@@Show all system processes"                          \
       "cat /var/run/dmesg.boot@@@Show the dmesg boot output"          \
       "sysctl -a | grep -v '^<'@@@Sysctl settings"                     \
    ; do
        mylogcmd $mycmd
    done
################################


################################
    mybanner "                           NETWORK INFORMATION"

     for mycmd in  \
        "hostname@@@Show systems hostname"                              \
        "ifconfig -a@@@Show all network interfaces"                     \
        "netstat -nr@@@Show the routing table"                          \
        "netstat -na@@@Show listening ports, connections, and domain sockets"  \
        "sockstat@@@Show sockets information"                           \
        "cat /etc/exports@@@Show the NFS /etc/exports file"             \
        "cat /etc/hosts@@@Show the /etc/hosts file"                     \
        "cat /etc/hosts.allow@@@Show the /etc/hosts.allow file"         \
        "cat /etc/hosts.equiv@@@Show the /etc/hosts.equiv file"         \
        "cat /etc/host.conf@@@Show the /etc/host.conf name lookup order"\
        "cat /etc/resolv.conf@@@Show the /etc/resolv.conf name resolver order" \
        "named -v@@@Show the version of named"                          \
        "cat /etc/namedb/named.conf@@@Show the /etc/namedb/named.conf file"    \
        "testparm -s@@@Show Samba info, if installed"                   \
     ; do
         mylogcmd $mycmd
     done

# currently set to report on Bind "8" versions, probably could use commands
#  to handle finding and reporting on Bind "9" installation,
#   solutions to this problem would be appreciated.

# the nmap $mycmd will introduce error/informational messages to the screen
#  while it is running, this does not show in your report, but is messy
#   solutions to this problem would be appreciated.
#        "nmap -n -v -sT -sU -P0 127.0.0.1@@@Portscan your localhost"    \
################################


################################
# get the date, time, and TZ.
myofftime=$(date "+%m-%d-%Y %H:%M:%S %Z")

    mybanner " End report for $mysysname at $myofftime"

# lets see it! #

if [ -x /usr/bin/less ]
  then
      /usr/bin/less $mylogf
else
      /usr/bin/more $mylogf
fi    
################################
# End of script.
################################

Corrections? / Additions? / Suggestions? / Links?
Please email any and all such to:


nospam@hiltonbsd.com