How to list the managed controllers and its resources

Article ID:360028137611
1 minute readKnowledge base

Issue

  • I want to list all the managed controllers and the resources associated with it.

Environment

Resolution

You will need to run a groovy script on the Operations Center. Open CloudBees Core Cloud Operations Center, and continue to Manage Jenkins. Select Script Console. Run the following groovy script.

/**
* List Managed controllers and its Resources
 */

def mms = Jenkins.instance.getAllItems(com.cloudbees.opscenter.server.model.ManagedMaster)

String outputFormat = "%-56s%-8s%-10s%-14s%-10s%s\n"
String output = String.format(outputFormat,
    "Managed controller Full Display Name", "Id", "Cpus", "Memory[MB]", "Ratio", "Disk [GB]")
println(output)

mms.each {
  it.getPersistedState().resource.each { p ->
    output = String.format(outputFormat,
        it.getFullDisplayName(), it.id, p.getCpus(), p.getMemory(), p.getRatio(), p.getDisk())
    print(output)
  }
}
null