Changeset 42921 for trunk/ippMonitor/raw/storage.php
- Timestamp:
- Sep 10, 2025, 1:11:48 PM (8 months ago)
- File:
-
- 1 edited
-
trunk/ippMonitor/raw/storage.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
