03 April 2010

Oracle Database 11.2 for windows release

The 11.2 release for windows x64 has now been released on OTN. We'll have to wait for 32 bits.

03 March 2010

Columns showing active databases

When I logon to a server with a large number of databases on it, I like to see what instances are active. When the list is growing, a simple grep on e.g. pmon processes would not give a nice list. Columns can be created with the pr command:

ls /usr/bin | pr -T4 -W$

The screenwidth in a script can be found with the $(tput cols) variable or - outside a script - with the $COLUMNS variable. Putting it all together gives me the following, which can be sourced in .bash_profile if you like. Nice thing is, that the number of columns is variable and will change depending on your screenwidth.

# Determine number of columns to use
MINCOLWD=10 # minimum column width
SCRNCHAR=$(( $(tput cols) )) # screen width
NROFCOLS=$(( $SCRNCHAR / $MINCOLWD )) # number of columns


ps -ef | grep pmon | grep -v 'grep pmon' | awk '{ print substr($8,10,10) }' | sort | pr -T${NROFCOLS} -W${SCRNCHAR} > list_db.tmp
cat list_db.tmp
#
# Determine number of active databases
NRACTDB=`ps -ef | grep pmon | grep -v 'grep pmon' | wc -l`
echo \>\> Total: $NRACTDB databases active


The output looks like this:

ABCONT61  COVUG02   DPSONT   ESYUNTD1  LNXBTR01
ABCONT62  CRILS30T  DPSTST   GFKONT    LNXTTO 
BRFP01    CRILS61   ECWCTST  HBJSONT   OAADB  
BKDWHO    CRILS61T  ECWPTST  INOKDS01  SQWWUR 
BKDWHT    CRILS62
>> Total: 26 databases active

17 February 2010

format columns in awk with printf

I was struggling with awk to display the diskspace on my Linux host in the most convenient way. One problem was that a df command splits the output on two lines, but this is fixed by df -P.

Formatting the output with awk required using printf instead of print. With printf you can give formatting to the columns. I came on the following which is seems very usefull in my case.

oracle@myserver:~> df -Ph | awk '{ printf "%-12s%8s\n", $6 , $5 }'

Mounted Use%

/ 9%

/dev 1%

/boot 10%

/home 4%

/opt 31%

/tmp 20%

/usr 52%

/var 11%

/data 15%

/backup 83%