From: buddy@netcom.com (larry d. clark) Subject: Database size report(perl) Newsgroups: comp.databases.informix Date: Sun, 16 Apr 1995 14:37:04 GMT netlanders: here is a perl script i wrote to produce a report on individual database size for online 5.xx. it should work with online 6.xx & 7.xx. i hope someone finds it useful. brickbats & flames > /dev/null. bouquettes & alocades appreciated. larry d. clark buddy@netcom.com #cut to here #!/usr/bin/perl sub commas { local($_) = @_; l while s/(.*\d)(\d\d\d)/$1,$2/; "$_"; } $raw_file = "/tmp/tbcheck.out"; $rpt_file = "/tmp/database.rpt"; # get the raw file to work on $cmd = `tbcheck -pe > $raw_file`; system($cmd); # sort it $cmd = `sort -o $raw_file $raw_file`; system($cmd); # the machine name @flds = split(' ', `uname -a`); $mach_name = $flds[1]; # the system date $the_date = `date`; $user_name = " "; # open the input file for reading open(INFILE, "<$raw_file") || die "can't open $raw_file\n"; # open the report file open(OUTFILE, ">$rpt_file") || die "can't open $rpt_file\n"; printf OUTFILE "\nDatabase Usage Report Date : %s\n", $the_date; printf OUTFILE "System: %s\n\n", $mach_name; $usr_tot = 0; $mas_tot = 0; # while there is input while () { chop($_); if (length($_) < 2) { next; } # make everything lower case $_ =~ tr/A-Z/a-z/; # throw away all informix tables if ($_ =~ ".sys") { next; } if ($_ =~ "chunk") { next; } # throw away extent warnings if ($_ =~ "warning") { next; } # throw away free messages if ($_ =~ "free") { next; } if ($_ =~ "----------") { next; } if ($_ =~ "other reserved pages") { next; } if ($_ =~ "database tblspace") { next; } if ($_ =~ "logical log pages") { next; } if ($_ =~ "tblspace tblspace") { next; } if ($_ =~ "physical log pages") { next; } if ($_ =~ "root dbspace reserved pages") { next; } if (/^ /) { next; } if ($_ =~ "dbspace usage report") { next; } # break up initial line @flds = split(' ', $_); @flds1 = split(':', $flds[0]); if ($user_name ne $flds1[0]) { if ($usr_tot > 0) { $usr_tot = do commas($usr_tot); printf OUTFILE "Total Usage for %-18.18s %18.18s pages\n", $user_name, $usr_tot; $usr_tot = 0; } $user_name = $flds1[0]; } $usr_tot += $flds[2]; $mas_tot += $flds[2]; } if ($usr_tot > 0) { $usr_tot = do commas($usr_tot); printf OUTFILE "Total Usage for %-18.18s %18.18s pages\n", $user_name, $usr_tot; } $mas_tot = do commas("$mas_tot"); printf OUTFILE "\nTotal usage %s pages\n", $mas_tot; close(OUTFILE); exit;