IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 10, 2025, 1:11:48 PM (8 months ago)
Author:
cclin33
Message:

update storage views

File:
1 edited

Legend:

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

    r42736 r42921  
    5252    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    5353    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%\">";
    54     echo "  <div id=\"disk_div\" style=\"width:100%; height:4000px\"></div>";
     54    echo "  <div id=\"disk_div\" style=\"width:100%; height:5000px\"></div>";
    5555    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 50px; right: 20px;\">";
    56     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>";
    57     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #ffff00\"><center>Used</div>";
    58     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #ff0000\"><center>> 97% limit</div>";
    59     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #bbbbbb\"><center>Down | Repair</div>";
    60     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #ffffff\"><center>Power Off</div>";
     56    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgreen\"><center>Free</div>";
     57    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: yellow\"><center>Used</div>";
     58    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: pink\"><center>> 97% limit</div>";
     59    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgrey\"><center>Down | Repair</div>";
     60    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: white\"><center>Offline</div>";
    6161    echo "  </div>";
    6262    echo "</div>";
     
    6969    exec("neb-host |cut -b 17-30,86-", $hostnoteall);
    7070
    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";
     71    $sql = "SELECT host, format(total, 2), format(available, 2), format(used, 2), writable, readable, format(used/total*100,3) as ratio FROM hosts where xattr <> 3 ";
    7472    $qry = $db->query($sql);
    7573
     
    8078
    8179    $dataRows = array();
     80    $maxUsed = 0;   // initialize before the while loop
     81
    8282    while ($qry->fetchInto($row)) {
    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 
     83        // Access by index
     84        $host      = $row[0]; // ipp071.0
     85        $total     = $row[1]; // 80.0352 TB
     86        $available = $row[2]; // 10.8096 TB
     87        $used      = $row[3]; // 69.2256 TB
     88        $writable  = $row[4]; // 0
     89        $readable  = $row[5]; // 1
     90        $ratio     = $row[6]; // 86.4939 %
     91
     92        // update maxUsed
     93        if ($total > $maxUsed) {
     94            $maxUsed = $total/2;
     95        }
     96
     97        // Match notes
    9298        $hostnotes = preg_grep("/$host/", $hostnoteall);
    9399        $hostnote = reset($hostnotes);
    94100
    95         $styles = "stroke-width: 0.5; stroke-color: black;";
     101        // Defaults
     102        $styles    = "stroke-width: .5; stroke-color: black;";
     103        $status    = "down";
     104        $usedColor = "lightgrey";
     105        $freeColor = "lightgrey";
     106
     107        // Status logic
    96108        if ($writable == 1 && $readable == 1) {
    97             $usedColor = $ratio >= 97 ? "#ff0000" : "#ffff00";
    98             $freeColor = "#00ff00";
     109            $status    = "up";
     110            $usedColor = ($ratio >= 97) ? "pink" : "yellow"; // red if ≥97%
     111            $freeColor = "#a6ec99"; // green free
    99112        } elseif ($writable == 0 && $readable == 1) {
    100             $usedColor = $ratio >= 97 ? "#ff0000" : "#ffff00";
    101             $freeColor = "#bbbbbb";
     113            $status    = "repair";
     114            $usedColor = ($ratio >= 97) ? "pink" : "yellow";
     115            $freeColor = "lightgrey"; // grey free
     116        } elseif ($available < 1) {
     117            $used      = $maxUsed;
     118            $available = $maxUsed;
     119            $status    = "offline";
     120            $usedColor = "white";
     121            $freeColor = "white";
     122        }
     123   
     124        if ($status == "down") {
     125            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used ".
     126                           "<span style='color:red; font-weight:bold;'> <br>" . $hostnote .  "</span>";
     127            $tooltipFree = "<span style='color:red; font-weight:bold;'>" .
     128                           $host . ": " . $available . " TB free" .
     129                           "</span>";
     130        } elseif ($status == "offline") {
     131            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used ".
     132                           "<span style='color:red; font-weight:bold;'> <br>" . $hostnote .  "</span>";
     133            $tooltipFree = "<span style='color:red; font-weight:bold;'>" .
     134                           $host . ": " . $total . " TB free" .
     135                           "</span>";
    102136        } else {
    103             $usedColor = $freeColor = "#bbbbbb";
     137            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used<br>" . $hostnote;
     138            $tooltipFree = $host . ": " . $available . " TB free";
    104139        }
    105140
    106         $dataRows[] = "[ \"$host\", $used, \"$styles color: $usedColor;\", \"$host: $ratio% of $total TB used<br>$hostnote\",
    107                        $available, \"$styles color: $freeColor;\", \"$host: $available TB free\"]";
     141        // Build data row (manual string concatenation for old PHP)
     142        $dataRows[] =
     143            "[ \"" . $host . ":" . $status . "\", " .
     144            $used . ", \"" . $styles . " color: " . $usedColor . ";\", \"" . $tooltipUsed . "\", " .
     145            $available . ", \"" . $styles . " color: " . $freeColor . ";\", \"" . $tooltipFree . "\" ]";
     146
    108147    }
    109 
    110148    echo "<script type=\"text/javascript\">
    111149            google.charts.load('current', {packages: ['corechart', 'bar']});
     
    126164                    tooltip: {isHtml: true},
    127165                    legend: { position: 'none', alignment: 'end', maxLines: 3 },
    128                     hAxis: { title: 'Space (TB)', gridlines: {count: 10} },
     166                    hAxis: { title: 'Space (TB)', gridlines: {count: 20} },
     167                    vAxis: { textStyle: {fontSize: 14}, format: 'string',  textPosition: 'in', direction: 1},
    129168                    bar: { groupWidth: '95%' },
    130                     chartArea: {left:100, top:50, right:20, bottom:40},
     169                    chartArea: {left:40, top:50, right:20, bottom:40},
    131170                    fontSize: 15,
     171                    allowHtml: true,
    132172                    isStacked: true
    133173                };
     
    155195    $start = $time;
    156196
    157     $db->query("SELECT sum(format(available, 2)) FROM hosts where host like 'ippb%'")->fetchInto($row);
     197    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ippb%' and xattr <> 3")->fetchInto($row);
    158198    $ippbusable = $row[0];
    159     $db->query("SELECT sum(format(available, 2)) FROM hosts where host like 'ippb%' and writable = 1")->fetchInto($row);
     199    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ippb%' and writable = 1 and xattr <> 3")->fetchInto($row);
    160200    $ippbfree = $row[0];
    161201
    162     $db->query("SELECT sum(format(available, 2)) FROM hosts where host not like 'ippb%'")->fetchInto($row);
     202    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host not like 'ippb%' and xattr <> 3")->fetchInto($row);
    163203    $ippusable = $row[0];
    164     $db->query("SELECT sum(format(available, 2)) FROM hosts where host not like 'ippb%' and writable = 1")->fetchInto($row);
     204    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host not like 'ippb%' and writable = 1 and xattr <> 3")->fetchInto($row);
    165205    $ippfree = $row[0];
     206
     207    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ipp%_bck.0' and xattr <> 3")->fetchInto($row);
     208    $bckusable = $row[0];
     209    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ipp%_bck.0' and writable = 1 and xattr <> 3")->fetchInto($row);
     210    $bckfree = $row[0];
     211
    166212
    167213    $sql = "select format(used/total*100,1), usable from cluster_space order by timestamp desc limit 1;";
     
    178224    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%; height:400\">";
    179225    echo "  <div id=\"space_div\" style=\"width:100%; \"></div>";
    180     echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
    181     echo "    <div style=\"font-size: 16px; color:#0000ff; background-color:#ffffff\"><b>ipp + ippb nodes: $ippusable + $ippbusable TB (latest usable)</b></div>";
    182     echo "    <div style=\"font-size: 16px; color:#33a532; background-color:#ffffff\"><b>ipp + ippb nodes: $ippfree + $ippbfree TB (latest free)</b></div>";
     226    echo "  <div class=\"overlay\" style=\"position: absolute; width: 500px; bottom: 60px; left: 80px;\">";
     227    echo "    <div style=\"font-size: 16px; color:#0000ff; \"><b>ipp*_bck: $bckusable TB (usable)</b></div>";
     228    echo "    <div style=\"font-size: 16px; color:#33a532; \"><b>ipp*_bck: $bckfree   TB (free)</b></div>";
    183229    echo "  </div>";
    184230    echo "</div>";
     
    190236    echo "  var data = new google.visualization.DataTable();";
    191237    echo "        data.addColumn('datetime', 'Day');";
    192     echo "        data.addColumn('number', 'Usable');";
    193     echo "        data.addColumn('number', 'Free');";
     238    echo "        data.addColumn('number', 'Usable (ipp:$ippusable, ippb:$ippbusable) TB');";
     239    echo "        data.addColumn('number', 'Free (ipp:$ippfree, ippb:$ippbfree) TB');";
    194240    echo "   data.addRows([";
    195241    $interval = 10;
Note: See TracChangeset for help on using the changeset viewer.