Newsgroups: comp.os.vms
Subject: Re: Updated DISKFREE.COM (New Command File)
From: matt@vulcan.mentec.ie
Date: 17 Dec 92 17:04:16 GMT
Organization: Mentec Computer Systems, Dublin, Ireland
Nntp-Posting-User: matt

Hello,

I have just recieved a copy of DISK_FREE the command file and wondered if anyone
was interested in something similar we use on our site here.

It works on any VT100 upwards terminal and is pretty easy to use. The command
file does not search for all disk devices so we use a logical defined to point
to them all then call it as below.

$ sh log alldisks
   "ALLDISKS" = "MAXUK$DUA0:" (LNM$PROCESS_TABLE)
	= "MAXUK$DUA1:"
	= "MAXUK$DUB0:"
	= "MAXUK$DUB1:"
	= "HALUK$DUA0:"
	= "HALUK$DUA1:"
	= "HALUK$DUB0:"
	= "HALUK$DUB1:"
	= "ORACUK$DKA300:"
	= "ZENUK$DKA300:"
	= "ZENUK$DKB300:"
	= "ZENUK$DKB700:"

$ @men$command:im_disk_free alldisks 100000 25000

To get the full effect of the command file run it then wait sometime for the
disk space to change before running it again !

I apologise in advance for the coding, it was knocked together in about 4 hours.
BUT IT WORKS (or should :-) ).

I welcome any comments, suggestions etc.

Matt

--------------------------------------------------------------------------------
Matthew Roxburgh : Mentec International (UK) Ltd, Mentec House, Birchwood Blvd,
                   Birchwood, Warrington, Cheshire WA3 7QX. England.
Voice / Fax      : +44 925 830000 / +44 925 830123    
Internet         : matt@mentec.ie
--------------------------------------------------------------------------------
"The Surest Sign That Intelligent Life Exists Elsewhere In The Universe Is That
 None Of It Has Tried To Contact Us"                 - Calvin (Calvin & Hobbes)
--------------------------------------------------------------------------------


$!-----------------------------CUT HERE-----------------------------------------
$!   IM_DISK_FREE (c) 1992 Matthew Roxburgh - Mentec
$!    - Another in the continuing IM series of command files
$!
$!   This command file gives the free space on a device in a bar graph format
$!   multiple devices can be specified by using a logical pointing to all the 
$!   devices required as P1 to this command file.
$!
$!   The volume free space on the first call of this command procedure is 
$!   indicated by a thin line thus allowing changes to be spotted at a glance.
$!
$!   If the command file is called again with the same P1 parameter the change 
$!   in disk space is indicated by a +/- in the blocks column.
$!
$!   The maximum scale of the graph can be specified by passing the number of 
$!   blocks in p2 otherwise it is calculated to be the largest free space on 
$!   the volumes specified.
$!   
$!   A danger threshold can be specified (again in blocks) as P3 if any disk 
$!   falls below this level the bar is highlighted in bold. If the free blocks 
$!   on any volume falls below 10% of this value then the situation is indicated
$!   as a flashing bar.
$!
$!   P1 = device name or logical (logical can be a list of devices)
$!        default = sys$sysdevice
$!   P2 = max graph size
$!        default = maximum free
$!   P3 = danger threshhold (bars marked bold if below this)
$!        N.B. bars flash if less than 10% of this figure
$!        default = 10000   
$
$    set noverify
$
$    set term sys$output /nowrap
$
$    if "''loc$debug'" .EQS. "TRUE" THEN SET VERIFY
$    if "''P1'" .eqs. "" then P1 = f$parse(f$environment("DEFAULT"),,,"DEVICE")
$    if "''P1'" .eqs. "" then P1 = "sys$sysdevice:"
$
$    esc[0,8] = 27
$    nor = esc + "#5"
$    index = 0
$
$    max_free = 0
$
$ loop:
$
$    actdev = f$trnlnm(p1,, index)
$    if actdev .eqs. ""
$    then
$        if index .eq. 0
$        then
$            actdev = P1
$        else
$            goto exit_loop
$        endif
$    endif
$
$    pad_dev = f$extract(0,15,"''f$getdvi(actdev,"DEVNAM")'                ")
$    freb = F$GETDVI("''ACTDEV'","FREEBLOCKS")
$
$    if freb .gt. max_free then max_free = freb
$
$    index = index + 1
$
$    if "''old_df_para'" .eqs. P1
$    then
$        if dev_sp_'index' .gt. max_free then max_free = dev_sp_'index'
$    endif
$
$    dev_n_'index' = pad_dev
$    dev_f_'index' = freb
$
$    goto loop
$
$ exit_loop:
$
$    if p2 .eqs. "" then p2 = max_free
$
$    if p3 .eqs. "" then p3 = 10000
$    dang_thresh = P3
$
$    if max_free .gt. p2
$    then
$        max_free = p2
$        fre_step = max_free / 5
$    else
$        fre_step = max_free * 110 / 500
$    endif
$
$    scale = max_free / 50
$    blocks = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
$
$    say nor, esc, "(0lqqqqqqqqqqqqqqqwqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk"
$    say nor, "x  DEVICE NAME  x  BLOCKS  x0                                                  x"
$
$    ss = 1
$
$ sc_loop:
$
$    tab = 27 + (10 * ss)
$    dv = fre_step * ss
$    tab = tab - f$length("''dv'")
$    say esc, "[A",esc,"[''tab'C", dv, "->"
$
$    ss = ss + 1
$    if ss .lt. 6 then goto sc_loop
$
$    say nor, "tqqqqqqqqqqqqqqqnqqqqqqqqqqnnwwwwwwwwwnwwwwwwwwwnwwwwwwwwwnwwwwwwwwwnwwwwwwwwwnu",esc,"(B"
$
$    disks = index
$    index = 0
$    all_qs = "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
$    spaces = "                                                   "
$    max_bar = ""
$
$    if "''old_df_para'" .eqs. P1
$    then
$        gosub set_df_date
$    else
$        dev_sp_date == ""
$        gosub set_df_date
$    endif
$
$ disk_loop:
$
$    index = index + 1
$    if index .gt. disks then goto exit_disk_loop
$
$    pad_len = 7
$    pad_buf = dev_f_'index'
$    gosub pad_it
$
$    dn = dev_n_'index'
$
$    spdir1 = " "
$    spdir2 = " "
$
$    if "''old_df_para'" .eqs. P1
$    then
$        old_df = dev_of_'index'
$        if old_df .gt. dev_f_'index'
$        then
$            spdir1 = esc + "[7m-"
$        else
$            if old_df .lt. dev_f_'index'
$            then
$                spdir2 = esc + "[7m+"
$            endif
$        endif
$    endif
$
$    dev_of_'index' == dev_f_'index'
$
$    spbar = dev_sp_'index' / scale
$    if spbar .eq. 0 then spbar = 1
$    bar = f$extract(0,spbar-1,all_qs) + "u"
$    bar = f$extract(0,51,bar + spaces)
$
$    if dev_f_'index' .gt. max_free
$    then
$        bar1 = max_bar
$        bar2 = ""
$    else
$        barlen = dev_f_'index' / scale
$        if barlen .eq. 0 then barlen = 1
$        bar1 = f$extract(0, barlen, bar)
$        bar2 = f$extract(barlen,51, bar)
$    endif
$
$    lo = esc + "[0m"
$    if dev_f_'index' .le. dang_thresh then lo = esc + "[1m"
$    if dev_f_'index' .le. (dang_thresh / 10) then lo = esc + "[1m" + esc + "[5m"
$
$    say nor, esc, "(0x''lo'''dn'", esc, "[0mx''lo'''spdir1'", esc, "[0m''lo'''pad_buf' ", -
         "''spdir2'", esc, "[0mx''lo'", esc, "[7m''bar1'", esc, "[0m''lo'''bar2'", esc, "[0mx", esc, "(B"
$
$    goto disk_loop
$
$ exit_disk_loop:
$                       
$    say nor, esc, "(0mqqqqqqqqqqqqqqqvqqqqqqqqqqvvqqqqqqqqqvqqqqqqqqqvqqqqqqqqqvqqqqqqqqqvqqqqqqqqqvj", esc, "(B"
$
$    old_df_para == P1
$
$    exit
$
$ pad_it:
$
$    if f$length(pad_buf) .eq. pad_len then return
$    pad_buf = "                                            ''pad_buf'"
$    pad_buf = f$extract(f$length(pad_buf) - pad_len, pad_len, pad_buf)
$    return
$
$ set_df_date:
$
$    if "''dev_sp_date'" .eqs. f$extract(0,11,f$time()) then return
$
$    dev_sp_date == f$extract(0,11,f$time())
$
$    spi = 1
$
$ loop:
$
$    dev_sp_'spi' == dev_f_'spi'
$
$    spi = spi + 1
$    if spi .le. disks then goto loop
$
$    return
Newsgroups: comp.os.vms,vmsnet.misc