Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

12.2. Getting the JBoss ON ID for an Object

Everything in JBoss ON — resources, configuration properties, bundle archives, templates, alerts, everything — is identified with a unique ID number. Most of these ID numbers are visible in the web UI as part of the URL which goes to that object's details page.
Not every ID is easily found, though. For example, searching for a metric template requires the resource type ID, but the resource type ID is hard to find.
In other instances, you may want to run a script against multiple resources, which means there are multiple resource IDs which may not be explicitly known at the time you write the script.
Searching for a resource (Section 12.1, “Searches”) retrieves the resource's details, including its ID.
rhqadmin@localhost:7080$ criteria = new ResourceCriteria();
  ResourceCriteria:
  inventoryManagerRequired: false
  persistentClass: class org.rhq.core.domain.resource.Resource

  rhqadmin@localhost:7080$ criteria.addFilterResourceTypeName('Linux')

  rhqadmin@localhost:7080$ ResourceManager.findResourcesByCriteria(criteria);
  one row
  Resource:
  id: 10001
  name: gs-dl585g2-01.rhts.eng.bos.redhat.com
  version: Linux 2.6.32-220.el6.x86_64
  currentAvailability: UP
  resourceType: Linux
This is true for any *Criteria search. It retrieves the ID for the object is searches for, even if that ID is not explicitly displayed.
This ID can then be used in other operations.
rhqadmin@localhost:7080$ var metrics = MeasurementDataManager.findLiveData(resources.get(0).id, [mdefs.get(0).id]);