Producing Inventory

Producing Inventory
This article provides information about producing inventory from a probe.
How to Produce Probe Inventory
A probe developer should complete the following tasks to produce probe inventory:
  • Define inventory elements in probe_schema.xml.
  • Run the Maven build to generate Java classes based on the definitions in probe_schema.xml. Issue the command:
    mvn generate-sources
  • Implement the getUpdatedInventory() method to return an InventoryDataset that contains your inventory elements.
After the inventory elements have been defined in probe_schema.xml, and the associated Java classes have been created, you build your inventory in the getUpdatedInventory() method. For example, if you are working with the inventory defined in the mock_vm_host example probe, the inventory shown in the following illustration is produced and visible in the Template Editor:
Probe Inventory.png
The following example implementation of getUpdatedInventory() would produce the inventory shown in the illustration.
public IInventoryDataset getUpdatedInventory(ResourceConfig rc, IInventoryDataset previousDataset) throws NimException, InterruptedException { // Create a new, empty InventoryDataset. We will pass this to the // *.addInstance() method of every element we create. InventoryDataset ids = new InventoryDataset(rc); // Create a folder named "Hosts" and attach it to the Resource Folder hostsFolder = Folder.addInstance(ids, new EntityId(rc,"hosts"), "Hosts", rc); // Create an instance of a MyHost element named "host-1" and add // as a child of the hosts folder MyHost host1 = MyHost.addInstance(ids, new EntityId(rc, "host-1"), "host-1", hostsFolder); // Continue building the inventory tree using the same concepts // shown above Folder vmsFolder = Folder.addInstance(ids, new EntityId(host1,"vm"), "vm", host1); MyVM myVM1 = MyVM.addInstance(ids, new EntityId(host1, "vm-1"), "vm-1", vmsFolder); MyVMMemory myMemory = MyVMMemory.addInstance(ids, new EntityId(myVM1, "memory"), "memory", myVM1); Folder vmCPUFolder = Folder.addInstance(ids, new EntityId(myVM1,"CPUs"), "CPUs", myVM1); MyVMCPU myCPUElement = MyVMCPU.addInstance(ids, new EntityId(myVM1, "cpu- 1"), "cpu-1", vmCPUFolder); return ids; }
Allowing for Shutdown Interruption
If your probe has a long running collection cycle you should periodically invoke ProbeBase.handleInventoryCollectionInterrupt(). This detects a shutdown request and interrupts the collection cycle and allow the probe to honor the shutdown request.
Hiding the Detached Configuration Folder
In the probe configuration GUI, the
Detached Configuration
folder is displayed by default. You can disable this function by using Raw Configure in Admin Console, or directly on the filesystem. Using Raw Configure, enter
property show_detached_configuration=false
in the Setup section of the probe .cfg file.