Index: trunk/ippMonitor/raw/czartool_labels.php
===================================================================
--- trunk/ippMonitor/raw/czartool_labels.php	(revision 42902)
+++ trunk/ippMonitor/raw/czartool_labels.php	(revision 42921)
@@ -1706,5 +1706,5 @@
 #
 ###########################################################################
-function getHosts($db) {
+function getHostsold($db) {
     // timer start
     $time = microtime();
@@ -1716,5 +1716,5 @@
     echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640px\">"; 
-    echo "  <div id=\"disk_div\" style=\"width:640px; height:4000px\"></div>";
+    echo "  <div id=\"disk_div\" style=\"width:640px; height:5000px\"></div>";
     echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 35px; right: 20px;\">";
     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>";
@@ -1735,5 +1735,6 @@
     echo "     'free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],";
 
-    $sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts where host like 'ipp1%' or host like 'ippb%' order by host";
+    //$sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts";
+    $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 ";
     if ($debug) {echo "$sql<br>";}
     $qry = $db->query($sql);
@@ -1753,5 +1754,5 @@
           if ($ratio >= 97) {
             # space used over limits, up mode (read/write ok).
-            echo "[ \"$host\", ";
+            echo "[ \"$host:up\", ";
             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
@@ -1759,5 +1760,5 @@
           else {
             # enough space, up mode (read/write ok).
-            echo "[ \"$host\", ";
+            echo "[ \"$host:up\", ";
             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
@@ -1767,5 +1768,5 @@
           if ($ratio >= 97) {
             # space used over limits, repair mode (read only).
-            echo "[ \"$host\", ";
+            echo "[ \"$host:repair\", ";
             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]\", ";
             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
@@ -1773,5 +1774,5 @@
           else {
             # enough space, but hosts are unstable, repair mode (read only).
-            echo "[ \"$host\", ";
+            echo "[ \"$host:repair\", ";
             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used<br>$hostnote[0]\", ";
             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
@@ -1780,5 +1781,5 @@
        else {
             # down mode (can't read or write).
-            echo "[ \"$host\", ";
+            echo "[ \"$host:down\", ";
             echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $ratio% used<br>$hostnote[0]\", ";
             echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
@@ -1798,6 +1799,7 @@
    echo "               gridlines: {count: 10}";
    echo "     },";
+   echo "     vAxis: { textPosition: 'in', direction: 1 },";
    echo "     bar: { groupWidth: '95%' },";
-   echo "     chartArea: {left:100, top:30, right:20, bottom:40},";
+   echo "     chartArea: {left:20, top:30, right:20, bottom:40},";
    echo "     fontSize: 15,";
    echo "     isStacked: true,";
@@ -1819,4 +1821,144 @@
 ###########################################################################
 #
+# Gets disk status
+#
+###########################################################################
+function getHosts($db) {
+    $start = microtime(true);
+
+    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
+    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%\">";
+    echo "  <div id=\"disk_div\" style=\"width:100%; height:5000px\"></div>";
+    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 50px; right: 20px;\">";
+    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgreen\"><center>Free</div>";
+    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: yellow\"><center>Used</div>";
+    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: pink\"><center>> 97% limit</div>";
+    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgrey\"><center>Down | Repair</div>";
+    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: white\"><center>Offline</div>";
+    echo "  </div>";
+    echo "</div>";
+
+    // Set environment variables
+    putenv("PATH=/usr/local/bin:/usr/bin:/bin:/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/bin");
+    putenv("PERL5LIB=/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/lib");
+
+    $hostnoteall = array();
+    exec("neb-host |cut -b 17-30,86-", $hostnoteall);
+
+    $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 ";
+    $qry = $db->query($sql);
+
+    if ($qry === false) {
+        echo "<b>Error with SQL query</b><br>";
+        return;
+    }
+
+    $dataRows = array();
+    $maxUsed = 0;   // initialize before the while loop
+
+    while ($qry->fetchInto($row)) {
+        // Access by index
+        $host      = $row[0]; // ipp071.0
+        $total     = $row[1]; // 80.0352 TB
+        $available = $row[2]; // 10.8096 TB
+        $used      = $row[3]; // 69.2256 TB
+        $writable  = $row[4]; // 0
+        $readable  = $row[5]; // 1
+        $ratio     = $row[6]; // 86.4939 %
+
+        // update maxUsed
+        if ($total > $maxUsed) {
+            $maxUsed = $total/2;
+        }
+
+        // Match notes
+        $hostnotes = preg_grep("/$host/", $hostnoteall);
+        $hostnote = reset($hostnotes);
+
+        // Defaults
+        $styles    = "stroke-width: .5; stroke-color: black;";
+        $status    = "down";
+        $usedColor = "lightgrey";
+        $freeColor = "lightgrey";
+
+        // Status logic
+        if ($writable == 1 && $readable == 1) {
+            $status    = "up";
+            $usedColor = ($ratio >= 97) ? "pink" : "yellow"; // red if â¥97%
+            $freeColor = "#a6ec99"; // green free
+        } elseif ($writable == 0 && $readable == 1) {
+            $status    = "repair";
+            $usedColor = ($ratio >= 97) ? "pink" : "yellow";
+            $freeColor = "lightgrey"; // grey free
+        } elseif ($available < 1) {
+            $used      = $maxUsed;
+            $available = $maxUsed;
+            $status    = "offline";
+            $usedColor = "white";
+            $freeColor = "white";
+        }
+
+        if ($status == "down") {
+            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used ".
+                           "<span style='color:red; font-weight:bold;'> <br>" . $hostnote .  "</span>";
+            $tooltipFree = "<span style='color:red; font-weight:bold;'>" .
+                           $host . ": " . $available . " TB free" .
+                           "</span>";
+        } elseif ($status == "offline") {
+            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used ".
+                           "<span style='color:red; font-weight:bold;'> <br>" . $hostnote .  "</span>";
+            $tooltipFree = "<span style='color:red; font-weight:bold;'>" .
+                           $host . ": " . $total . " TB free" .
+                           "</span>";
+        } else {
+            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used<br>" . $hostnote;
+            $tooltipFree = $host . ": " . $available . " TB free";
+        }
+
+        // Build data row (manual string concatenation for old PHP)
+        $dataRows[] =
+            "[ \"" . $host . ":" . $status . "\", " .
+            $used . ", \"" . $styles . " color: " . $usedColor . ";\", \"" . $tooltipUsed . "\", " .
+            $available . ", \"" . $styles . " color: " . $freeColor . ";\", \"" . $tooltipFree . "\" ]";
+
+    }
+    echo "<script type=\"text/javascript\">
+            google.charts.load('current', {packages: ['corechart', 'bar']});
+            google.charts.setOnLoadCallback(drawBarColors);
+
+            function drawBarColors() {
+                var data = google.visualization.arrayToDataTable([
+                    ['Host', 'Used', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}},
+                     'Free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],
+                    " . implode(",\n", $dataRows) . "
+                ]);
+
+                var options = {
+                    title: 'Nebulous Disk Use across IPP Clusters',
+                    titleTextStyle: {color: 'black', fontSize: 15},
+                    width: '100%',
+                    height: '100%',
+                    tooltip: {isHtml: true},
+                    legend: { position: 'none', alignment: 'end', maxLines: 3 },
+                    hAxis: { title: 'Space (TB)', gridlines: {count: 20} },
+                    vAxis: { textStyle: {fontSize: 14}, format: 'string',  textPosition: 'in', direction: 1},
+                    bar: { groupWidth: '95%' },
+                    chartArea: {left:40, top:50, right:20, bottom:40},
+                    fontSize: 15,
+                    allowHtml: true,
+                    isStacked: true
+                };
+
+                var chart = new google.visualization.BarChart(document.getElementById('disk_div'));
+                chart.draw(data, options);
+            }
+          </script>";
+
+    $total_time = round(microtime(true) - $start, 3);
+    echo "<center>loading in $total_time seconds<br></center>";
+}
+
+###########################################################################
+#
 # Gets disk spaces status
 #
@@ -1829,15 +1971,22 @@
     $start = $time;
 
-    $db->query("SELECT sum(format(available, 2)) FROM hosts where host like 'ippb%'")->fetchInto($row);
+
+    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ippb%' and xattr <> 3")->fetchInto($row);
     $ippbusable = $row[0];
-    $db->query("SELECT sum(format(available, 2)) FROM hosts where host like 'ippb%' and writable = 1")->fetchInto($row);
+    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ippb%' and writable = 1 and xattr <> 3")->fetchInto($row);
     $ippbfree = $row[0];
 
-    $db->query("SELECT sum(format(available, 2)) FROM hosts where host not like 'ippb%'")->fetchInto($row);
+    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host not like 'ippb%' and xattr <> 3")->fetchInto($row);
     $ippusable = $row[0];
-    $db->query("SELECT sum(format(available, 2)) FROM hosts where host not like 'ippb%' and writable = 1")->fetchInto($row);
+    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host not like 'ippb%' and writable = 1 and xattr <> 3")->fetchInto($row);
     $ippfree = $row[0];
 
+    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ipp%_bck.0' and xattr <> 3")->fetchInto($row);
+    $bckusable = $row[0];
+    $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);
+    $bckfree = $row[0];
+
     $sql = "select format(used/total*100,1), usable from cluster_space order by timestamp desc limit 1;";
+
     if ($debug) {echo "$sql<br>";}
     $qry = $db->query($sql);
@@ -1851,7 +2000,7 @@
     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">"; 
     echo "  <div id=\"space_div\" style=\"width:640; \"></div>";
-    echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
-    echo "    <div style=\"font-size: 16px; color:#0000ff; background-color:#ffffff\"><b>ipp + ippb nodes: $ippusable + $ippbusable TB (latest usable)</b></div>";
-    echo "    <div style=\"font-size: 16px; color:#33a532; background-color:#ffffff\"><b>ipp + ippb nodes: $ippfree + $ippbfree TB (latest free)</b></div>";
+    echo "  <div class=\"overlay\" style=\"position: absolute; width: 500px; bottom: 60px; left: 85px;\">";
+    echo "    <div style=\"font-size: 16px; color:#0000ff; \"><b>ipp*_bck: $bckusable TB (usable)</b></div>";
+    echo "    <div style=\"font-size: 16px; color:#33a532; \"><b>ipp*_bck: $bckfree   TB (free)</b></div>";
     echo "  </div>";
     echo "</div>";
@@ -1863,6 +2012,6 @@
     echo "  var data = new google.visualization.DataTable();";
     echo "        data.addColumn('datetime', 'Day');";
-    echo "        data.addColumn('number', 'Usable');";
-    echo "        data.addColumn('number', 'Free');";
+    echo "        data.addColumn('number', 'Usable (ipp:$ippusable, ippb:$ippbusable) TB');";
+    echo "        data.addColumn('number', 'Free (ipp:$ippfree, ippb:$ippbfree) TB');";
     echo "   data.addRows([";
     $interval = 10;
