Populate the Statistics Store Namespace

In this example, the application that produces the statistics is a custom application named util1.

In the /usr/lib/sstore/metadata/json/site/ directory, create the file class.app.util1.json with the following content to define the class for the util1 application. Note that files in /usr/lib/sstore/metadata/json/site/ are owned by root.

{
    "$schema": "//:class",
    "description": "Example using count data and sstore_data_attach()",
    "id": "app/util1",
    "stability": "stable",
    "stat-names": [
        "//:stat.reads",
        "//:stat.writes",
        "//:stat.errors"
    ]
}

If you might change the semantic meaning of a statistic (for example, the type of the statistic), set the value of stability to unstable.

To define the statistics for this example, create the file stat.util1.json with the following content in the /usr/lib/sstore/metadata/json/site/ directory:

[
    {
        "$schema": "//:stat",
        "description": "reads",
        "id": "//:class.app/util1//:stat.reads",
        "stability": "stable",
        "type": "counter",
        "units": "operations"
    },
    {
        "$schema": "//:stat",
        "description": "writes",
        "id": "//:class.app/util1//:stat.writes",
        "stability": "stable",
        "type": "counter",
        "units": "operations"
    },
    {
        "$schema": "//:stat",
        "description": "errors",
        "id": "//:class.app/util1//:stat.errors",
        "stability": "stable",
        "type": "counter",
        "units": "errors"
    }
]

Run the soljsonfmt tool on the .json file to check for JSON syntactic errors:

# soljsonfmt class.app.util1.json stat.util1.json

Run the soljsonvalidate tool on the .json file to check for JSON semantic errors:

# soljsonvalidate class.app.util1.json stat.util1.json

Use the v option to see a list of each element and the schema against which that element was validated.

You must restart the sstore:default service to see the new class SSID.

$ sstore list //:class.app/util1
Warning (//:class.app/util1) - lookup error: no matches found

Restart the statistics store:

$ svcadm restart sstore:default

Ensure that sstore:default and other services are online:

$ svcs -x

Check whether the metadata files imported correctly:

$ svcs -Lx sstore

The log file should show no errors and should show that the start method exited with status 0.

Try again to list the new class SSID:

$ sstore list //:class.app/util1
IDENTIFIER
//:class.app/util1

Show the metadata for the class:

$ sstore info //:class.app/util1
 Identifier: //:class.app/util1
  stability: stable
    $schema: //:class
description: Example using count data and sstore_data_attach()
         id: app/util1
 stat-names: //:stat.reads
 stat-names: //:stat.writes
 stat-names: //:stat.errors

Except for the stat-names statistic names shown in the class information, you cannot get any information about statistics until you provide values for the statistics as shown in Update and View Statistic Values.

$ sstore list //:class.app/util1//:*
Warning (//:class.app/util1//:*) - lookup error: no matches found
$ sstore list //:class.app/util1//:stat.*
Warning (//:class.app/util1//:stat.*) - lookup error: no matches found
$ sstore list //:class.app/util1//:stat.reads
Warning (//:class.app/util1//:stat.reads) - lookup error: no matches found