Announce: IDSspaces Beta Disk Usage Tool For Linux IDS 7.30
Posted in 1999
I'd like to release this for testing, as I don't have a very complex
system on Linux, and would like to see if it works correctly for a
variety of systems. It's also been stripped down from another version
I used on XPS. This one appears to work correctly but I'd like some
feedback from you. ( Yes it's free! ) If you are interested in the
XPS version please contact me.
Enjoy!
--
-
--
--- Tim Schaefer
---- tschaefe@mindspring.com
--- http://www.inxutil.com
--
-
#!/bin/sh
################################################################################
# begin doc
# Program: IDSspaces
# Author: Tim Schaefer, tschaefe@mindspring.com
# Login: timmy
# Created: April 1997
# Description: IDSspaces reports on dbspace usage for a particular instance.
# The report is based on your ONCONFIG setting. You can add
# UNIX sort parameters to this program on the command line to
# format the output.
# Usage: IDSspaces [ S | L ] [ "wildcard" ]
#
# where:
# S - Space Information
# or
# L - Link Information
# H - Show Help
# and an optional:
#
#
# wildcard - An optional quoted pattern for a dbspace name
#
# NOTE: YOU MUST SET YOUR LINK_DIR TO WHERE YOUR DISK LINKS RESIDE
# This program currently has LINK_DIR=/opt/db
#
# TESTED ONLY ON LINUX WITH INFORMIX 7.30
#
#-------------------------------------------------------------------------------
# PVCS/RCS Information
#-------------------------------------------------------------------------------
# $Revision: $
# $Author: $
# $State: $
# $Date: $
# $Locker: $
# $Log: $
#-------------------------------------------------------------------------------
# end doc
################################################################################
AWK=awk
TMP=/tmp
DBACCESS=dbaccess
LINK_DIR=/opt/db/
DATA_FILE=${TMP}/${LOGNAME}.IDSspaces.dat
LINK_DATA=${TMP}/${LOGNAME}.IDSlinks.dat
NEW_DATA=${TMP}/${LOGNAME}.IDSmerge.dat
RAW_RPT=${TMP}/${LOGNAME}.IDSspaces.raw
page_size=`onstat -b | grep "buffer size" | awk ' { print $10 } '`
################################################################################
mrg_link_data()
{
awk -F"|" ' BEGIN { link_file="'${LINK_DATA}'"
base_name="";
i=0;
}
{
link=$2
bas_cnt = split ( link, bas_arr, "/" )
base_link= bas_arr[bas_cnt]
lset=0
{ printf ( "%s", $0 ) }
while ( lset == 0 )
{
getline linkdrive < link_file
drv_cnt = split ( linkdrive, drv_arr, "|" )
for ( i = 0 ; i <= drv_cnt ; ++i )
{
{ if ( drv_arr[i] == base_link )
{
{ printf ( "%s|%s|\\n", drv_arr[i], drv_arr[++i] ) }
close ( link_file )
lset=1
}
}
}
}
}
' ${DATA_FILE} > ${NEW_DATA}
mv ${NEW_DATA} ${DATA_FILE}
}
################################################################################
#
# Be sure to set LINK_DIR to point to the correct directory where your links
# or dbspaces exist. Tested only with cooked files, not links.
#
bld_link_data()
{
ls -l $LINK_DIR | grep ^- | awk ' BEGIN { link_dir="'$LINK_DIR'" }
{
{ if ( length($9) > 0 )
{
{ printf( "%s|%s|\\n", link_dir, $9) }
}
}
}
' > ${LINK_DATA}
}
################################################################################
match_dbs()
{
$DBACCESS sysmaster 2>/dev/null <<+
SET ISOLATION TO DIRTY READ ;
UNLOAD TO "${DATA_FILE}"SELECT
sysdbspaces.name,
syschunks.fname,
syschunks.offset,
sysdbspaces.dbsnum,
syschunks.chknum,
sysdbspaces.fchunk,
"X",
syschunks.chksize,
syschunks.nfree,
CURRENT
FROM sysdbspaces, syschunks
WHERE sysdbspaces.dbsnum = syschunks.dbsnum
AND sysdbspaces.name matches "$WILDCARD"
ORDER BY 1
+
}
################################################################################
gather_all_dbs()
{
$DBACCESS sysmaster 2>/dev/null <<+
SET ISOLATION TO DIRTY READ ;
UNLOAD TO "${DATA_FILE}"SELECT
sysdbspaces.name,
syschunks.fname,
syschunks.offset,
sysdbspaces.dbsnum,
syschunks.chknum,
sysdbspaces.fchunk,
"X",
syschunks.chksize,
syschunks.nfree,
CURRENT
FROM sysdbspaces, syschunks
WHERE sysdbspaces.dbsnum = syschunks.dbsnum
ORDER BY 1,5
+
}
################################################################################
print_header()
{
echo "Informix DB Space Report `date` "
}
################################################################################
gen_raw_data()
{
${AWK} -F"|" ' BEGIN { page_size='$page_size' ;
name="" ; fname="" ; offset=0 ; dbsnum="" ; chknum="" ;
fchunk="" ; chksize=0 ; nfree=0 ; current="" ;
linkdisk=""; used_pages=0 ;
pct_free=0 ; ttl_kb=0 ; free_kb=0 ; used_kb=0 ;
}
{
name=$1
fname=$2
offset=$3*2
dbsnum=$4
chknum=$5
fchunk=$6
ttl_pages=$8
free_pages=$9
current=$10
linkdisk=$12
used_pages=ttl_pages-free_pages
pct_free=((1-free_pages/ttl_pages)*100)
ttl_kb=(((ttl_pages - free_pages)*page_size)/1000)
free_kb=((free_pages*page_size)/1000)
used_kb=((ttl_pages*page_size)/1000)
{ printf("%3d %3d X %20s %6s %8d %8d %8d %6.2f %8d %8d %8d\\n",\\
dbsnum, chknum, name, offset, ttl_pages, free_pages, used_pages, \\
pct_free, ttl_kb, free_kb, used_kb ) }
}
' ${DATA_FILE} > ${RAW_RPT}
}
################################################################################
print_space_info()
{
$AWK ' BEGIN {
title="O"; last_title="O";
avg_free_space=0.00 ;
avg_avg=0.00 ;
cntr=0 ;
disk_drive="" ;
t_ttl_pages=0 ; t_free_pages=0 ; t_used_pages=0 ; t_pct_full=0 ;
t_ttl_kb=0 ; t_free_kb=0 ; t_used_kb=0 ;
}
{
arr_cnt = split( $4, name_arr, "\\." );
title=name_arr[1];
avg_free_space+=$9
++cntr
{ if ( NR == 1 )
{
{ printf("%s\\n", title ); }
print_header() ;
}
}
{ if ( ( last_title != title ) && ( NR != 1 ) )@