Configuration page outline
authorBrian Flowers <git-admn@bsflowers.net>
Thu, 22 Sep 2016 17:01:10 +0000 (13:01 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Thu, 22 Sep 2016 17:01:10 +0000 (13:01 -0400)
configure.php

index ba8c86d..aad32ee 100755 (executable)
         <th>Graph Range (values)</th>
         <th>Graph Duration (seconds)</th>
       </tr>
-      <tr><th>www.slightlycyberpunk.com</th></tr>
-      <tr>
-        <td>CPU-US</td>
-        <td><input type="text" value="User CPU" /></td>
-      </tr>
+<?php
+$db_handle  = new SQLite3("/home/bdsm/bdsm.sqlite3");
+$result     = $db_handle->query("SELECT DISTINCT host FROM MEASUREMENTS");
+
+$hosts = Array();
+while($host = $result->fetchArray(SQLITE3_ASSOC))
+  if ( $host['host'] )
+    array_push($hosts, $host['host']);
+
+foreach ($hosts as $host)
+{
+    echo "      <tr><th>$host</th></tr>";
+    $result = $db_handle->query("SELECT DISTINCT attribute FROM MEASUREMENTS WHERE host='$host'");
+    $attributes = Array();
+    while($attribute = $result->fetchArray(SQLITE3_ASSOC))
+      if ( $attribute['attribute'] )
+        array_push($attributes, $attribute['attribute']);
+    
+    echo "      <tr>";
+    echo "        <td>$attribute</td>";
+    echo "        <td><input type='text' name='$host-$attribute-name' value='' /></td>";
+    echo "        <td><input type='checkbox' name='$host-$attribute-graph' /></td>";
+    echo "        <td><input type='text' name='$host-$attribute-min' value='' />".
+                  ."<input type='text' name='$host-$attribute-max' value='' /></td>";
+    echo "        <td><input type='text' name='$host-$attribute-duration' value='' /></td>";
+    echo "      </tr>";
+}
+?>
     </table>
   </BODY>
 </HTML>