Find out how much Space is Being Used by Tables

Tbstat -d gives you an output that shows the raw information necessary to calculate the free space in your database, but it is not organized in a way that is easy to comprehend.

This script, a C-Shell script called dbdf, does a much cleaner job:

#!/bin/csh
#dbdf
$INFORMIXDIR/bin/tbstat -d | grep / | grep -v bpages | sort +2 -3 -n |awk
'{printf ("%s	*s	%s	%s
", $3, $5, $6, $8) }' > /tmp/c$$
$INFORMIXDIR/bin/tbstat -d | grep informix | awk '{print $2, $8}' > /trap/s$$
join /tmp/s$$ /tmp/c$$ > /tmp/j$$
awk '
BEGIN {name=""} 
{total[$2]+=$3; free[$2]+=$4} 
END { for (space in total) printf("%-12s is %.2f percent full and has %6d free pages 
", space,
(1-free [space]/total[space])*100,free[space])} ' /tmp/j$$ | grep -v log
rm /tmp/c$$ /tmp/s$$ /tmp/j$$

This script uses tbstat -d and massages the output with grep and awk. It creates three temporary files in the /tmp directory that are erased at completion of the script. These files will be cXXXXX, sXXXXX, and jXXXXX where the XXXXX is the script's process id number (PID). This PID number is created by the $$ construct as used in rm /tmp/c$$ /tmp/m$$ /tmp/j$$. The second tbstat command makes one assumption. It assumes that the owner of all of the Informix chunks is user informix. If for some reason you have a custom installation that does not follow this convention, you will need to modify the grep informix. The last statement before the UNIX command rm /tmp/c$$ contains another section of code that you may want to modify. It uses a grep -v log to exclude any lines that contain the word log. All of my logs are in separate dbspaces that are called logSOMETHING. Since the space utilization of these logspaces does not vary (the logs are allocated and take up space whether they're full or not), I'm not interested in monitoring changes in the space utilization of these dbspaces. If you use similar conventions in naming your chunks and dbspaces, you may want to use a similar exclude statement.

Place the script in your $INFORMIXDIR/local_bin directory and chmod it to be executable by whomever you wish to give the right to run dbdf. This program does not understand multiple OnLine instances. If you want to make it do so, you'll have to pass it a parameter for the name of the $TBCONFIG file and have it set the $TBCONFIG environment variable to the passed value and then run the script.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.255.127