#!/bin/ksh
#
#####
#####  Written by Paul A. Luzzi on 02-01-2002
#####
#####    version 1 written 02-01-2002
#####    version 1.1 updated 07-12-2002 to handle proper sorting
#####    version 1.2 updated 08-21-2002 to handle proper spacing
#####    version 1.3 updated 08-23-2002 to handle k bytes and multi OS
#####
#####  Script name : $BBHOME/ext/hpux_df.sh
#####
#####  Small extension script written for HP-UX to allow the 
#####    the df output to all come out on one line per filesystem
#####    instead of the HP specific "two line" for long f/s names.
#####
#####  Uses bbsys.local's new variable called DFPROPER, and the
#####    bbsys.sh file MUST have its DF entry commented out.
#####    Example lines from configured bbsys.local are as follows :
#####
#####      DF="$BBHOME/ext/hpux_df.sh"
#####      export DF
#####
#####  To test from command line, uncomment the 2 lines above this line
#####    as well as the 7 lines below :
#####
#####      AWK="/usr/bin/awk"
#####      GREP="/usr/bin/grep"
#####      TAIL="/usr/bin/tail"
#####      SORT="/usr/bin/sort"
#####      UNAME="/usr/bin/uname"
#####      DFSORT=5	# field number to sort on - should be % column
#####      export AWK GREP TAIL SORT DFSORT UNAME
#####

#####
#####  Do a quick OS check
#####
OS_TYPE=`$UNAME -s`

#####
#####  Now set $DF options based on OS type
#####
case "$OS_TYPE" in 
  HP-UX ) 
          DFPROPER="/usr/bin/df " 
          DFOPTS=" -Pkl " 
          export DFPROPER DFOPTS 
          ;;
  SunOS ) 
          DFPROPER="/usr/sbin/df " 
          DFOPTS=" -kl " 
          export DFPROPER DFOPTS 
          ;;
  Linux ) 
          DFPROPER="/bin/df " 
          DFOPTS=" -kl " 
          export DFPROPER DFOPTS 
          ;;
  * )     
          DFPROPER="/usr/bin/df " 
          DFOPTS=" -kl " 
          export DFPROPER DFOPTS 
          ;;
esac

#####
#####  Now run the one line disk checker
#####
for device in ` $DFPROPER $DFOPTS | $GREP -v Filesystem | $AWK '$1 ~ /\// {print $1}'` 
 do
   print "$device \t \c"
   $DFPROPER $DFOPTS $device | $TAIL -1 | $AWK ' $1 ~ /^[0-9].[0-9]/ {print $1,"\t",$2,"\t",$3,"\t",$4,"\t",$5} $1 ~ /\// {print "\t"$2,"\t",$3,"\t",$4,"\t",$5,"\t",$6}'
 done | $SORT -n -k $DFSORT

#####
#####  End of hpux_df.sh
#####
