# This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by David Kleppinger on Tue Sep 12 15:12:48 2000 # # This archive contains: # ratios.README ratios # # Existing files will not be overwritten. # Error checking via wc(1) will be performed. LANG=""; export LANG PATH=/bin:/usr/bin:/usr/sbin:/usr/ccs/bin:$PATH; export PATH if test -f ratios.README then echo Ok to overwrite existing file ratios.README\? read answer case "$answer" in [yY]*) echo Proceeding;; *) echo Aborting; exit 1;; esac rm -f ratios.README if test -f ratios.README then echo Error: could not remove ratios.README, aborting exit 1 fi fi echo x - ratios.README cat >ratios.README <<'@EOF' Program: ratios Author: David Kleppinger dkleppinger@dts.edu Perl script to calculate Read-ahead utilization, Bufwaits Ratio, and Buffer Turnover ratio. Usage: ratios [ []] If no parameters given it runs onstat -p to get the current profile information and does it's calculations. is the name of a file containing the output of a previously run onstat -p. If a is given it will calculate the BTR base on minutes since reset. Warnings: Uses onstat -c to get BUFFERS. If BUFFERS has been changed recently it will report BR/BTR incorrectly when run on a file created before the change. If no parameters are given it requires Jonathan Leffler's sqlcmd to get the time since last reset of the statistics. Future development: Use SMI tables directly instead of onstat. Use DBI::Informix instead of onstat/sqlcmd. Allow BUFFERS to be passed as a parameter. @EOF set `wc -lwc ratios <<'@EOF' #!/usr/bin/perl -T # Perl script to calc informix RAU, BR, and BTR # Written by David Kleppinger (dkleppinger@dts.edu). The idea for # this came from an awk script posted to c.d.i. by Allen J. # Thanks to Art Kagel for the original BR and BTR calculations (and all # the other great info he's posted to c.d.i.) # Requires Jonathan Leffler's sqlcmd to get the time since stats zero. # # Parameters: option filename for stored onstat -p output # if no filename it does an onstat -p on the fly # $doit = 0; $numarg = @ARGV; $infdir = $ENV{'INFORMIXDIR'}; if ($infdir =~ m#^(/[0-9A-Za-z/]+)$#) { $infdir = $1; } else { die "INFORMIXDIR is invalid: $ENV{INFORMIXDIR}\n"; } $ENV{PATH} = "/usr/bin:/bin:$infdir/bin"; if ($numarg > 0) { $onstat = $ARGV[0]; if ($onstat =~ m#^([0-9A-Za-z/.]+)$#) { $onstat = $1; } else { die "Not a valid filename\nUsage: ratios [saved-profile [minutes]]\n"; } open PROFILE, $onstat or die "Can't open $ARGV[0] as an input file.\nUsage: ratios [saved-profile [minutes]]\n"; } else { open PROFILE, "$infdir/bin/onstat -p |" or die "Can't get current profile. Are INFORMIXDIR, ONCONFIG, \& INFORMIXSERVER set?\n"; } while () { chomp; if ($_ eq "Profile") { $doit = 1; } else { if ($doit == 1 && /[a-zA-Z]/) { @name = split; } if ($doit == 1 && /\d/) { @valu = split; $valu = @valu; for ($i = 0; $i < $valu; $i++) { $nv{$name[$i]} = $valu[$i]; } } } } close PROFILE; print "\n"; if ($doit == 0) { print "The input did not appear to be an onstat profile.\n"; exit 1; } else { if ($ENV{ONRATIOS} eq "vt100") { $vt_red = "\e[1;31;47m"; $vt_yellow = "\e[1;33;40m"; $vt_std = "\e[0m"; } else { $vt_red = $vt_yellow = $vt_std = ""; } print " pgsused/(ixda-RA+idx-RA+da-RA)*100\n"; $rau = $nv{'RA-pgsused'}/( $nv{'ixda-RA'}+$nv{'idx-RA'}+$nv{'da-RA'})*100; $color = ""; if ($rau <= 95) { $color = $vt_yellow; } if ($rau <= 90) { $color = $vt_red; } printf("Read-Ahead Util (RAU):%s%6.2f%%%s ", $color, $rau, $vt_std); print "$nv{'RA-pgsused'}/($nv{'ixda-RA'}+$nv{'idx-RA'}+$nv{'da-RA'})*100\n"; $bwr = ($nv{bufwaits}*100) / ($nv{pagreads}+$nv{bufwrits}); $color = ""; if ($bwr > 7) { $color = $vt_yellow; } if ($bwr > 10) { $color = $vt_red; } print "\n bufwaits*100 / (pagreads+bufwrits)\n"; printf("Bufwaits Ratio (BWR): %s%6.2f%%%s ", $color, $bwr, $vt_std); print "($nv{bufwaits}*100) / ($nv{pagreads}+$nv{bufwrits})\n"; open ONCONFIG, "$infdir/bin/onstat -c |" or die "Unable to get onconfig BUFFERS."; while () { if (/^BUFFERS/) { ($descript, $BUFFERS) = split; } } close ONCONFIG; $btmax = ($nv{pagreads}+$nv{bufwrits}) /$BUFFERS; $nv{'%cached'} /= 100; $btmin = ($nv{pagreads}+($nv{bufwrits}*(1 - $nv{'%cached'}))) /$BUFFERS; printf("Buffer Turnover(Max):%7.2f ", $btmax); print "(pagreads+bufwrits)/(BUFFERS=$BUFFERS)\n"; printf("Buffer Turnover(Min):%7.2f ", $btmin); print "(pagreads+(bufwrits*(1-\%cached)))/(BUFFERS)\n"; if ($numarg == 0) { open GETZERO, "echo 'select sh_curtime - sh_pfclrtime from sysshmvals;'|sqlcmd -d sysmaster|" or exit 0; $zerotime = or die "Unable to get profile clear time through sqlcmd.\n"; close GETZERO; $btrmax = $btmax * 60 * 60 / $zerotime; $btrmin = $btmin * 60 * 60 / $zerotime; printf(" BT Period-max:%7.2f/hr every %5.2f minutes.\n", $btrmax, 60/$btrmax); printf(" BT Period-min:%7.2f/hr every %5.2f minutes.\n", $btrmin, 60/$btrmin); } else { if ($numarg == 2 && $ARGV[1] > 0) { $btrmax = $btmax * 60 / $ARGV[1]; $btrmin = $btmin * 60 / $ARGV[1]; printf(" BT Period-max: %7.2f/hr every %5.2f minutes.\n", $btrmax, 60/$btrmax); printf(" BT Period-min: %7.2f/hr every %5.2f minutes.\n", $btrmin, 60/$btrmin); } else { print " (BTR): Unable to calculate, period not known.\n"; } } } print "\n"; @EOF set `wc -lwc