Re: script for dbspace usage
Posted in 1996
Topics: Storage & Space Management, Stored Procedures & SPL
This is a multi-part message in MIME format.
--------------85857E736D6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Tony Reynolds (Acc & Purchasing Helpdesk) wrote:
>
> Has any one got a script to
> enable me to see pages free, %age used of
> dbspaces for online 7.
> I have a script but it disregards dbspaces with
> multiple chunks.
> The script I've got uses awk on the output of
> onstat -d and I dont know> enough about awk to modify it.
> Can anyone help??
> Tony Reynolds :-))
> tr-3475@necadmin.necvenues.co.uk
> The National Exhibition Centre Ltd
Well, I had the same idea, so I wrote some lines of C which should do the
job (see the attached file).
BUT : you must know about a bug in online 7 (we have 7.12 on an HP9000
K200). This bug makes the output from onstat -d inconsistent under
certain conditions that Informix Support can't find out. Then, the only
way for finding free space in chunks is examining the output of the
oncheck -pe command. For example, have a look at this !!! :
INFORMIX-OnLine Version 7.12.UC1 -- On-Line -- Up 1 days 23:56:46 --
139072 Kbytes
Dbspaces
address number flags fchunk nchunks flags owner name
c45990e8 1 2 1 1 M informix rootdbs
c459a3e0 2 1 2 1 N informix dbsiege
c459a448 3 1 3 1 N informix datadbs2
c459a4b0 4 1 4 1 N informix datadbs3
c459a518 5 1 5 1 N informix datadbs4
c459a580 6 1 6 4 N informix datadbs1
c459a5e8 7 1 7 1 N informix dbref
c459a650 8 1 8 1 N informix idxdbs3
c459a6b8 9 1 9 2 N informix idxdbs4
c459a720 10 1 10 1 N informix dbstat
c459a788 11 1 11 1 N informix idxdbs2
c459a7f0 12 1 12 1 N informix dbcde
c459a858 13 1 13 2 N informix idxdbs1
c459a8c0 14 2001 14 1 N T informix tempdbs1
c459a928 15 2001 16 1 N T informix tempdbs3
c459a990 16 2001 15 1 N T informix tempdbs2
16 active, 2047 maximum
Chunks
address chk/dbs offset size free bpages flags pathname
c4599150 1 1 2 200000 48849 PO-
/dev/informix/rootdbs
c4599228 1 1 2 200000 0 MO-
/dev/informix/mrootdbs
c4599300 2 2 2 175000 9153 PO-
/dev/informix/dbsiege
c45993d8 3 3 2 900000 17181 PO-
/dev/informix/datadbs2
c45994b0 4 4 2 900000 -73041 PO-
/dev/informix/datadbs3
c4599588 5 5 2 800000 388926 PO-
/dev/informix/datadbs4
c4599660 6 6 2 640000 643 PO-
/dev/informix/datadbs1
c4599738 7 7 2 150000 45638 PO-
/dev/informix/dbref
c4599810 8 8 2 1000000 110220 PO-
/dev/informix/idxdbs3
c45998e8 9 9 2 900000 4426 PO-
/dev/informix/idxdbs4
c45999c0 10 10 2 150000 12691 PO-
/dev/informix/dbstat
c4599a98 11 11 2 850000 86612 PO-
/dev/informix/idxdbs2
c4599b70 12 12 2 150000 65209 PO-
/dev/informix/dbcde
c4599c48 13 13 2 700000 146382 PO-
/dev/informix/idxdbs1
c4599d20 14 14 2 100000 99721 PO-
/dev/informix/tempdbs1
c4599df8 15 16 2 100000 99509 PO-
/dev/informix/tempdbs2
c4599ed0 16 15 2 100000 43892 PO-
/dev/informix/tempdbs3
c4599fa8 17 6 2 50000 0 PO-
/dev/informix/datadbs1.1
c459a080 18 6 2 511998 108056 PO-
/dev/informix/datadbs1.2
c459a158 19 9 2 511998 50500 PO-
/dev/informix/idxdbs4.1
c459a230 20 6 512002 528382 528379 PO-
/dev/informix/datadbs1.3
c459a308 21 13 2 153598 9963 PO-
/dev/informix/idxdbs1.1
21 active, 2047 maximum
Did you notice the free space for /dev/informix/datadbs3 ??? (Bug fixed
in 7.2...)
I hope I've been helpfull.
Valery FOUQUES, Go Sport - France.
--------------85857E736D6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="TBSTATD.C"
#include <stdio.h>
#include <stdlib.h>
struct dbspace {
int number;
char name[20];
long int total_size;
long int free_size;
};
int main()
{
FILE *infile;
struct dbspace names[64];
int i;
int p;
int number;
char *s;
char *num;
char *tfree;
char *tsize;
/* Creation des fichiers des places informix */
system("/usr/informix/bin/tbstat -d|grep -e\\" N \\" -e\\" M \\"|awk '{ n=split($0,a); print $2\\"|\\"$n\\"|\\" }'>/tmp/tbstat.d1");
system("/usr/informix/bin/tbstat -d|grep \\"P[O|D]-\\"|awk '{ print $3\\"|\\"$5\\"|\\"$6\\"|\\" }'>/tmp/tbstat.d2");
/* Allocation de quelques ressources */
s=malloc(200);
num=malloc(12);
tfree=malloc(64);
tsize=malloc(64);
/* Recuperation du nom des dbspaces */
number=0;
infile=fopen("/tmp/tbstat.d1","r");
fgets(s,100,infile);
while (!feof(infile))
{
for(i=0,p=0;s[i]!='|';num[p]=s[i],p++,i++);
num[p]=0;
number++;
names[number].number=atoi(num);
for(i++,p=0;s[i]!='|';names[number].name[p]=s[i],p++,i++);
names[number].name[p]=0;
names[number].total_size=0;
names[number].free_size=0;
fgets(s,100,infile);
}
fclose(infile);
/* Recuperation des infos sur les dbspaces */
infile=fopen("/tmp/tbstat.d2","r");
fgets(s,100,infile);
while (!feof(infile))
{
for(i=0,p=0;s[i]!='|';num[p]=s[i],p++,i++);
num[p]=0;
for(i++,p=0;s[i]!='|';tsize[p]=s[i],p++,i++);
tsize[p]=0;
for(i++,p=0;s[i]!='|';tfree[p]=s[i],p++,i++);
tfree[p]=0;
i=atoi(num);
names[i].total_size+=atol(tsize);
names[i].free_size+=atol(tfree);
fgets(s,100,infile);
}
fclose(infile);
/* Liberation de la memoire */
free(s);
free(num);
free(tfree);
free(tsize);
/* Affichage des resultats */
printf("+--------------+----------+----------+---+\\n");
printf("+ dbspace + total + free + %% +\\n");
printf("+--------------+----------+----------+---+\\n");
for(i=1;i<=number;i++)
{
printf("|%-14s|%10u|%10u|%3u|\\n",names[i].name,names[i].total_size,names[i].free_size,100*names[i].free_size/names[i].total_size);
}
printf("+--------------+----------+----------+---+\\n");
/* Effacement des fichiers (pour etre propre...) */
Related threads
- IDS 10 table-level restore
- DBPATH & INFORMIXSERVER - HELP
- Informix Development Webinar December 11, 2007
- ontape -p/r with changed ROOTPATH
- Migrate from HP PA-RISC to HP ITANIUM by ontape