Skip to content
Snippets Groups Projects
bootinfo 3.55 KiB
Newer Older
#!/bin/sh
#File: 		bootinfo
#Description: 	get info from the IOC_LASTBOOTED database table
#Author:	D.Zimoch
#Parameters:    
function help() {
luedeke's avatar
luedeke committed
    echo "usage: $(basename $0) [options] [pattern]"
    echo "  Find boot information about %pattern% in database"
    echo "options are:"
    echo "  -h, -?, --help : print this help and quit"
    echo "  -v, --version  : print cvs version info and quit"
luedeke's avatar
luedeke committed
    echo "  -d : print BOOTDATE"
    echo "  -t : print BOOTTIME"
    echo "  -b : print BOOTPC"
    echo "  -S : print SLSBASE"
    echo "  -E : print EPICS version"
    echo "  -V : print vxWorks version"
    echo "  -i : print IP_ADDR"
    echo "  -A : print ARCH"
    echo "  -a : print a lot (= -dtbSEViA)"
    echo "  -L : log (print all reboots, not only last)"
luedeke's avatar
luedeke committed
    echo "  -x : do exact query, i.e. do not append '%' to search pattern"
luedeke's avatar
luedeke committed
    echo "  --noheader : don't print table header"
    echo "  -- : treat next word as pattern, even if starting with -"
    exit 0
}
function version() {
    echo 'Author: D. Zimoch'
luedeke's avatar
luedeke committed
    echo '$Date: 2006/04/26 08:16:09 $'
    echo '$Source: /cvs/G/DRV/misc/App/scripts/bootinfo,v $'
    exit 0
}
luedeke's avatar
luedeke committed
HSEL="SYSTEM AS IOC"
DEFAULTSEL=",BOOTDATE,BOOTTIME,BOOTPC,SLSBASE,
            EPICSVER AS EPICS,VXWORKSVER AS VXWORKS,IPADDR AS IP_ADDR,
            SUBSTR(VXWORKS,INSTR(VXWORKS,'/',-1,2)+1,
            INSTR(VXWORKS,'/',-1,1)-INSTR(VXWORKS,'/',-1,2)-1) AS ARCH"
TABLE="IOC_LASTBOOTED"
zimoch's avatar
zimoch committed
ORDER="IOC,TO_DATE(BOOTDATE||' '||BOOTTIME,'DD-MM-YYYY HH24:MI:SS')"
luedeke's avatar
luedeke committed
JOKER="%"
while true
do
zimoch's avatar
zimoch committed
  case "$1" in
luedeke's avatar
luedeke committed
    --noheader) OPTS="SET HEADING OFF;" ;;
    -*h* | -*\?* | --help) help ;;
    -*v* | --version) version ;;
    --) shift; break ;;
luedeke's avatar
luedeke committed
    -*) OPTION=$1
        while true
        do
        OPTION=${OPTION:1}
        case "$OPTION" in
            d*) SEL="$SEL,BOOTDATE" ;;
            t*) SEL="$SEL,BOOTTIME" ;;
            b*) SEL="$SEL,BOOTPC" ;;
            E*) SEL="$SEL,EPICSVER AS EPICS" ;;
            V*) SEL="$SEL,VXWORKSVER AS VXWORKS";;
            i*) SEL="$SEL,IPADDR AS IP_ADDR" ;;
            e*) SEL="$SEL,ETHADDR AS ETH_ADDR" ;;
            S*) SEL="$SEL,SLSBASE" ;;
            A*) SEL="$SEL,SUBSTR(VXWORKS,INSTR(VXWORKS,'/',-1,2)+1,
                INSTR(VXWORKS,'/',-1,1)-INSTR(VXWORKS,'/',-1,2)-1) AS ARCH" ;;
            f*) SEL="$SEL,VXWORKS AS FILENAME" ;;
            a*) OPTION=-dtbSEViA${OPTION:1} ;;
            L*) TABLE="IOC_BOOTLOG" ;;
luedeke's avatar
luedeke committed
            x*) JOKER="" ;;
luedeke's avatar
luedeke committed
            "") break ;;
            *)  echo "Unknown option -${OPTION:0:1}. Try: --help"
                exit 1 ;;
        esac
        done  ;;
zimoch's avatar
zimoch committed
    *)  break ;;
  esac
  shift
if [ -d /usr/oracle-9.2 ] ; then
        export ORACLE_HOME=/usr/oracle-9.2
else
        export ORACLE_HOME=/usr/oracle-8.1.7
	export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
fi
luedeke's avatar
luedeke committed
eval $(resize 2>/dev/null)
luedeke's avatar
luedeke committed
pattern="$JOKER$1$JOKER"
$ORACLE_HOME/bin/sqlplus -s ssrm_public/pub01@psip0 << EOF
SET PAGESIZE 10000;
luedeke's avatar
luedeke committed
SET LINESIZE ${COLUMNS:-120};
SET FEEDBACK OFF;
luedeke's avatar
luedeke committed
$OPTS
COLUMN IOC FORMAT A17;
COLUMN SLSBASE FORMAT A7;
COLUMN EPICS FORMAT A7;
COLUMN VXWORKS FORMAT A7;
COLUMN ARCH FORMAT A15;
maden's avatar
maden committed

luedeke's avatar
luedeke committed
SELECT ${HSEL} ${SEL:-$DEFAULTSEL}
FROM SSRM.${TABLE}
luedeke's avatar
luedeke committed
WHERE  SYSTEM     LIKE '$pattern' OR
       BOOTPC     LIKE '$pattern' OR
       SLSBASE    LIKE '$pattern' OR
       EPICSVER   LIKE '$pattern' OR
       VXWORKSVER LIKE '$pattern' OR
       ETHADDR    LIKE '$pattern' OR
       IPADDR     LIKE '$pattern' OR
       VXWORKS    LIKE '$pattern'
zimoch's avatar
zimoch committed
ORDER BY ${ORDER};
maden's avatar
maden committed

EXIT
EOF
# $Name:  $
luedeke's avatar
luedeke committed
# $Id: bootinfo,v 1.15 2006/04/26 08:16:09 luedeke Exp $
# $Source: /cvs/G/DRV/misc/App/scripts/bootinfo,v $
luedeke's avatar
luedeke committed
# $Revision: 1.15 $