Skip to content

Instantly share code, notes, and snippets.

@wrossmck
Last active February 9, 2021 20:50
Show Gist options
  • Save wrossmck/110de5dc0afe79589cf06e41cc9c4643 to your computer and use it in GitHub Desktop.
Save wrossmck/110de5dc0afe79589cf06e41cc9c4643 to your computer and use it in GitHub Desktop.
add queue length
def busyExecutors = Jenkins.instance.computers
.collect {
c -> c.executors.findAll { it.isBusy() }
}
.flatten() // reminder: transforms list(list(executor)) into list(executor)
active = 0
busy = 0
offline = 0
agents = 0
busyExecutors.each { e ->
active = active + 1
}
Jenkins.instance.computers.each{
if(it.isOffline()) {
offline = offline + 1
} else {
if(!it.isIdle()) {
busy = busy + 1
}
agents = agents + 1
}
}
println("Num builds in queue: "+ Jenkins.instance.queue.items.length)
println("Num active jobs : "+ active)
println("Num busy agents : "+ busy)
println("Num offline : "+ offline)
println("Num agents : "+ agents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment