Skip to content

Instantly share code, notes, and snippets.

@stephenc
Last active December 25, 2015 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenc/7041072 to your computer and use it in GitHub Desktop.
Save stephenc/7041072 to your computer and use it in GitHub Desktop.
Estimates the number of executors in use for a Jenkins instance
def int x0 = 0;
def double x1 = 0.0;
def double x2 = 0.0;
println("Total executors")
println("===============")
println("")
println("Sampling every hour")
println("-------------------")
println("")
for (x in Jenkins.instance.overallLoad.totalExecutors.hour.history) {
x0++;
x1+=x;
x2+=x*x;
}
println("Number of observations: " + x0);
if (x0>1) println("Average number of executors: " + Math.round(x1 / x0 * 10) * 0.1);
if (x0>2) println("Sample standard deviation: " + Math.round(Math.sqrt( (x0 * x2 - x1 * x1) / x0 / ( x0 - 1) ) * 10.0) * 0.1);
println("")
println("Sampling every minute")
println("---------------------")
println("")
x0 = 0;
x1 = 0.0;
x2 = 0.0;
println("")
for (x in Jenkins.instance.overallLoad.totalExecutors.min.history) {
x0++;
x1+=x;
x2+=x*x;
}
println("Number of observations: " + x0);
if (x0>1) println("Average number of executors: " + Math.round(x1 / x0 * 10) * 0.1);
if (x0>2) println("Sample standard deviation: " + Math.round(Math.sqrt( (x0 * x2 - x1 * x1) / x0 / ( x0 - 1) ) * 10.0) * 0.1);
x0 = 0;
x1 = 0.0;
x2 = 0.0;
println("")
println("Busy executors")
println("==============")
println("")
println("Sampling every hour")
println("-------------------")
println("")
for (x in Jenkins.instance.overallLoad.busyExecutors.hour.history) {
x0++;
x1+=x;
x2+=x*x;
}
println("Number of observations: " + x0);
if (x0>1) println("Average number of executors: " + Math.round(x1 / x0 * 10) * 0.1);
if (x0>2) println("Sample standard deviation: " + Math.round(Math.sqrt( (x0 * x2 - x1 * x1) / x0 / ( x0 - 1) ) * 10.0) * 0.1);
println("")
println("Sampling every minute")
println("---------------------")
println("")
x0 = 0;
x1 = 0.0;
x2 = 0.0;
println("")
for (x in Jenkins.instance.overallLoad.busyExecutors.min.history) {
x0++;
x1+=x;
x2+=x*x;
}
println("Number of observations: " + x0);
if (x0>1) println("Average number of executors: " + Math.round(x1 / x0 * 10) * 0.1);
if (x0>2) println("Sample standard deviation: " + Math.round(Math.sqrt( (x0 * x2 - x1 * x1) / x0 / ( x0 - 1) ) * 10.0) * 0.1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment