Meny21...
Here's a couple of command procedures I wrote quite some years ago - perhaps not "optimised code", but it does exactly what I need it to... I have taken these everywhere I've worked to manage just the problem you are describing. NOTE: these are two seperate command procedures - the GET_DISK_LIST.COM file is one I call from many other programs... either edit the location to match where you save it to on your system, or hack away and compress the two procedures into a single file. The main procedure CHECK_FILE_VERSIONS.COM can either be run interactively (reports to sys$output), or (as I usually do) add it to my periodic housekeeping routines and then mail the report to myself...
As usual, NO GUARANTEE ot WARRANTY etc with this program - I post it merely to show you how to manage the file limitation - you will need to massage it to get it running on your system! There is no automatic "fixing" of the problem (any files reported you should be investigating manually anyway), but this will alert you to files nearing the limitation. Usually I look for anything at 20,000 versions or more... then kick the developers and tell them to use unique file names instead of depending on versioning...
Hope it helps!
Main Procedure:
$GOTO CHECK_IF_CALLED
$!.......................................................................
$! private_UTILS_NODE:CHECK_FILE_VERSIONS.COM
$!
$! Purpose :-
$!
$! Checks the highest version of a file, and reports if it exceeds
$! a predetermined threshold.
$!
$!
$! Dependancies:-
$!
$! Program private_UTILS_NODE:GET_DISK_LIST.COM must exist.
$!
$!
$! Inputs :-
$!
$! Nil.
$!
$!
$! Outputs :-
$!
$! Mailed report file - see value of 'workfile'.
$!
$!
$! Modifications.
$!---------------
$!
$! Hugh Samson 28/8/98 Implemented.
$!
$!.......................................................................
$Check_If_Called:
$ ! This routine is usually called from DISK_STATUS.COM, which uses
$ ! the file 'reportfile' for output.
$ If f$trnlnm("REPORTFILE") .nes. ""
$ Then
$ say == "WRITE REPORTFILE"
$ Else
$ say == "WRITE SYS$OUTPUT"
$ Endif
$
$Error_Handling:
$ set NOon
$
$Initialize:
$ reqdisk = "''p1'"
$ cur_disk = ""
$ max_ver = 20000
$ ttl_files == 0
$ pid = f$getjpi("","pid")
$ node = f$getsyi("NODENAME")
$
$!.......................................................................
$Mainline:
$
$ If (reqdisk.eqs."").or.(f$edit("''reqdisk'","COLLAPSE,UPCASE").eqs."ALL")
$ Then
$ cur_disk = "ALL"
$ Else
$ cur_disk = "''reqdisk'" - "$1$" - ":" - "_"
$ cur_disk = "$1$''cur_disk':"
$ Endif
$
$ say ""
$ Say " >> Reporting on versions greater than ''max_ver' <<"
$
$ Call Get_Disk_List "''cur_disk'"
$
$ EXIT
$
$!.......................................................................
$Get_File_List: SUBROUTINE
$
$ disk = "''p1'"
$ tmp_files = 0
$
$ File_Loop:
$ file=f$search("''disk'[*...]*.*;")
$ If file .eqs. ""
$ Then
$ if tmp_files .gt. 0
$ then
$ say " "
$ say " >> ''tmp_files' exceed on this disk."
$ else
$ say " "
$ say " All file versions within specs."
$ endif
$ EXIT
$ Endif
$
$ file_ver = f$parse("''file'",,,"version")
$ file_ver = "''file_ver'" - ";"
$ file_ver = f$integer(file_ver)
$
$ If 'file_ver .lt. 'max_ver
$ Then
$ goto file_loop
$ Else
$ tmp_files = tmp_files + 1
$ ttl_files == ttl_files + 1
$ say " --> ''file'"
$ goto file_loop
$ Endif
$ ENDSUBROUTINE
$!.......................................................................
$Get_Disk_List: SUBROUTINE
$
$ If p1 .eqs. "ALL"
$ Then
$ @private_utils_node:get_disk_list
$ count = 1
$ disk_loop:
$ disk = disk_'count'_name
$ Call get_file_list "''disk'"
$ count = count + 1
$ if count .eq. disk_ttl then exit
$ goto disk_loop
$ Else
$ Call get_file_list "''cur_disk'"
$ Endif
$
$ ENDSUBROUTINE
$!.......................................................................
Procedure 2:
$GOTO Startup
$!-----------------------------------------------------------------------------
$! GET_DISK_LIST.COM
$!
$!<>
$! Purpose:
$!
$! This program will obtain a list of disk devices from the system, and
$! define the disk name into global symbols. INFOSERVER and CD-ROM disk
$! units are NOT defined. No handling is provded for software based STRIPE
$! disks. Shadow set MASTERs are listed, shadow set MEMBERS are not.
$!
$!<>
$! Dependancies:
$!
$! None.
$!
$!<>
$! Input/Output:
$!
$! A number symbols are defined :-
$!
$! DISK_TTL. The total number of disk symbols that have been
$! defined.
$!
$! DISK_'nbr'_NAME The name of the disk where 'nbr' relates to the
$! device counter specified. E.G. DISK_1_NAME may
$! translate to "_KWV001$DKB400:"
$!
$!<>
$! Modifications :
$!
$! Hugh Samson ("PiC" @ private) 19/8/1998 Implemented.
$!
$!
$!
$!-----------------------------------------------------------------------------
$!
$Startup:
$
$Get_Disk_List:
$
$ disk_nbr == "" ! Disk sequence nbr
$ disk_ttl == "" ! Total disk count
$
$ Disk_Loop:
$
$ dev = f$device("*","DISK",)
$
$ If "''dev'" .eqs. "" then goto end_disk_loop
$
$ ! Check if shadow set member. (Only want DSA devices)
$ If f$getdvi("''dev'","SHDW_MEMBER") then goto disk_loop
$
$ ! Check if disk is mounted.
$ If .not. f$getdvi("''dev'","MNT") then goto disk_loop
$
$ ! Check if part of SOFTWARE stripeset.
$ If f$getdvi("''dev'","FREEBLOCKS") .eqs. "2076" then -
goto disk_loop
$
$ ! Check if info-server disk.
$ If (f$extract(0,3,dev) .eqs. "DAD") .or. -
(f$extract(0,4,dev) .eqs. "_DAD") -
then goto disk_loop
$
$ ! Check if write-locked (privately mounted).
$ If f$getdvi("''dev'","WCK") then goto disk_loop
$
$ ! Check if attached CD drive.
$ If f$getdvi("''dev'","DEVTYPE") .eqs. "72" then -
goto disk_loop
$
$ disk_nbr == disk_nbr + 1
$ disk_ttl == disk_ttl + 1
$ disk_'disk_nbr'_name == "''dev'"
$
$ goto disk_loop
$
$ End_Disk_Loop:
$
$ If "''disk_nbr'" .nes. "" then dele/sym/glo disk_nbr
$
$ EXIT
$
$!-----------------------------------------------------------------------------
$!
Hope this helps - feel free to laugh if you find the code less than "optimal"
Hugh.