Need script to monitor extent size

Alegre

New Member
Would anyone be able to provide a script or guidelines for one that monitors the size of the last variable extent of each Progress database on UNIX and LINUX servers and then if the size excedes a defined limit would generate an email?
Thanks
 

mwm

New Member
/* File Name : hc/db-extent-chk
Description : checks file size of fixed DB extents (found in list# var)
Date Written : 05/29/03 by MWM
Date Modified: 01/23/04 by MWM - allow for more than 1 extent
*/

def var i as int.
def var name# as char.
def var list# as char init "controls_7.d2,controls_8.d3".
def var file-size# as int.

repeat i = 1 to num-entries(list#):
name# = entry(i,list#).
/* Start input from the "fs" command & skip the first line */
unix silent value ("ls -l /db-location/" + name# + " > " + name# + ".lst").
input from value (name# + ".lst").
import ^ ^ ^ ^ file-size#.
input close.

/* use this for testing
if file-size# > 100000 then unix silent value
("mail -s 'DB extent size warning!' user.name@domain.com"
+ " < " + name# + ".lst").
*/
if file-size# > 1535000000 then unix silent value
("mail -s 'DB extent size warning!' user.name@domain.com < "
+ name# + ".lst").
end.
 

jcarrell

New Member
I wish I'd have seen the other script earlier. This is what I came up with, it monitors only the last file and sends an e-mail to root with the extent causing the problem.

#!/bin/bash
#This script looks at the growable extents and monitors to make sure none are
#approching the 2GB limit. If one is getting close it will send out an e-mail
#Written 7/20/2004
#Author Jim Carrell
wd=/fastt1/db/prod/mfg/db
logfile=/root/extentsize_prod
logfile1=/root/extentsize_temp
/usr/bin/touch $logfile
listf=`ls $wd/mfgprod_* | /usr/bin/cut -f 1 -d . | /usr/bin/uniq`
for i in $listf
do
ls -alr $i* | /usr/bin/head -1 >> $logfile
done
/usr/bin/cat $logfile | /usr/bin/sort -n +4 | /usr/bin/awk '{ printf ("%5d %s\n", ($5 / 1024 + 0.999), $9) }'>$logfile1
mv $logfile1 $logfile
exec < $logfile
while read line
do
var1=`echo $line | awk '{print $1}'`
var2=`echo $line | awk '{print $2}'`
if [ $var1 -gt 1800000 ]
then
mail -I -s "Alert Extent Size nearing capacity" root <<- ENDOFMAIL
Extent $var2 is close to the 2GB limit
------------------------------------------------------------
~r $logfile
ENDOFMAIL
fi
done
 

vinod_home

Member
Hi,


----------
cd <dbdir>

find . -size +600000000c -print | xargs ls -l

---------

would give you all the files greater than 512000 area size. Change the value of size to whatever you want and then email that to a person or alias...

HTH
 

jcarrell

New Member
Thanks for the reply.

We were looking to just monitor the last growable extent, so when it approches the limit an e-mail is sent out. We don't need daily reports just a notice when things are getting close to the limit, which is what mine does in an ugly manner.

-Jim
 

JTWilson

New Member
Here's a piece of code that might do something close to what you want... but I don't promise anything.


Code:
/*Process Each Area of the DB*/
FOR EACH _AreaStatus
NO-LOCK:
/*Set the variables*/
ASSIGN iv_LastExtentSize = 0
	   lv_OnLastExtent   = NO.

/*Used to find all the area information like block size*/
FIND _Area WHERE _Area._Area-number = _AreaStatus._AreaStatus-Areanum 
	NO-LOCK NO-ERROR.

/*Process each Extent for the Data Area*/
FOR EACH _AreaExtent WHERE _AreaExtent._Area-RecID = RECID(_Area)
NO-LOCK:
	/*find the actual file information about current area extent*/
	FIND _FileList WHERE ENTRY(NUM-ENTRIES(_FileList._FileList-Name, cv_Delimiter),
										 _FileList._FileList-Name, cv_Delimiter)
						 = ENTRY(NUM-ENTRIES(_Areaextent._Extent-Path, cv_Delimiter),
											 _Areaextent._Extent-Path, cv_Delimiter)
	   NO-LOCK.

	/*Check if running on the Last extent*/
	IF _FileList-Name = _AreaStatus-LastExtent
	THEN DO:
		ASSIGN lv_OnLastExtent = YES.
			 /*busy_flag = "****"*/

		/*if _FileList._FileList-Extend = 0 FIXED.  Other > 0 Variable*/
		IF _FileList._FileList-Extend > 1 
		THEN DO:
		 /*There is a need to estmate the last extent size if not already fix preallocated*/
		 /*iv_LastExtentSize = INT((2 * (1024 * 1024 * 1024)) / _Area._Area-blocksize).*/
			iv_LastExtentSize = 2 * (1024 * 1024 * 1024).
			ASSIGN /*Apx 2GB - FileArea Used Space to give free about*/
				 /*iv_LastExtentSize = iv_LastExtentSize - _FileList._FileList-Size.*/
				 iv_LastExtentSize = iv_LastExtentSize 
								 - (_FileList._FileList-Size * _FileList._FileList-BlkSize).

		 /*DISP iv_LastExtentSize FORMAT "->>>,>>>,>>>,>>9"
				 _FileList._FileList-Size FORMAT "->>>,>>>,>>>,>>9"
			   WITH FRAME ftmp.*/
		END.
	END.  /*IF _FileList-Name = _AreaStatus-LastExtent*/
END.  /*FOR EACH _AreaExtent...*/
 
wow

wow, all that work just to check the last extent?
there should be a few empty fixed extents in between the last variable extent that should be used up before the variable extent starts getting used, and it should take quite a while before the fixed extents get used up. If you have a last variable extent that is being used and growing it's time to add more extents anyway. I just check the last extent once a week to see if it has started growing. If it has I make plans to add more extents.
 
Top