-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclview.py
executable file
·53 lines (50 loc) · 1.42 KB
/
clview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
#
# Author: Martin Souchal <[email protected]>
# Date : 12 avril 2018
# Desc. : Cluster resources overview
#
#
#
import pbs
from PBSQuery import PBSQuery
from PBSQuery import PBSError
from tabulate import tabulate
import sys
import re
def main():
p = PBSQuery()
p.new_data_structure()
nodes = p.getnodes()
l=list()
jobs = "none"
for id in nodes:
try:
queue = nodes[id].properties[0]
state = nodes[id].state[0]
power = nodes[id].power_state[0]
np = nodes[id].np[0]
name = nodes[id].name
memory = nodes[id].status.physmem[0]
memory = memory[:-2]
memory = int(memory)
memory = memory/1000000
load = nodes[id].status.loadave[0]
display = " "
if hasattr(nodes[id],"jobs"):
jobs = nodes[id].jobs
results = len(jobs)
for result in range(results):
display += "x"
#result = str()
#s = ", "
#result = s.join(jobs)
else:
display = "0"
l.append([name,state,power,queue,np,memory,load,display])
except PBSError, detail:
print detail
pass
l.sort()
print tabulate(l, headers=["Node","State", "Power state", "Queue", "CPU", "MEM", "Load", "jobs"], tablefmt="rst")
main()