-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmetrics-influxdb-condor-capacity
executable file
·33 lines (26 loc) · 1.4 KB
/
metrics-influxdb-condor-capacity
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
#!/usr/bin/python
import htcondor
import classad
coll = htcondor.Collector()
startds = coll.query(htcondor.AdTypes.Startd, "PartitionableSlot =?=True", ["Machine","TotalMemory","Memory","TotalCpus","Cpus","RalScaling","ScalingFactor","RalCluster","StartJobs"])
data = ''
for startd in startds:
# Determine the scaling factor
scalingFactor = 0
if "RalScaling" in startd:
scalingFactor = startd["RalScaling"]
elif "ScalingFactor" in startd:
scalingFactor = startd["ScalingFactor"]
capacityTotal = int(4.0*scalingFactor*startd["TotalCpus"])
capacityIdle = int(4.0*scalingFactor*startd["Cpus"])
capacityUsed = capacityTotal - capacityIdle
memoryTotal = startd["TotalMemory"]
memoryIdle = startd["Memory"]
memoryUsed = memoryTotal - memoryIdle
if "StartJobs" in startd:
if startd["StartJobs"]:
data = data + 'capacity,type=idle,resource=cpu,host='+startd["Machine"]+',tranche='+startd["RalCluster"]+' value='+str(capacityIdle)+'\n'
data = data + 'capacity,type=idle,resource=memory,host='+startd["Machine"]+',tranche='+startd["RalCluster"]+' value='+str(memoryIdle)+'\n'
data = data + 'capacity,type=used,resource=cpu,host='+startd["Machine"]+',tranche='+startd["RalCluster"]+' value='+str(capacityUsed)+'\n'
data = data + 'capacity,type=used,resource=memory,host='+startd["Machine"]+',tranche='+startd["RalCluster"]+' value='+str(memoryUsed)+'\n'
print data