show "sinfo" results on /nodes page
authorTom Clegg <tom@clinicalfuture.com>
Fri, 22 Feb 2013 23:17:12 +0000 (15:17 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Fri, 22 Feb 2013 23:17:12 +0000 (15:17 -0800)
app/assets/stylesheets/nodes.css
app/controllers/nodes_controller.rb
app/views/nodes/index.html.erb

index ba901922f108cc540393a89c2f1e4ee009efd337..79b7293f17c57f707992da3072d0403bc5c1fdef 100644 (file)
@@ -6,12 +6,32 @@
     /* unknown status - might be bad */
     background: #ff8888;
 }
-.node-status-running {
+.node-status-running .node-status {
     background: #88ff88;
 }
-.node-status-missing {
+.node-status-missing .node-status {
     background: #ff8888;
 }
-.node-status-terminated {
+.node-status-terminated .node-status {
     background: #ffffff;
 }
+
+.node-slurm-state {
+    /* unknown status - might be bad */
+    background: #ff8888;
+}
+.node-status-missing .node-slurm-state {
+    background: #ffffff;
+}
+.node-status-terminated .node-slurm-state {
+    background: #ffffff;
+}
+.node-status-running .node-slurm-state-alloc {
+    background: #88ff88;
+}
+.node-status-running .node-slurm-state-idle {
+    background: #ffbbbb;
+}
+.node-status-running .node-slurm-state-down {
+    background: #ff8888;
+}
index 5dce1b13cc5273bc8926d656cf67a48e5f83c5f9..1b4e37dad06e4121b13e0f9c6430724e168f8302 100644 (file)
@@ -1,5 +1,30 @@
 class NodesController < ApplicationController
   def index
     @objects = model_class.order("created_at desc")
+
+    @slurm_state = {}
+    IO.popen('sinfo --noheader --Node || echo "compute[1-3] foo bar DOWN"').readlines.each do |line|
+      tokens = line.strip.split
+      nodestate = tokens.last
+      nodenames = []
+      if (re = tokens.first.match /^([^\[]*)\[([-\d,]+)\]$/)
+        nodeprefix = re[1]
+        re[2].split(',').each do |number_range|
+          if number_range.index('-')
+            range = number_range.split('-').collect(&:to_i)
+            (range[0]..range[1]).each do |n|
+              nodenames << "#{nodeprefix}#{n}"
+            end
+          else
+            nodenames << "#{nodeprefix}#{number_range}"
+          end
+        end
+      else
+        nodenames << tokens.first
+      end
+      nodenames.each do |nodename|
+        @slurm_state[nodename] = nodestate.downcase
+      end
+    end
   end
 end
index d4e8aa1edafb560b620aa19f020de828c82cd25e..bb346e96760f2b5d695671d29e151f138302487c 100644 (file)
@@ -2,6 +2,8 @@
   <tr class="contain-align-left">
     <th>
       status
+    </th><th>
+      sinfo
     </th><th>
       uuid
     </th><th>
 
   <% @objects.each do |o| %>
 
-  <tr class="node-status node-status-<%= o.status %>" data-showhide-selector="tr#extra-info-<%= o.uuid %>" style="cursor:pointer">
-    <td>
+  <tr class="node-status-<%= o.status %>">
+    <td class="node-status" data-showhide-selector="tr#extra-info-<%= o.uuid %>" style="cursor:pointer">
       <%= o.status %>
+    </td><td class="node-slurm-state node-slurm-state-<%= @slurm_state[o.hostname] %>">
+      <%= @slurm_state[o.hostname] %>
     </td><td>
       <%= o.uuid %>
     </td><td>
@@ -47,7 +51,7 @@
 
   <% if  %>
   <tr id="extra-info-<%= o.uuid %>" <%= 'data-showhide-default' unless o.info[:ec2_start_command] and !o.first_ping_at %>>
-    <td colspan="8">
+    <td colspan="9">
       <dl>
       <% o.info.each do |k,v| %>
       <dt><em><%= k %></em></dt>