Method: WorkflowManager::FGCZCluster#node_list

Defined in:
lib/workflow_manager/cluster.rb

#node_listObject



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/workflow_manager/cluster.rb', line 243

def node_list
  node2scr = {}
  command = "qhost -F scratch"
  keep = nil
  IO.popen(command) do |out|
    while line=out.gets
      hostname, arch, ncpu, loading, memtot, memuse, *others = line.split
      if hostname =~ /fgcz/
        keep = hostname
      elsif scratch_ = line.chomp.split.last and
            scratch = scratch_.split('=').last
        node2scr[keep] = scratch.to_i
        keep = nil
      end
    end
  end

  list = {}
  keep = nil
  command = 'qhost -q'
  IO.popen(command) do |out|
    while line=out.gets
      # HOSTNAME                ARCH         NCPU  LOAD  MEMTOT  MEMUSE  SWAPTO  SWAPUS
      hostname, arch, ncpu, loading, memtot, memuse, *others = line.split
      if hostname =~ /fgcz/
        #puts [hostname, ncpu, loading, memtot, memuse].join("\t")
        mem = memtot.gsub(/G/, '').to_i
        keep = [hostname, ncpu, "#{mem}G"]
      elsif hostname == "GT" and keep and cores = line.chomp.split.last and cores !~ /[du]/
        hostname = keep.shift
        keep[0] = cores
        if scr = node2scr[hostname] and scr >= 1000
          scr = "%.1f" % (scr.to_f / 1000)
          scr << "T"
        else
          scr = scr.to_s + "G"
        end
        keep << scr
        list[hostname] = keep
        keep = nil
      end
    end
  end

  # reformat
  nodes = {}
  list.each do |hostname, specs|
    # 20190823 masa tentatively off use f47
    unless hostname =~ /fgcz-c-047/
      cores, ram, scr = specs
      key = "#{hostname}: cores #{cores}, ram #{ram}, scr #{scr}"
      value = hostname
      nodes[key] = value
    end
  end
  nodes
end