Web Based Disk Usage Display - VMS

This is a discussion on Web Based Disk Usage Display - VMS ; Inspired by JF's cell phone cluster monitor, I wrote a "quick & dirty" web based disk usage display using PHP and a little bit of DCL. The display shows the amount of free space on the disks in both ASCII ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Web Based Disk Usage Display

  1. Web Based Disk Usage Display

    Inspired by JF's cell phone cluster monitor, I wrote a "quick & dirty"
    web based disk usage display using PHP and a little bit of DCL. The
    display shows the amount of free space on the disks in both ASCII and
    with a bar graph. It is not dynamic (yet). I plan to make it more
    dynamic so it will be able to indicate when the amount of free space
    on a disk changes. The PHP script needs to be run on a web host that
    has TCP connectivity with the VMS nodes that are to be monitored, it
    does not have to be run on a VMS web host, but it does run fine on
    VMS. The PHP script gets the disk usage from the following DCL
    procedure which needs to be set up as a TCP/IP service:

    $ set noon
    $ set nover
    $ open/write out sys$net
    $ lf[0,8] = 10
    $dl:
    $ nd = f$dev("*d*:","disk")
    $ if nd .eqs. ""
    $ then
    $ close out
    $ exit
    $ endif
    $ if .not. f$getd(nd,"mnt") then goto dl
    $ mb = f$getd(nd,"maxblock")
    $ fb = f$getd(nd,"freeblocks")
    $ write out "''nd', ''mb', ''fb'''lf'"
    $ goto dl

    Here is the PHP script (HTML code) -- No Javascript is used in this procedure.



    VMS Cluster Disk Usage



    $nodes = array('this','is','a','list','of','the','VMS','nod es','to','be','monitored');
    $socket_num = 1001; // socket used to connect to the DCL script
    $yellow_pct = 50; // less than or equal to this is a yellow bar
    $red_pct = 10; // less than or equal to this is a red bar
    $tmp = array();
    $tmp[] = '
    '
    ..
    'Disk Usage
    ' .
    date('l, F j, Y \a\t g:i A') . '
    ';
    foreach ($nodes as $node) {
    $du = array();
    $tmp[] = ' style="clear:both;width:100%;font-weight:bold;text-align:center">' .
    strtoupper($node) . '

    ';
    $fp = fsockopen($node,$socket_num);
    while (!feof($fp))
    $du[] = fgets($fp,80);
    fclose($fp);
    $du = array_map('trim',$du);
    foreach ($du as $line) {
    if (substr($line,0,1) == '_') {
    $usage = explode(',',$line);
    $pct_free = ($usage[2]/$usage[1]) * 100;
    $bkgnd = 'lime';
    if ($pct_free < $yellow_pct) $bkgnd = 'yellow';
    if ($pct_free < $red_pct) $bkgnd = 'red';
    $bar_width = 80 * ($pct_free/100);
    $tmp[] = '
    ';
    $tmp[] = ' style="display:block;width:20%;float:left">' .
    str_replace('_','',$usage[0]) .
    ', ' . number_format($pct_free,2) . '% Free';
    $tmp[] = ' ';
    $tmp[] = '
    ';
    }
    }
    $tmp[] = '

    ';
    }
    echo implode("\n",$tmp)."\n";
    ?>



    If the formatting gets screwed up by GMail, please contact me. If the
    web page doesn't look right (lines wrapping in weird places, maximize
    the size of the browser page. I've tested this in both Firefox and
    MSIE7.

    Ken Robinson

  • Re: Web Based Disk Usage Display

    Ken Robinson wrote:
    > Inspired by JF's cell phone cluster monitor, I wrote a "quick & dirty"
    > web based disk usage display using PHP and a little bit of DCL. The
    > display shows the amount of free space on the disks in both ASCII and
    > with a bar graph. It is not dynamic (yet). I plan to make it more
    > dynamic so it will be able to indicate when the amount of free space
    > on a disk changes. The PHP script needs to be run on a web host that
    > has TCP connectivity with the VMS nodes that are to be monitored, it
    > does not have to be run on a VMS web host, but it does run fine on
    > VMS. The PHP script gets the disk usage from the following DCL
    > procedure which needs to be set up as a TCP/IP service


    If the PHP is running on the VMS box then there are simpler
    ways than a TCP/IP service.

    Approach 1
    ----------



    Disk space


    Disk space




    $disktyps = array( "DU", "DI", "DK", "DQ" );
    $diskctrls = array( "A", "B", "C", "D" );
    foreach($disktyps as $typ) {
    foreach($diskctrls as $ctrl) {
    for($unit = 0; $unit < 8; $unit++) {
    $modunit = $unit;
    if($typ == "DK") $modunit *= 100;
    $disk = $typ . $ctrl . $modunit;
    $total = intval(disk_total_space("$disk:[000000]") / 1000000);
    $free = intval(disk_free_space("$disk:[000000]") / 1000000);
    if($total > 0) {
    echo "\n";
    }
    }
    }
    }
    ?>
    DiskTotal (MB)Free (MB)
    $disk$total$free




    Approach 2
    ----------



    Disk space


    Disk space




    $p = popen("@disk2:[arne.www]disks.com", "r");
    while(!feof($p)) {
    $line = fgets($p);
    $parts = split(" ", $line);
    $disk = $parts[0];
    $total = $parts[1];
    $free = $parts[2];
    echo "\n";
    }
    pclose($p);
    ?>
    DiskTotal (blocks)Free (blocks)
    $disk$total$free




    and

    $ loop:
    $ diskname=f$device("*","DISK")
    $ if diskname .eqs. "" then goto endloop
    $ if .not. f$getdvi(diskname,"MNT") then goto loop
    $ free=f$getdvi(diskname,"FREEBLOCKS")
    $ total=f$getdvi(diskname,"MAXBLOCK")
    $ write sys$output diskname," ",total," ",free
    $ goto loop
    $ endloop:
    $ exit

    Arne

  • Re: Web Based Disk Usage Display

    On Dec 4, 2007 8:58 PM, Arne Vajh°j wrote:
    > If the PHP is running on the VMS box then there are simpler
    > ways than a TCP/IP service.


    You are assuming that the node running the PHP script is part of a
    cluster and that all the disks are mounted on all the nodes of the
    cluster. My script doesn't make those assumptions. It can also be run
    from any host that is running PHP and has TCP/IP connectivity to the
    VMS nodes.

    Ken

  • Re: Web Based Disk Usage Display

    Ken Robinson wrote:
    > On Dec 4, 2007 8:58 PM, Arne Vajh°j wrote:
    >> If the PHP is running on the VMS box then there are simpler
    >> ways than a TCP/IP service.

    >
    > You are assuming that the node running the PHP script is part of a
    > cluster and that all the disks are mounted on all the nodes of the
    > cluster. My script doesn't make those assumptions. It can also be run
    > from any host that is running PHP and has TCP/IP connectivity to the
    > VMS nodes.
    >
    > Ken


    Looks like you are doing something similar to the "disk usage report" from wasd?

    http://wasd.vsm.com.au/ht_root/doc/misc/vmsscripts.html

  • Re: Web Based Disk Usage Display

    On Dec 5, 2007 8:17 AM, sol gongola wrote:
    >
    > Looks like you are doing something similar to the "disk usage report" from wasd?
    >
    > http://wasd.vsm.com.au/ht_root/doc/misc/vmsscripts.html


    Since I have never used wasd, I had no idea that this script was out
    there. Yes it's similar, but, as I said, this script should run on any
    platform as long as it supports PHP and can communicate with the VMS
    nodes via TCP/IP.

    Ken

  • + Reply to Thread