def buildload(self, irc, msg, args):
k = koji.ClientSession('https://koji.fedoraproject.org/kojihub', {})
hosts = hosts = k.listHosts()
total = 0
load = 0
for host in hosts:
total = total + host['capacity']
load = load + host['task_load']
perc = (load / total * 100)
if perc > 95:
status = "Overload!"
elif perc > 80:
status = "Very High Load"
elif perc > 60:
status = "High Load"
elif perc > 40:
status = "Medium Load"
elif perc > 30:
status = "Light Load"
elif perc > 0:
status = "Very Light Load"
elif perc == 0:
status = "No Load"
irc.reply(str('Load: %.1f Total: %.1f Use: %.1f%% (%s)' % (load, total, perc, status ) ))
buildload = wrap(buildload)