Collect Data for Dynamically Allocated Resources

The example described in this section is similar to the previous example. The difference is that in this example you do not know ahead of time how many or which application instances will be configured on the system. The resources in this example are dynamically allocated in the application using the sstore_resource_add() interface.

The sstore_resource_add() interface protects against multiple applications providing data for the same resources as described in the following comparison:

  • To allocate resources statically, you must assume the root role; the metadata files and directories are owned by root. If you add conflicting metadata, you will get errors when you restart the sstore service.

  • To allocate resources dynamically, you must call sstore_resource_add() to add the resource metadata to the statistics repository. If you try to add metadata that is already in the statistics store, you will get an error return.

Note that a single class can have both statically-allocated resources and dynamically-allocated resources. For example, the svc class has one static resource: the default restarter service system/svc/restarter:default. Other services are added dynamically as the services are installed on the system.