#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # dbspace-space.sh dbspace-space.txt # # This shell archive created: Tue Aug 10 07:14:22 CDT 1999 # echo "Extracting file dbspace-space.sh" sed -e 's/^X//' <<\SHAR_EOF > dbspace-space.sh X#!/usr/bin/ksh X# dbspace-space.sh - Display vital stats on all dbspaces X# Author: Jacob Salomon X# JakeSalomon@netscape.net X# Jun 16, 1999 X# XUNL0=/tmp/aaa0-$$.unl XUNL1=/tmp/aaa1-$$.unl Xdbaccess sysmaster - <<%% Xselect d.name dbspace, X d.dbsnum, X c.chknum chunknum, X c.chksize pages, c.nfree FreePages, X trunc((((c.chksize - c.nfree)/c.chksize)*100), 2) PercentF X from sysmaster:sysdbspaces d, X sysmaster:syschunks c X where d.dbsnum = c.dbsnum X into temp dbs_chunks; X Xunload to $UNL1 Xselect dbspace, dbsnum, X count(*) nchunks, X sum(pages) tot_pages, X sum(freepages) free_pages, X round((((sum(pages) - sum(freepages))/sum(pages)) * 100), 2) X pcnt_full X from dbs_chunks X group by dbsnum, dbspace X order by dbsnum, dbspace; Xdrop table dbs_chunks; X%% Xcat >$UNL0 <<%% XDB-Space|DBS-Num|NumChunks|TotPages|FreePages|%-Full| X%% Xsed -e 's/\.0|/|/g' $UNL1 >>$UNL0 Xbeautify-unl.sh $UNL0 Xrm $UNL0 $UNL1 SHAR_EOF if [ `wc -c < dbspace-space.sh` -ne 971 ] then echo "Lengths do not match -- Bad Copy of dbspace-space.sh" fi echo "Extracting file dbspace-space.txt" sed -e 's/^X//' <<\SHAR_EOF > dbspace-space.txt XTitle: dbspace-space.sh XAuthor: Jacob Salomon X JakeSalomon@netscape.net XDate: 1999-07-27 XPrerequisite Program: beautify-unl.sh X XShort Description: X A relatively quick & painless utility to display the space available X in all dbspaces in the current system. X XLong Description: X XOne of the tasks that fall to the typical DBA or Informix system Xadministrator is to insure that the dbspaces in the running system do Xnot fill to capacity. When this event does occur the users begin to get Xerror messages to the effect that "Device is full" and the DBA quickly Xgets irate calls from users or help-desk operators. The shell-script Xdbspace-space.sh runs an SMI query to get this information and then Xuses the utility "beautify-unl.sh" to display the information in neat Xcolumns suitable for a spreadsheet import. X XNote that you can obtain the beautify-unl.sh utility from the IIUG Xsoftware archives at URL: Xhttp://www.iiug.org/members/memb_software/archive/beautify_unl X XThere are no parameters; you simply run the script (assuming its Xlocation is in your PATH) and it runs. Since it runs an SMI query X(i.e. against the "sysmaster" pseudo-database) you will see messages Xlike "Database selected" and "13 rows selected into temp" etc. If these Xare a distraction you can redirect standard error to /dev/null. X XExample 1: Generic run. X---------------------------------------------------------------------- X X$ dbspace-space.sh X XDatabase selected. X X X17 row(s) retrieved into temp table. X X X12 row(s) unloaded. X X XTable dropped. X X X XDatabase closed. X XDB-Space |DBS-Num|NumChunks|TotPages|FreePages|%-Full| Xrootdbs | 1| 1| 100000| 97739| 2.26| Xphys_dbs | 2| 1| 250000| 1947| 99.22| Xlog_dbs | 3| 2| 1512000| 521944| 65.48| Xtmp_dbs1 | 4| 1| 256000| 231311| 9.64| Xtmp_dbs2 | 5| 1| 256000| 231231| 9.68| Ximm_dbs | 6| 3| 2500000| 631074| 74.76| Ximm_frag1 | 7| 1| 1000000| 584546| 41.55| Ximm_frag2 | 8| 1| 1000000| 584546| 41.55| Xbook_dbs | 9| 1| 500000| 392599| 21.48| Xindexdbs | 10| 1| 524288| 524235| 0.01| Xscratchdbs| 11| 3| 3145725| 3145666| 0| Xalpha_dbs | 12| 1| 1048575| 90128| 91.4| X---------------------------------------------------------------------- X XExample 2: Run with stderr redirected: X---------------------------------------------------------------------- X$ dbspace-space.sh 2>/dev/null X XDB-Space |DBS-Num|NumChunks|TotPages|FreePages|%-Full| Xrootdbs | 1| 1| 100000| 97747| 2.25| Xphys_dbs | 2| 1| 250000| 1947| 99.22| Xlog_dbs | 3| 2| 1512000| 521944| 65.48| Xtmp_dbs1 | 4| 1| 256000| 231349| 9.63| Xtmp_dbs2 | 5| 1| 256000| 231269| 9.66| Ximm_dbs | 6| 3| 2500000| 631074| 74.76| Ximm_frag1 | 7| 1| 1000000| 584546| 41.55| Ximm_frag2 | 8| 1| 1000000| 584546| 41.55| Xbook_dbs | 9| 1| 500000| 392599| 21.48| Xindexdbs | 10| 1| 524288| 524235| 0.01| Xscratchdbs| 11| 3| 3145725| 3145666| 0| Xalpha_dbs | 12| 1| 1048575| 90128| 91.4| X---------------------------------------------------------------------- XEOF SHAR_EOF if [ `wc -c < dbspace-space.txt` -ne 3316 ] then echo "Lengths do not match -- Bad Copy of dbspace-space.txt" fi echo "Done." exit 0