Changeset 42921
- Timestamp:
- Sep 10, 2025, 1:11:48 PM (10 months ago)
- Location:
- trunk/ippMonitor
- Files:
-
- 5 edited
-
czartool/czarpoll.pl (modified) (2 diffs)
-
czartool/czartool/CzarDb.pm (modified) (2 diffs)
-
czartool/czartool/Nebulous.pm (modified) (6 diffs)
-
raw/czartool_labels.php (modified) (13 diffs)
-
raw/storage.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippMonitor/czartool/czarpoll.pl
r42858 r42921 654 654 my $readable = 1; 655 655 my $writable = 1; 656 my $xattr = 0; 656 657 657 658 #print "Mount $mount_point: total=${total_tb}TB, used=${used_tb}TB (${used_percent}%), available=${available_tb}TB (${available_percent}%)\n"; … … 660 661 #my $host_label = "$host.$suffix(${total_tb}T)"; 661 662 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 346 346 ########################################################################### 347 347 sub updateHost { 348 my ($self, $host, $total, $available, $used, $readable, $writable ) = @_;348 my ($self, $host, $total, $available, $used, $readable, $writable, $xattr) = @_; 349 349 350 350 my $query = $self->{_db}->prepare(<<SQL); … … 355 355 $query = $self->{_db}->prepare(<<SQL); 356 356 INSERT INTO hosts 357 (host, total, available, used, readable, writable )357 (host, total, available, used, readable, writable, xattr) 358 358 VALUES 359 ('$host', $total, $available, $used, $readable, $writable );359 ('$host', $total, $available, $used, $readable, $writable, $xattr); 360 360 SQL 361 361 $query->execute; -
trunk/ippMonitor/czartool/czartool/Nebulous.pm
r42794 r42921 96 96 my $readable; 97 97 my $writable; 98 my $xattr; 98 99 foreach $line (@cmdOut) { 99 100 … … 120 121 if ($4 >= 98) {$self->{_hostsOverNinetyEightPC}++;} 121 122 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 123 126 124 127 $self->{_czarDb}->updateHost($1, … … 126 129 $self->convertKbToTb($3), 127 130 $self->convertKbToTb($2), 128 $readable, $writable );131 $readable, $writable, $xattr); 129 132 } 130 133 } … … 144 147 ########################################################################### 145 148 sub getReadableWritableStatus { 146 my ($self, $ host, $readable, $writable) = @_;149 my ($self, $name, $readable, $writable, $xattr) = @_; 147 150 148 151 ${$readable} = 0; 149 152 ${$writable} = 0; 153 ${$xattr} = 0; 150 154 151 155 my @cmdOut = `neb-host`; … … 154 158 155 159 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) { 157 161 158 162 # if mounted... … … 161 165 ${$readable} = $3; 162 166 ${$writable} = $2; 167 ${$xattr} = $4; 163 168 } 164 169 } -
trunk/ippMonitor/raw/czartool_labels.php
r42902 r42921 1706 1706 # 1707 1707 ########################################################################### 1708 function getHosts ($db) {1708 function getHostsold($db) { 1709 1709 // timer start 1710 1710 $time = microtime(); … … 1716 1716 echo "<script type=\"text/javascript\" src=\"loader.js\"></script>"; 1717 1717 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>"; 1719 1719 echo " <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 35px; right: 20px;\">"; 1720 1720 echo " <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: #00ff00\"><center>Free</div>"; … … 1735 1735 echo " 'free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],"; 1736 1736 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 "; 1738 1739 if ($debug) {echo "$sql<br>";} 1739 1740 $qry = $db->query($sql); … … 1753 1754 if ($ratio >= 97) { 1754 1755 # space used over limits, up mode (read/write ok). 1755 echo "[ \"$host \", ";1756 echo "[ \"$host:up\", "; 1756 1757 echo " $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ff0000;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", "; 1757 1758 echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],"; … … 1759 1760 else { 1760 1761 # enough space, up mode (read/write ok). 1761 echo "[ \"$host \", ";1762 echo "[ \"$host:up\", "; 1762 1763 echo " $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used</b></i><br>$hostnote[0]\", "; 1763 1764 echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #00ff00;\", \"<i><b>$host: $available TB free</b></i>\"],"; … … 1767 1768 if ($ratio >= 97) { 1768 1769 # space used over limits, repair mode (read only). 1769 echo "[ \"$host \", ";1770 echo "[ \"$host:repair\", "; 1770 1771 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]\", "; 1771 1772 echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],"; … … 1773 1774 else { 1774 1775 # enough space, but hosts are unstable, repair mode (read only). 1775 echo "[ \"$host \", ";1776 echo "[ \"$host:repair\", "; 1776 1777 echo " $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #ffff00;\", \"<i><b>$host: $ratio% of $total TB used<br>$hostnote[0]\", "; 1777 1778 echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],"; … … 1780 1781 else { 1781 1782 # down mode (can't read or write). 1782 echo "[ \"$host \", ";1783 echo "[ \"$host:down\", "; 1783 1784 echo " $used, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $ratio% used<br>$hostnote[0]\", "; 1784 1785 echo " $available, \"stroke-width: 0.3;\"+\"stroke-color: black;\"+\"color: #bbbbbb;\", \"<i><b>$host: $available TB free</b></i>\"],"; … … 1798 1799 echo " gridlines: {count: 10}"; 1799 1800 echo " },"; 1801 echo " vAxis: { textPosition: 'in', direction: 1 },"; 1800 1802 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},"; 1802 1804 echo " fontSize: 15,"; 1803 1805 echo " isStacked: true,"; … … 1819 1821 ########################################################################### 1820 1822 # 1823 # Gets disk status 1824 # 1825 ########################################################################### 1826 function 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 # 1821 1963 # Gets disk spaces status 1822 1964 # … … 1829 1971 $start = $time; 1830 1972 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); 1832 1975 $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); 1834 1977 $ippbfree = $row[0]; 1835 1978 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); 1837 1980 $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); 1839 1982 $ippfree = $row[0]; 1840 1983 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 1841 1989 $sql = "select format(used/total*100,1), usable from cluster_space order by timestamp desc limit 1;"; 1990 1842 1991 if ($debug) {echo "$sql<br>";} 1843 1992 $qry = $db->query($sql); … … 1851 2000 echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 640; height:400\">"; 1852 2001 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 (latestusable)</b></div>";1855 echo " <div style=\"font-size: 16px; color:#33a532; background-color:#ffffff\"><b>ipp + ippb nodes: $ippfree + $ippbfree TB (latestfree)</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>"; 1856 2005 echo " </div>"; 1857 2006 echo "</div>"; … … 1863 2012 echo " var data = new google.visualization.DataTable();"; 1864 2013 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');"; 1867 2016 echo " data.addRows(["; 1868 2017 $interval = 10; -
trunk/ippMonitor/raw/storage.php
r42736 r42921 52 52 echo "<script type=\"text/javascript\" src=\"loader.js\"></script>"; 53 53 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>"; 55 55 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>"; 61 61 echo " </div>"; 62 62 echo "</div>"; … … 69 69 exec("neb-host |cut -b 17-30,86-", $hostnoteall); 70 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"; 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 "; 74 72 $qry = $db->query($sql); 75 73 … … 80 78 81 79 $dataRows = array(); 80 $maxUsed = 0; // initialize before the while loop 81 82 82 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 92 98 $hostnotes = preg_grep("/$host/", $hostnoteall); 93 99 $hostnote = reset($hostnotes); 94 100 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 96 108 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 99 112 } 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>"; 102 136 } else { 103 $usedColor = $freeColor = "#bbbbbb"; 137 $tooltipUsed = $host . ": " . round($ratio, 1) . "% of " . $total . " TB used<br>" . $hostnote; 138 $tooltipFree = $host . ": " . $available . " TB free"; 104 139 } 105 140 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 108 147 } 109 110 148 echo "<script type=\"text/javascript\"> 111 149 google.charts.load('current', {packages: ['corechart', 'bar']}); … … 126 164 tooltip: {isHtml: true}, 127 165 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}, 129 168 bar: { groupWidth: '95%' }, 130 chartArea: {left: 100, top:50, right:20, bottom:40},169 chartArea: {left:40, top:50, right:20, bottom:40}, 131 170 fontSize: 15, 171 allowHtml: true, 132 172 isStacked: true 133 173 }; … … 155 195 $start = $time; 156 196 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); 158 198 $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); 160 200 $ippbfree = $row[0]; 161 201 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); 163 203 $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); 165 205 $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 166 212 167 213 $sql = "select format(used/total*100,1), usable from cluster_space order by timestamp desc limit 1;"; … … 178 224 echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%; height:400\">"; 179 225 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 (latestusable)</b></div>";182 echo " <div style=\"font-size: 16px; color:#33a532; background-color:#ffffff\"><b>ipp + ippb nodes: $ippfree + $ippbfree TB (latestfree)</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>"; 183 229 echo " </div>"; 184 230 echo "</div>"; … … 190 236 echo " var data = new google.visualization.DataTable();"; 191 237 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');"; 194 240 echo " data.addRows(["; 195 241 $interval = 10;
Note:
See TracChangeset
for help on using the changeset viewer.
