IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42921


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

update storage views

Location:
trunk/ippMonitor
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/czartool/czarpoll.pl

    r42858 r42921  
    654654            my $readable = 1;
    655655            my $writable = 1;
     656            my $xattr = 0;
    656657
    657658            #print "Mount $mount_point: total=${total_tb}TB, used=${used_tb}TB (${used_percent}%), available=${available_tb}TB (${available_percent}%)\n";
     
    660661            #my $host_label = "$host.$suffix(${total_tb}T)";
    661662            my $host_label = "$host.$suffix";
    662             $czarDb->updateHost($host_label, $total_tb, $available_tb, $used_tb, $readable, $writable);
    663         }
    664     }
    665 }
     663            $czarDb->updateHost($host_label, $total_tb, $available_tb, $used_tb, $readable, $writable, $xattr);
     664        }
     665    }
     666}
  • trunk/ippMonitor/czartool/czartool/CzarDb.pm

    r42858 r42921  
    346346###########################################################################
    347347sub updateHost {
    348     my ($self, $host, $total, $available, $used, $readable, $writable) = @_;
     348    my ($self, $host, $total, $available, $used, $readable, $writable, $xattr) = @_;
    349349
    350350    my $query = $self->{_db}->prepare(<<SQL);
     
    355355    $query = $self->{_db}->prepare(<<SQL);
    356356    INSERT INTO hosts
    357         (host, total, available, used, readable, writable)
     357        (host, total, available, used, readable, writable, xattr)
    358358        VALUES
    359         ('$host', $total, $available, $used, $readable, $writable);
     359        ('$host', $total, $available, $used, $readable, $writable, $xattr);
    360360SQL
    361361    $query->execute;
  • trunk/ippMonitor/czartool/czartool/Nebulous.pm

    r42794 r42921  
    9696    my $readable;
    9797    my $writable;
     98    my $xattr;
    9899    foreach $line (@cmdOut) {
    99100
     
    120121            if ($4 >= 98) {$self->{_hostsOverNinetyEightPC}++;}
    121122
    122             $self->getReadableWritableStatus($1, \$readable, \$writable);
     123            $self->getReadableWritableStatus($1, \$readable, \$writable, \$xattr);
     124            print "Host: $1, Readable: $readable, Writable: $writable, Xattr: $xattr\n";
     125
    123126
    124127            $self->{_czarDb}->updateHost($1,
     
    126129                    $self->convertKbToTb($3),
    127130                    $self->convertKbToTb($2),
    128                     $readable, $writable);
     131                    $readable, $writable, $xattr);
    129132        }
    130133    }
     
    144147###########################################################################
    145148sub getReadableWritableStatus {
    146     my ($self, $host, $readable, $writable) = @_;
     149    my ($self, $name, $readable, $writable, $xattr) = @_;
    147150
    148151    ${$readable} = 0;
    149152    ${$writable} = 0;
     153    ${$xattr} = 0;
    150154
    151155    my @cmdOut = `neb-host`;
     
    154158
    155159        chomp($line);
    156         if ($line =~ m/[0-9.A-Za-z]+\s+$host\s+([01]+)\s+([01]+)\s+([01]+)\s+.*/i) {
     160        if ($line =~ m/[0-9.A-Za-z]+\s+$name\s+([01]+)\s+([01]+)\s+([01]+)\s+([0-9]+)\s+.*/i) {
    157161
    158162            # if mounted...
     
    161165                ${$readable} = $3;
    162166                ${$writable} = $2;
     167                ${$xattr} = $4;
    163168            }
    164169        }
  • trunk/ippMonitor/raw/czartool_labels.php

    r42902 r42921  
    17061706#
    17071707###########################################################################
    1708 function getHosts($db) {
     1708function getHostsold($db) {
    17091709    // timer start
    17101710    $time = microtime();
     
    17161716    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    17171717    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640px\">";
    1718     echo "  <div id=\"disk_div\" style=\"width:640px; height:4000px\"></div>";
     1718    echo "  <div id=\"disk_div\" style=\"width:640px; height:5000px\"></div>";
    17191719    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 35px; right: 20px;\">";
    17201720    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>";
     
    17351735    echo "     'free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],";
    17361736
    1737     $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";
     1737    //$sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts";
     1738    $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 ";
    17381739    if ($debug) {echo "$sql<br>";}
    17391740    $qry = $db->query($sql);
     
    17531754          if ($ratio >= 97) {
    17541755            # space used over limits, up mode (read/write ok).
    1755             echo "[ \"$host\", ";
     1756            echo "[ \"$host:up\", ";
    17561757            echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
    17571758            echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
     
    17591760          else {
    17601761            # enough space, up mode (read/write ok).
    1761             echo "[ \"$host\", ";
     1762            echo "[ \"$host:up\", ";
    17621763            echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", ";
    17631764            echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],";
     
    17671768          if ($ratio >= 97) {
    17681769            # space used over limits, repair mode (read only).
    1769             echo "[ \"$host\", ";
     1770            echo "[ \"$host:repair\", ";
    17701771            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]\", ";
    17711772            echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
     
    17731774          else {
    17741775            # enough space, but hosts are unstable, repair mode (read only).
    1775             echo "[ \"$host\", ";
     1776            echo "[ \"$host:repair\", ";
    17761777            echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used<br>$hostnote[0]\", ";
    17771778            echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
     
    17801781       else {
    17811782            # down mode (can't read or write).
    1782             echo "[ \"$host\", ";
     1783            echo "[ \"$host:down\", ";
    17831784            echo "      $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $ratio% used<br>$hostnote[0]\", ";
    17841785            echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],";
     
    17981799   echo "               gridlines: {count: 10}";
    17991800   echo "     },";
     1801   echo "     vAxis: { textPosition: 'in', direction: 1 },";
    18001802   echo "     bar: { groupWidth: '95%' },";
    1801    echo "     chartArea: {left:100, top:30, right:20, bottom:40},";
     1803   echo "     chartArea: {left:20, top:30, right:20, bottom:40},";
    18021804   echo "     fontSize: 15,";
    18031805   echo "     isStacked: true,";
     
    18191821###########################################################################
    18201822#
     1823# Gets disk status
     1824#
     1825###########################################################################
     1826function getHosts($db) {
     1827    $start = microtime(true);
     1828
     1829    echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
     1830    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%\">";
     1831    echo "  <div id=\"disk_div\" style=\"width:100%; height:5000px\"></div>";
     1832    echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 50px; right: 20px;\">";
     1833    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgreen\"><center>Free</div>";
     1834    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: yellow\"><center>Used</div>";
     1835    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: pink\"><center>> 97% limit</div>";
     1836    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgrey\"><center>Down | Repair</div>";
     1837    echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: white\"><center>Offline</div>";
     1838    echo "  </div>";
     1839    echo "</div>";
     1840
     1841    // Set environment variables
     1842    putenv("PATH=/usr/local/bin:/usr/bin:/bin:/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/bin");
     1843    putenv("PERL5LIB=/data/ippc65.0/ipp/src/psconfig//ipp-20210708-gentoo.lin64/lib");
     1844
     1845    $hostnoteall = array();
     1846    exec("neb-host |cut -b 17-30,86-", $hostnoteall);
     1847
     1848    $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 ";
     1849    $qry = $db->query($sql);
     1850
     1851    if ($qry === false) {
     1852        echo "<b>Error with SQL query</b><br>";
     1853        return;
     1854    }
     1855
     1856    $dataRows = array();
     1857    $maxUsed = 0;   // initialize before the while loop
     1858
     1859    while ($qry->fetchInto($row)) {
     1860        // Access by index
     1861        $host      = $row[0]; // ipp071.0
     1862        $total     = $row[1]; // 80.0352 TB
     1863        $available = $row[2]; // 10.8096 TB
     1864        $used      = $row[3]; // 69.2256 TB
     1865        $writable  = $row[4]; // 0
     1866        $readable  = $row[5]; // 1
     1867        $ratio     = $row[6]; // 86.4939 %
     1868
     1869        // update maxUsed
     1870        if ($total > $maxUsed) {
     1871            $maxUsed = $total/2;
     1872        }
     1873
     1874        // Match notes
     1875        $hostnotes = preg_grep("/$host/", $hostnoteall);
     1876        $hostnote = reset($hostnotes);
     1877
     1878        // Defaults
     1879        $styles    = "stroke-width: .5; stroke-color: black;";
     1880        $status    = "down";
     1881        $usedColor = "lightgrey";
     1882        $freeColor = "lightgrey";
     1883
     1884        // Status logic
     1885        if ($writable == 1 && $readable == 1) {
     1886            $status    = "up";
     1887            $usedColor = ($ratio >= 97) ? "pink" : "yellow"; // red if ≥97%
     1888            $freeColor = "#a6ec99"; // green free
     1889        } elseif ($writable == 0 && $readable == 1) {
     1890            $status    = "repair";
     1891            $usedColor = ($ratio >= 97) ? "pink" : "yellow";
     1892            $freeColor = "lightgrey"; // grey free
     1893        } elseif ($available < 1) {
     1894            $used      = $maxUsed;
     1895            $available = $maxUsed;
     1896            $status    = "offline";
     1897            $usedColor = "white";
     1898            $freeColor = "white";
     1899        }
     1900
     1901        if ($status == "down") {
     1902            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used ".
     1903                           "<span style='color:red; font-weight:bold;'> <br>" . $hostnote .  "</span>";
     1904            $tooltipFree = "<span style='color:red; font-weight:bold;'>" .
     1905                           $host . ": " . $available . " TB free" .
     1906                           "</span>";
     1907        } elseif ($status == "offline") {
     1908            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used ".
     1909                           "<span style='color:red; font-weight:bold;'> <br>" . $hostnote .  "</span>";
     1910            $tooltipFree = "<span style='color:red; font-weight:bold;'>" .
     1911                           $host . ": " . $total . " TB free" .
     1912                           "</span>";
     1913        } else {
     1914            $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used<br>" . $hostnote;
     1915            $tooltipFree = $host . ": " . $available . " TB free";
     1916        }
     1917
     1918        // Build data row (manual string concatenation for old PHP)
     1919        $dataRows[] =
     1920            "[ \"" . $host . ":" . $status . "\", " .
     1921            $used . ", \"" . $styles . " color: " . $usedColor . ";\", \"" . $tooltipUsed . "\", " .
     1922            $available . ", \"" . $styles . " color: " . $freeColor . ";\", \"" . $tooltipFree . "\" ]";
     1923
     1924    }
     1925    echo "<script type=\"text/javascript\">
     1926            google.charts.load('current', {packages: ['corechart', 'bar']});
     1927            google.charts.setOnLoadCallback(drawBarColors);
     1928
     1929            function drawBarColors() {
     1930                var data = google.visualization.arrayToDataTable([
     1931                    ['Host', 'Used', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}},
     1932                     'Free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],
     1933                    " . implode(",\n", $dataRows) . "
     1934                ]);
     1935
     1936                var options = {
     1937                    title: 'Nebulous Disk Use across IPP Clusters',
     1938                    titleTextStyle: {color: 'black', fontSize: 15},
     1939                    width: '100%',
     1940                    height: '100%',
     1941                    tooltip: {isHtml: true},
     1942                    legend: { position: 'none', alignment: 'end', maxLines: 3 },
     1943                    hAxis: { title: 'Space (TB)', gridlines: {count: 20} },
     1944                    vAxis: { textStyle: {fontSize: 14}, format: 'string',  textPosition: 'in', direction: 1},
     1945                    bar: { groupWidth: '95%' },
     1946                    chartArea: {left:40, top:50, right:20, bottom:40},
     1947                    fontSize: 15,
     1948                    allowHtml: true,
     1949                    isStacked: true
     1950                };
     1951
     1952                var chart = new google.visualization.BarChart(document.getElementById('disk_div'));
     1953                chart.draw(data, options);
     1954            }
     1955          </script>";
     1956
     1957    $total_time = round(microtime(true) - $start, 3);
     1958    echo "<center>loading in $total_time seconds<br></center>";
     1959}
     1960
     1961###########################################################################
     1962#
    18211963# Gets disk spaces status
    18221964#
     
    18291971    $start = $time;
    18301972
    1831     $db->query("SELECT sum(format(available, 2)) FROM hosts where host like 'ippb%'")->fetchInto($row);
     1973
     1974    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ippb%' and xattr <> 3")->fetchInto($row);
    18321975    $ippbusable = $row[0];
    1833     $db->query("SELECT sum(format(available, 2)) FROM hosts where host like 'ippb%' and writable = 1")->fetchInto($row);
     1976    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ippb%' and writable = 1 and xattr <> 3")->fetchInto($row);
    18341977    $ippbfree = $row[0];
    18351978
    1836     $db->query("SELECT sum(format(available, 2)) FROM hosts where host not like 'ippb%'")->fetchInto($row);
     1979    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host not like 'ippb%' and xattr <> 3")->fetchInto($row);
    18371980    $ippusable = $row[0];
    1838     $db->query("SELECT sum(format(available, 2)) FROM hosts where host not like 'ippb%' and writable = 1")->fetchInto($row);
     1981    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host not like 'ippb%' and writable = 1 and xattr <> 3")->fetchInto($row);
    18391982    $ippfree = $row[0];
    18401983
     1984    $db->query("SELECT FORMAT(IFNULL(SUM(available), 0), 1) FROM hosts where host like 'ipp%_bck.0' and xattr <> 3")->fetchInto($row);
     1985    $bckusable = $row[0];
     1986    $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);
     1987    $bckfree = $row[0];
     1988
    18411989    $sql = "select format(used/total*100,1), usable from cluster_space order by timestamp desc limit 1;";
     1990
    18421991    if ($debug) {echo "$sql<br>";}
    18431992    $qry = $db->query($sql);
     
    18512000    echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">";
    18522001    echo "  <div id=\"space_div\" style=\"width:640; \"></div>";
    1853     echo "  <div class=\"overlay\" style=\"position: absolute; width: 400px; bottom: 60px; left: 85px;\">";
    1854     echo "    <div style=\"font-size: 16px; color:#0000ff; background-color:#ffffff\"><b>ipp + ippb nodes: $ippusable + $ippbusable TB (latest usable)</b></div>";
    1855     echo "    <div style=\"font-size: 16px; color:#33a532; background-color:#ffffff\"><b>ipp + ippb nodes: $ippfree + $ippbfree TB (latest free)</b></div>";
     2002    echo "  <div class=\"overlay\" style=\"position: absolute; width: 500px; bottom: 60px; left: 85px;\">";
     2003    echo "    <div style=\"font-size: 16px; color:#0000ff; \"><b>ipp*_bck: $bckusable TB (usable)</b></div>";
     2004    echo "    <div style=\"font-size: 16px; color:#33a532; \"><b>ipp*_bck: $bckfree   TB (free)</b></div>";
    18562005    echo "  </div>";
    18572006    echo "</div>";
     
    18632012    echo "  var data = new google.visualization.DataTable();";
    18642013    echo "        data.addColumn('datetime', 'Day');";
    1865     echo "        data.addColumn('number', 'Usable');";
    1866     echo "        data.addColumn('number', 'Free');";
     2014    echo "        data.addColumn('number', 'Usable (ipp:$ippusable, ippb:$ippbusable) TB');";
     2015    echo "        data.addColumn('number', 'Free (ipp:$ippfree, ippb:$ippbfree) TB');";
    18672016    echo "   data.addRows([";
    18682017    $interval = 10;
  • 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.