$! SHARED_IMAGES.COM - see EOF for doc
$ old_verify = f$verify (0)
$ set noon
$ say := write sys$output
$ ask := read/end_of_file=exit/error=exit sys$command command/prompt=
$ status = 1
$ required_privs = "OPER"
$ old_privs = f$setprv (required_privs)
$ if .not. f$privilege (required_privs)
$ then
$ say "Required privs: " + required_privs
$ status = 36
$ goto exit
$ endif
$ default_disk = f$trnlnm ("SYS$SYSDEVICE", "LNM$SYSTEM_TABLE")
$get_disk:
$ ask "Disk to report on [''default_disk']: "
$ the_disk = f$edit (command, "collapse,upcase,uncomment")
$ if the_disk .eqs. ""
$ then
$ the_disk = default_disk
$ endif
$ node_list = ""
$ report_dir = f$trnlnm ("sys$scratch")
$ temp1 = f$unique () + ".tmp"
$ if .not. f$getsyi ("cluster_member")
$ then
$ goto not_cluster
$ endif
$ ctx = ""
$ cut_off = 1
$node_loop:
$ csid = f$csid (ctx)
$ if csid .eqs. ""
$ then
$ goto end_node_loop
$ endif
$ node = f$getsyi ("nodename",, csid)
$ if node_list .nes. ""
$ then
$ node_list = node_list + "," + node
$ else
$ node_list = node
$ endif
$ cut_off = cut_off + 1
$ goto node_loop
$end_node_loop:
$ ask "Run on nodes [''node_list']: "
$ command = f$edit (command, "upcase,collapse,uncomment")
$ if command .nes. ""
$ then
$ node_cnt = 0
$check_node:
$ node = f$element (node_cnt, ",", command)
$ if node .eqs. ","
$ then
$ goto end_check_node
$ endif
$ if .not. f$getsyi ("cluster_member", node)
$ then
$ say node + " is not a cluster member!"
$ goto end_node_loop
$ else
$ node_cnt = node_cnt + 1
$ goto check_node
$ endif
$end_check_node:
$ node_list = command
$ cut_off = node_cnt + 1
$ endif
$ open/write temp1 'temp1'
$ write temp1 "set e/node=(''node_list')"
$ write temp1 "set prof/default=''report_dir'"
$ write temp1 "do show dev/file/nosystem ''the_disk' -"
$ write temp1 " /out='f$getsyi (""nodename"").shared_image_cnt"
$ close temp1
$ define/user sys$output nl:
$ define/user sys$error nl:
$ mc sysman @'temp1'
$ delete/nolog 'temp1';*
$ goto start
$not_cluster:
$ show dev/file/nosystem 'the_disk' -
/out='report_dir''f$getsyi ("nodename")'.shared_image_cnt
$ cut_off = 2
$start:
$ image_list = ""
$floop:
$ file = f$search ("''report_dir'*.shared_image_cnt")
$ if file .eqs. ""
$ then
$ goto end_floop
$ endif
$ close/nolog in
$ open/read in 'file'
$ read/end=end_loop in header
$ read/end=end_loop in header
$loop:
$ read/end=end_loop in rec
$ rec = f$edit (rec, "compress,trim")
$ the_image = f$element (2, " ", rec)
$ image = f$parse (the_image,,,"name")
$ if f$parse (the_image,,,"type") .nes. ".EXE"
$ then
$ goto loop
$ endif
$ minus = 0
$ save_image = image
$remove_minus:
$ if f$locate ("-", image) .lt. f$length (image)
$ then
$ minus = 1
$ image = image - "-"
$ goto remove_minus
$ endif
$ symbol = image + "_cnt"
$ if f$type ('symbol) .eqs. ""
$ then
$ if minus
$ then
$ 'image'_name = save_image
$ endif
$ 'image'_cnt = 1
$ if image_list .eqs. ""
$ then
$ image_list = image
$ else
$ image_list = image_list + "," + image
$ endif
$ else
$ 'image'_cnt = 'image'_cnt + 1
$ endif
$ goto loop
$end_loop:
$ close in
$ delete/nolog 'file'
$ goto floop
$end_floop:
$ if image_list .eqs. ""
$ then
$ goto no_rep
$ endif
$ count = 0
$ open/write temp1 'temp1'
$iloop:
$ image = f$element (count, ",", image_list)
$ if image .eqs. ","
$ then
$ goto end_iloop
$ endif
$ if 'image'_cnt .ge. cut_off
$ then
$ temp = image
$ if f$type ('image'_name) .nes. ""
$ then
$ temp = 'image'_name
$ endif
$ write temp1 f$fao ("!3ZL !AS", 'image'_cnt, temp)
$ endif
$ count = count + 1
$ goto iloop
$end_iloop:
$ close temp1
$ sort/key=(pos:1,siz:3,desc) 'temp1' 'report_dir'shared_image_cnt.rep
$ delete/nolog 'temp1';*
$ purge/nolog 'report_dir'shared_image_cnt.rep
$ type/nopage 'report_dir'shared_image_cnt.rep
$ goto exit
$no_rep:
$ say "There is not data to report for disk " + the_disk
$exit:
$ junk = f$setprv (old_privs)
$ exit status + (0*f$verify (old_verify))
$!++
$!
$! DESCRIPTION
$!
$! Produces a report of all executables open on a specified disk sorted
$! by the number of processes with open channels to them.
$! You can specify this disk, and the nodes to query, or accept the
$! default of the system disk cluster wide.
$!
$! AUTHOR
$!
$! James F. Duff
$!
$! DATE WRITTEN
$!
$! 15-Jun-2013
$!
$! MODIFICATION HISTORY
$!
$! 15-Jun-2013 Jim Duff
$! Original version of module
$!
$! 21-Jun-2013 Jim Duff
$! Handle case where there are no images. Thanks Ian.
$!
$! 15-Jul-2013 Jim Duff
$! Handle image names with minus signs. Thanks to Tony
$! McGrath for pointing this out.
$!
$! 24-Aug-2013 Jim Duff
$! Fix some sloppy file name handling. Initialize some variables in
$! an appropriate place so both clusters and non-clustered systems work
$! correctly.
$!--
Posted at June 20, 2013 4:16 PM
I think there may be a problem if there are no such images
$iloop:
$ image = f$element (count, ",", image_list)
$ if image .eqs. ","
$ endif
$ if _cnt .ge. cut_off
%DCL-W-UNDSYM, undefined symbol - check validity and spelling
\_CNT\
Posted by: Ian Miller at June 20, 2013 9:13 PM
Thanks Ian, I've fixed the code to handle that.
Posted by: Jim Duff at June 21, 2013 1:18 PM
Comments are closed