IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 25, 2024, 3:50:12 PM (20 months ago)
Author:
cclin33
Message:

CCL: add plot pointing, airmass, and data quality. and some minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/raw/storage.php

    r42276 r42736  
    2323echo "<table border=\"0\">";
    2424echo "<tr>";
    25 echo "  <td style=width:1000px>";
     25echo "  <td style=width:1200px>";
    2626echo "  <h1 align=\"middle\">Storage status</h1>";
    2727# storage timeseries
     
    4242/////////////////////////////////////////////////////////////////////////////
    4343
    44 
    4544###########################################################################
    4645#
     
    4948###########################################################################
    5049function getHosts($db) {
    51     // timer start
    52     $time = microtime();
    53     $time = explode(' ', $time);
    54     $time = $time[1] + $time[0];
    55     $start = $time;
    56 
    57     #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
     50    $start = microtime(true);
     51
    5852    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    59     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640px\">";
    60     echo "  <div id=\"disk_div\" style=\"width:1000px; height:1600px\"></div>";
     53    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%\">";
     54    echo "  <div id=\"disk_div\" style=\"width:100%; height:4000px\"></div>";
    6155    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 50px; right: 20px;\">";
    6256    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>";
     
    6862    echo "</div>";
    6963
    70     echo "<script type=\"text/javascript\">";
    71     echo "google.charts.load('current', {packages: ['corechart', 'bar']});";
    72     echo "google.charts.setOnLoadCallback(drawBarColors);";
    73     echo "function drawBarColors() {";
    74     echo "  var data = google.visualization.arrayToDataTable([";
    75     echo "    ['Host', ";
    76     echo "     'used', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}, ";
    77     echo "     'free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],";
    78 
    79     $sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts order by host";
    80     if ($debug) {echo "$sql<br>";}
     64    // Set environment variables
     65    putenv("PATH=/usr/local/bin:/usr/bin:/bin:/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/bin");
     66    putenv("PERL5LIB=/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/lib");
     67
     68    $hostnoteall = array();
     69    exec("neb-host |cut -b 17-30,86-", $hostnoteall);
     70
     71    $sql = "SELECT host, format(total, 2), format(available, 2), format(used, 2), writable, readable, format(used/total*100,3) as ratio
     72            FROM hosts
     73            ORDER BY host";
    8174    $qry = $db->query($sql);
    82     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    83     # not sure why neb-host doesn't work on ipp113 CCL.20210216
    84     exec("neb-host |cut -b 17-30,86-", $hostnoteall);
     75
     76    if ($qry === false) {
     77        echo "<b>Error with SQL query</b><br>";
     78        return;
     79    }
     80
     81    $dataRows = array();
    8582    while ($qry->fetchInto($row)) {
    86         list($host, $total, $available, $used, $writable, $readable, $ratio) = $row;
    87        $hostnotes = preg_grep("/$host/", $hostnoteall);
    88        $hostnote = array_values($hostnotes);
    89        if ($writable == 1 && $readable == 1) {
    90           if ($ratio >= 97) {
    91             # space used over limits, up mode (read/write ok).
    92             echo "[ \"$host\", ";
    93             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
    94             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
    95           }
    96           else {
    97             # enough space, up mode (read/write ok).
    98             echo "[ \"$host\", ";
    99             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
    100             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
    101          }
    102        }
    103        else if ($writable == 0 && $readable == 1) {
    104           if ($ratio >= 97) {
    105             # space used over limits, repair mode (read only).
    106             echo "[ \"$host\", ";
    107             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used<br><font color=red>$hostnote[0]\", ";
    108             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
    109           }
    110           else {
    111             # enough space, but hosts are unstable, repair mode (read only).
    112             echo "[ \"$host\", ";
    113             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used<br>$hostnote[0]\", ";
    114             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
    115           }
    116        }
    117        else {
    118             # down mode (can't read or write).
    119             echo "[ \"$host\", ";
    120             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $ratio% used<br>$hostnote[0]\", ";
    121             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
    122        }
     83        // Access data using numeric indices
     84        $host = $row[0]; // ipp071.0
     85        $total = $row[1]; // 80.0352
     86        $available = $row[2]; // 10.8096
     87        $used = $row[3]; // 69.2256
     88        $writable = $row[4]; // 0
     89        $readable = $row[5]; // 1
     90        $ratio = $row[6]; // 86.493950215116
     91
     92        $hostnotes = preg_grep("/$host/", $hostnoteall);
     93        $hostnote = reset($hostnotes);
     94
     95        $styles = "stroke-width: 0.5; stroke-color: black;";
     96        if ($writable == 1 && $readable == 1) {
     97            $usedColor = $ratio >= 97 ? "#ff0000" : "#ffff00";
     98            $freeColor = "#00ff00";
     99        } elseif ($writable == 0 && $readable == 1) {
     100            $usedColor = $ratio >= 97 ? "#ff0000" : "#ffff00";
     101            $freeColor = "#bbbbbb";
     102        } else {
     103            $usedColor = $freeColor = "#bbbbbb";
     104        }
     105
     106        $dataRows[] = "[ \"$host\", $used, \"$styles color: $usedColor;\", \"$host: $ratio% of $total TB used<br>$hostnote\",
     107                       $available, \"$styles color: $freeColor;\", \"$host: $available TB free\"]";
    123108    }
    124    echo "  ]);";
    125    echo "   var options = {";
    126    echo "     title: 'Nebulous Disk Use across IPP Clusters',";
    127    echo "     titleTextStyle: {color: 'black', fontSize: 15},";
    128    echo "     width: '100%',";
    129    echo "     height: '100%',";
    130    echo "     tooltip: {isHtml: true},";
    131    echo "     legend: { position: 'none',";
    132    echo "               alignment: 'end',";
    133    echo "               maxLines: 3},";
    134    echo "     hAxis: {  title: 'Space (TB)',";
    135    echo "               gridlines: {count: 10}";
    136    echo "     },";
    137    echo "     bar: { groupWidth: '95%' },";
    138    echo "     chartArea: {left:70, top:30, right:20, bottom:40},";
    139    echo "     fontSize: 12,";
    140    echo "     isStacked: true";
    141    echo "   };";
    142    echo "   var chart = new google.visualization.BarChart(document.getElementById('disk_div'));";
    143    echo "   chart.draw(data, options);";
    144    echo " }";
    145    echo "</script>";
    146     $time = microtime();
    147     $time = explode(' ', $time);
    148     $time = $time[1] + $time[0];
    149     $finish = $time;
    150     $total_time = round(($finish - $start), 3);
    151     $start= $finish;
     109
     110    echo "<script type=\"text/javascript\">
     111            google.charts.load('current', {packages: ['corechart', 'bar']});
     112            google.charts.setOnLoadCallback(drawBarColors);
     113
     114            function drawBarColors() {
     115                var data = google.visualization.arrayToDataTable([
     116                    ['Host', 'Used', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}},
     117                     'Free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],
     118                    " . implode(",\n", $dataRows) . "
     119                ]);
     120               
     121                var options = {
     122                    title: 'Nebulous Disk Use across IPP Clusters',
     123                    titleTextStyle: {color: 'black', fontSize: 15},
     124                    width: '100%',
     125                    height: '100%',
     126                    tooltip: {isHtml: true},
     127                    legend: { position: 'none', alignment: 'end', maxLines: 3 },
     128                    hAxis: { title: 'Space (TB)', gridlines: {count: 10} },
     129                    bar: { groupWidth: '95%' },
     130                    chartArea: {left:100, top:50, right:20, bottom:40},
     131                    fontSize: 15,
     132                    isStacked: true
     133                };
     134
     135                var chart = new google.visualization.BarChart(document.getElementById('disk_div'));
     136                chart.draw(data, options);
     137            }
     138          </script>";
     139
     140    $total_time = round(microtime(true) - $start, 3);
    152141    echo "<center>loading in $total_time seconds<br></center>";
    153142}
     143
    154144
    155145###########################################################################
     
    186176    #echo "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>";
    187177    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    188     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">";
    189     echo "  <div id=\"space_div\" style=\"width:1000; \"></div>";
     178    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%; height:400\">";
     179    echo "  <div id=\"space_div\" style=\"width:100%; \"></div>";
    190180    echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
    191181    echo "    <div style=\"font-size: 16px; color:#0000ff; background-color:#ffffff\"><b>ipp + ippb nodes: $ippusable + $ippbusable TB (latest usable)</b></div>";
Note: See TracChangeset for help on using the changeset viewer.