Creating a Collection

A collection is a convenient way to show multiple statistics using one SSID, as described in Representing Sets of Statistics and Events in Using Oracle Solaris 11.4 StatsStore and System Web Interface and Using Collections in Using Oracle Solaris 11.4 StatsStore and System Web Interface.

Use one of the following methods to create a collection:

  • Create a JSON file in the /usr/lib/sstore/metadata/collections/ directory and restart the sstore service. The rules for creating a collection JSON file are documented in the ssid-collection.json(5) man page.

  • Use the API described in the sstore_collection_alloc (3SSTORE) man page.

After the collection is created, you can disable or enable the collection by using the following commands:

  • sstoreadm disable-collection

  • sstoreadm enable-collection

Note:

Statistics in an enabled collection are recorded persistently. Recording too many statistics persistently can degrade system performance, especially if those statistics are expensive to record.

The user1.db-rw.json JSON file in the /usr/lib/sstore/metadata/collections/ directory includes some user-created statistics in a collection:

{
    "$schema": "//:collection",
    "description": "DB rw",
    "enabled": false,
    "id": "db-rw",
    "ssids": [
        "//:class.app/db1//:stat.reads",
        "//:class.app/db1//:stat.writes",
        "//:class.app/db2//:stat.reads",
        "//:class.app/db2//:stat.writes"
    ],
    "user": "user1"
}

This collection is not enabled by default. Instead of persistently recording these statistics, this collection provides a convenient way to access these statistics by using one SSID.

Only user1 can change this collection by using the System Web Interface or the sstoreadm command.

Run the soljsonfmt tool on the .json file to check for JSON syntactic errors. Run the soljsonvalidate tool on the .json file to check for JSON semantic errors. See Using Statistics Store Metadata Files for more information. Make sure you are in a directory where you have write privilege because the soljsonfmt command creates a temporary file.

# soljsonfmt /usr/lib/sstore/metadata/collections/user1.db-rw.json
#

Restart the sstore service. Now you are able to use the collection.

# svcadm restart sstore:default
# sstore list //:class.collection//:collection.name/user1/db-rw
IDENTIFIER
//:class.collection//:collection.name/user1/db-rw

You cannot use the sstore list command to list the statistics that belong to the collection. Use the sstore info command instead.

# sstore info //:class.collection//:collection.name/user1/db-rw
Identifier: //:class.collection//:collection.name/user1/db-rw
  ssid: //:class.app/db1//:stat.reads
  ssid: //:class.app/db1//:stat.writes
  ssid: //:class.app/db2//:stat.reads
  ssid: //:class.app/db2//:stat.writes
 state: disabled
  uuid: 1ca6f562-e00d-42ed-b288-8047345507b6
 owner: user1
 cname: db-rw
crtime: 1464997510390334

You can use the collection SSID to easily record all the statistics that are in the collection:

# sstore capture //:class.collection//:collection.name/user1/db-rw
TIME                VALUE IDENTIFIER
2016-06-03T16:54:20 33352207 //:class.app/db1//:stat.reads
2016-06-03T16:54:20 33316406 //:class.app/db1//:stat.writes
2016-06-03T16:54:20 16438126 //:class.app/db2//:stat.reads
2016-06-03T16:54:20 16370542 //:class.app/db2//:stat.writes