status for idle nodes, rename good->active, bad->stale
smbaker [Tue, 18 Dec 2012 23:01:28 +0000 (15:01 -0800)]
apps/gacksadmin/nodestatus.php

index 4fbe166..11489d4 100644 (file)
@@ -78,7 +78,7 @@ $gacksapi = new GACKSAPI();
 $nodes = $gacksapi->call("admin_get_node_status");
 
 $clusters = array();
-foreach ( $nodes as $hostname => $fields) {
+foreach ( $nodes as $hostname => &$fields) {
     $parts = explode(".", $hostname);
     if (count($parts)>1) {
         $cluster = $parts[1];
@@ -88,13 +88,18 @@ foreach ( $nodes as $hostname => $fields) {
         }
 
         $totals = $clusters[$cluster];
-        if ($fields["date"] + 2*60*60 > time()) {
-            $totals["good"] = $totals["good"] + 1;
+        if ($fields["date"] + 2*60*60 <= time()) {
+            $fields["status"] = "stale";
+            $totals["stale"] = $totals["stale"] + 1;
+        } elseif (($fields["charge"]<=0) && ($fields["resv_charge"]<=0)) {
+            $fields["status"] = "idle";
+            $totals["idle"] = $totals["idle"] + 1;
+        } else {
+            $fields["status"] = "active";
+            $totals["active"] = $totals["active"] + 1;
             $totals["charge"] = $totals["charge"] + $fields["charge"];
             $totals["resv_charge"] = $totals["resv_charge"] + $fields["resv_charge"];
             $totals["core_charge"] = $totals["core_charge"] + $fields["core_charge"];
-        } else {
-            $totals["bad"] = $totals["bad"] + 1;
         }
         $clusters[$cluster] = $totals;
     }
@@ -102,8 +107,9 @@ foreach ( $nodes as $hostname => $fields) {
 
 $headers = array();
 $headers["cluster"] = "string";
-$headers["good"] = "integer";
-$headers["bad"] = "integer";
+$headers["active"] = "integer";
+$headers["idle"] = "integer";
+$headers["stale"] = "integer";
 $headers["charge"] = "integer";
 $headers["resv_charge"] = "integer";
 $headers["core_charge"] = "integer";
@@ -115,8 +121,9 @@ $table->start();
 foreach ( $clusters as $cluster => $fields) {
     $table->row_start();
     $table->cell($cluster);
-    $table->cell($fields["good"]);
-    $table->cell($fields["bad"]);
+    $table->cell($fields["active"]);
+    $table->cell($fields["idle"]);
+    $table->cell($fields["stale"]);
     $table->cell($fields["charge"]);
     $table->cell($fields["resv_charge"]);
     $table->cell($fields["core_charge"]);
@@ -127,7 +134,7 @@ $headers=array();
 $headers["id"] = "integer";
 $headers["hostname"] = "sortHostNameReverse"; //array("type"=>"sortHostNameReverse");
 $headers["date"] = "string";
-$headers["good?"] = "string";
+$headers["status"] = "string";
 $headers["charge"] = "float";
 $headers["resv-charge"] = "float";
 $headers["core-charge"] = "float";
@@ -141,11 +148,7 @@ foreach ( $nodes as $hostname => $fields ) {
     $table->cell($fields['id']);
     $table->cell($hostname);
     $table->cell($fields['datestr']);
-    if ($fields["date"] + 2*60*60 > time()) {
-        $table->cell("good");
-    } else {
-        $table->cell("bad");
-    }
+    $table->cell($fields['status']);
     $table->cell($fields['charge']);
     $table->cell($fields['resv_charge']);
     $table->cell($fields['core_charge']);