ssid-op, ssid-fmt - 统计信息存储运算和格式
Oracle Solaris Statistics Store 使用统计信息存储标识符 (statistics store identifier, SSID) 来命名统计信息和事件。有关更多信息,请参见 ssid(7) 手册页。SSID 还可以包括运算符 (//:op),以对统计信息应用各种数学运算和统计运算。SSID 还可以指定事件信息的格式 (//:fmt)。
op 和 fmt 参数集是预定义的。统计信息或事件的可用运算受其类型限制。
您可以查询有关某个运算的元数据,方法是对包含该运算的完整 SSID 使用 sstore 的 info 子命令。有关更多信息,请参见 sstore(1) 手册页。
还可以组合运算。有关更多信息,请参见“示例”部分中的示例 9。
定义统计信息时,请参见 ssid-metadata(7) 手册页以提供这些运算所使用的元数据。
sstore 运算和格式列表及其描述:
op.min(Optional percentage) op.max(Optional percentage) op.avg(Optional agg) op.difference op.quotient op.sum op.product op.rate op.delta op.util op.convert (Required unit) op.filter (Required value) op.changed op.count op.top (Optional Limit, Optional Metric) fmt.summary fmt.action fmt.impact fmt.response fmt.description fmt.label fmt.raw
min 和 max 可搜索指定 SSID 的数据点在指定时间范围内的极值。这些运算还可以采用可选的百分比参数。
min 和 max 提供以下范围内的数据点:
min - [min + (max-min) * pct / 100](对于 op.min(pct))
max - [min + (max-min) * pct / 100](对于 op.max(pct))
有关更多信息,请参见示例 1。
op.avg (Optional agg)
op.difference
op.product
op.quotient
op.sum
avg、difference、product、quotient 和 sum 通过匹配不同 SSID 中的时间戳并相应地计算值,在这些 SSID 之间执行算术运算。使用通配符或多个 SSID 时,这些运算会将结果合并到第一个 SSID 中,如示例 2 中所示。
avg 还可以采用可选的聚合参数 agg。此可选字段可以设置为 agg=all 或 agg=time。如果指定了 agg,avg 将计算提供的所有 SSID 或一个 SSID 中的所有数据点的平均值。不在 SSID 之间匹配时间戳。有关更多信息,请参见示例 3。
filter 仅返回与提供的参数显式匹配的数据点,如示例 4 中所示。
可以通过计算 SSID 的两个连续数据点之间的变化和变化率来获取有关 SSID 的 rate 和 delta。假定有两个点,一个在时间戳 time1 的值为 value1,另一个在时间戳 time2 的值为 value2,数据点的计算方式如下:
(value2-value1)/(time2-time1) for op.rate
(value2-value1) for op.delta
这将针对某个 SSID 中的所有数据点进行计算,如示例 5 中所示。
//:op.rate 和 //:op.delta 至少需要两个数据点才能完成上述计算。如果仅存在一个数据点,这些运算将返回NO_DATA.对于历史查询,这些运算将尝试从用户指定的时间范围之前的时间戳获取一个额外的数据点。如果发生事件,此额外的点可能不存在,则在计算用户查询的第一个值与未指定的时间戳的不存在的值之间的变化时,这些运算会跳过将出现的第一个NO_DATA 。
utilization 的计算方式有所不同,具体取决于是否已指定分区。对于分区统计信息,该运算将计算分区中的所有(键、值)对总数。然后,每个值将替换为总数的百分比。有关更多信息,请参见示例 6。
对不是分区的 SSID 应用 util 时,将搜索元数据以确定该 SSID 是否具有某个已知容量。找到后,按该容量所占的百分比计算 SSID 的值。
将统计信息值转换为所需单位。用户必须在运算的参数部分指定所需单位。sstore 支持的各种单位类型如下。这些关键字遵守 IEEE 标准 - https://en.wikipedia.org/wiki/IEEE_1541-2002。
速度/大小:位、千位、兆位、千兆位、兆兆位、千兆兆位、艾位、字节、千字节、兆字节、千兆字节、兆兆字节、千兆兆字节、艾字节、二进制千位、二进制兆位、二进制千兆位、二进制兆兆位、二进制拍位、二进制艾位、二进制千字节、二进制兆字节、二进制千兆字节、二进制兆兆字节、二进制拍字节、二进制艾字节、页
时间:纳秒、微秒、毫秒、秒、分钟、小时、天、周、年
温度:摄氏度、华氏度
使用 op.convert 时,如果提供对统计信息无效的参数类型,将导致转换失败。例如,对 units=bytes 的统计信息使用 op.convert(分钟)。有关 //:op.convert 用法的更多信息,请参见示例 7。
提供非事件统计信息更改的时间戳和值。
按值对输出排序,然后将输出限制为 top 元素。此操作不会过滤与给定 SSID 关联的数据,而是从返回的结果中删除不受关注的 SSID。如果未指定参数,//:op.top 将在返回结果中最多保留 5 个 SSID,等效于 //:op.top(5)。大多数查询有多个与给定 SSID 关联的历史值。缺省情况下,//:op.top 通过取这些值的平均值来对其进行加权,然后在对每个 SSID 排序时比较这些平均值。使用可选的度量参数可修改它。度量可取 'max' 或 'variance' 的值,以分别按照其最大值或差异值对数据集进行加权。//op.top 还有一个副作用,就是过滤出在请求范围内不包含数据的所有 SSID。
与已分区的 SSID 结合使用时,此操作一次仅作用于一个分区,并过滤出分区键。如果已分区的 SSID 集中在包含未分区的 SSID 的查询中,则忽略已分区的 SSID。
提供查询中的 ssid 的计数。此运算符对数字和字符串有效,对事件类型统计信息也有效。
fmt.label 格式在输出的值列中显示事件的标签。
fmt.description 格式在输出的值列中显示事件的描述。
fmt.summary 格式会同时显示事件的标签和说明。
如果未指定任何格式设置或指定了 fmt.raw,则输出会显示为名称-值对的列表。有关如何设置事件数据格式的更多信息,请参见示例 8。
以下示例将通过 op.min 或 op.max (agg) 导出统计信息。
$ sstore export -t 2016-03-10T13:18:34 -e 2016-03-10T13:18:38 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate TIME VALUE IDENTIFIER 2016-03-10T13:18:35 9202.092374581405 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate 2016-03-10T13:18:36 8065.265410471358 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate 2016-03-10T13:18:37 59.94155698194261 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate 2016-03-10T13:18:38 8758.661754010182 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate $ sstore export -t 2016-03-10T13:18:34 -e 2016-03-10T13:18:38 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.min TIME VALUE IDENTIFIER 2016-03-10T13:18:37 59.94155698194261 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.min $ sstore export -t 2016-03-10T13:18:34 -e 2016-03-10T13:18:38 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.max(10) TIME VALUE IDENTIFIER 2016-03-10T13:18:35 9202.092374581405 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.max(10) 2016-03-10T13:18:36 8065.265410471358 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.max(10) 2016-03-10T13:18:38 8758.661754010182 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.max(10)示例 2 通过 op.sum 导出统计信息
以下示例将通过 op.sum 导出统计信息。
$ sstore export -t 2016-03-10T23:03:40 -p 1 //:class.cpu//:res.id/*//:stat.interrupt-count TIME VALUE IDENTIFIER 2016-03-10T23:03:40 56409717.0 //:class.cpu//:res.id/0//:stat.interrupt-count 2016-03-10T23:03:40 35839679.0 //:class.cpu//:res.id/1//:stat.interrupt-count 2016-03-10T23:03:40 35913257.0 //:class.cpu//:res.id/2//:stat.interrupt-count 2016-03-10T23:03:40 177732121.0 //:class.cpu//:res.id/3//:stat.interrupt-count $ sstore export -t 2016-03-10T23:03:40 -p 1 //:class.cpu//:res.id///:s.[0,2]//:stat.interrupt-count//:op.sum TIME VALUE IDENTIFIER 2016-03-10T23:03:40 92322974.0 //:class.cpu//:res.id/0//:stat.interrupt-count//:op.sum示例 3 通过 op.avg 或 op.avg (agg) 导出统计信息
这将显示 net0 的 out-bytes 和 in-bytes 在每个时间戳的平均速率,并将结果保存在 out-bytes 统计信息中。
$ sstore export -t 2016-03-10T13:18:34 -e 2016-03-10T13:18:38 //:class.link/phys//:res.name/net0//:stat.*bytes//:op.rate//:op.avg TIME VALUE IDENTIFIER 2016-03-10T13:18:35 8778.502409667442 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.avg 2016-03-10T13:18:36 5069.138695990545 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.avg 2016-03-10T13:18:37 29.970778490971306 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.avg 2016-03-10T13:18:38 5457.80417042975 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.avg
这将单独显示 out-bytes 在指定时间段的平均速率和 in-bytes 在同一时间段的平均速率。
$ sstore export -t 2016-03-10T13:18:34 -e 2016-03-10T13:18:38 //:class.link/phys//:res.name/net0//:stat.*bytes//:op.rate//:op.avg(agg=time) TIME VALUE IDENTIFIER 2016-03-10T13:18:38 3146.217753278132 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.avg(agg=time) 2016-03-10T13:18:38 6521.490274011223 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.avg(agg=time)
这将显示 out-bytes 和 in-bytes 在指定时间段的平均速率,并将结果保存在 out-bytes 统计信息中。
$ sstore export -t 2016-03-10T13:18:34 -e 2016-03-10T13:18:38 //:class.link/phys//:res.name/net0//:stat.*bytes//:op.rate//:op.avg(agg=all) TIME VALUE IDENTIFIER 2016-03-10T13:18:38 4833.854013644677 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.avg(agg=all)示例 4 通过 op.filter 导出统计信息 (0)
以下示例将通过 op.filter 导出统计信息(0)。
$ sstore export -t 2016-03-11T08:30:10 -e 2016-03-11T08:30:45 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.filter(0) TIME VALUE IDENTIFIER 2016-03-11T08:30:11 0.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.filter(0) 2016-03-11T08:30:29 0.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.filter(0) 2016-03-11T08:30:45 0.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.filter(0)示例 5 通过 op.delta 或 op.rate 导出 net0 资源的 in-bytes 统计信息
以下示例将通过 op.delta 或 op.rate 导出 net0 资源的 in-bytes 统计信息。
$ sstore export -t 2016-03-11T08:30:10 -e 2016-03-11T08:30:13 //:class.link/phys//:res.name/net0//:stat.in-bytes TIME VALUE IDENTIFIER 2016-03-11T08:30:10 217758030 //:class.link/phys//:res.name/net0//:stat.in-bytes 2016-03-11T08:30:11 217758030 //:class.link/phys//:res.name/net0//:stat.in-bytes 2016-03-11T08:30:12 217758090 //:class.link/phys//:res.name/net0//:stat.in-bytes 2016-03-11T08:30:13 217758604 //:class.link/phys//:res.name/net0//:stat.in-bytes
$ sstore export -t 2016-03-11T08:30:10 -e 2016-03-11T08:30:13 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.delta TIME VALUE IDENTIFIER 2016-03-11T08:30:11 0.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.delta 2016-03-11T08:30:12 60.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.delta 2016-03-11T08:30:13 514.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.delta $ sstore export -t 2016-03-11T08:30:10 -e 2016-03-11T08:30:13 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate TIME VALUE IDENTIFIER 2016-03-11T08:30:11 0.0 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate 2016-03-11T08:30:12 59.024095603295116 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate 2016-03-11T08:30:13 521.6129408720273 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate示例 6 通过 op.util 导出 net0 资源的 in-bytes 统计信息
以下示例将通过 op.util 导出 net0 资源的 in-bytes 统计信息。
$ sstore export -t 2016-03-09T16:32:32 -p 1 //:class.cpu//:stat.usage//:part.mode TIME VALUE IDENTIFIER 2016-03-09T16:32:56 //:class.cpu//:stat.usage//:part.mode stolen: 0.0 intr: 495808.247348 idle: 76499305.003489 user: 1872796.029831 kernel: 1417289.148075
$ sstore export -t 2016-03-09T16:32:32 -p 1 //:class.cpu//:stat.usage//:part.mode//:op.util\fR TIME VALUE IDENTIFIER 2016-03-09T16:32:56 //:class.cpu//:stat.usage//:part.mode//:op.util stolen: 0.0 intr: 0.6175587244615878 idle: 95.28444408266094 user: 2.332679082176271 kernel: 1.7653181107012057示例 7 使用运算符导出唯一数据点
以下示例使用 op.changed 导出 class.system 中的 pkg-version。
$ sstore export//:class.system//:stat.pkg-version//:op.changed TIME VALUE IDENTIFIER 2017-05-03T00:12:48 5.12,5.12-5.12.0.0.0.122.0 //:class.system//:stat.pkg-version//:op.changed 2017-06-11T22:01:29 5.12,5.12-5.12.0.0.0.125.0 //:class.system//:stat.pkg-version//:op.changed 2017-08-15T12:57:53 11.4,5.11-11.4.0.0.0.2.0 //:class.system//:stat.pkg-version//:op.changed 2017-08-23T18:10:44 NO_DATA //:class.system//:stat.pkg-version//:op.changed 2017-08-23T18:10:45 11.4,5.11-11.4.0.0.0.2.0 //:class.system//:stat.pkg-version//:op.changed 2017-10-20T16:37:06 NO_DATA //:class.system//:stat.pkg-version//:op.changed 2017-10-20T16:37:07 11.4,5.11-11.4.0.0.0.6.0 //:class.system//:stat.pkg-version//:op.changed 2017-10-20T16:51:49 NO_DATA //:class.system//:stat.pkg-version//:op.changed 2017-10-20T16:51:50 11.4,5.11-11.4.0.0.0.6.0 //:class.system//:stat.pkg-version//:op.changed
由于 NO_DATA 也是以前记录后发生变化的值,因此会报告这些点。在此特殊情况下,它们反映了统计信息只是间歇性地捕获的情况。
示例 8 对事件实例计数以下示例将使用 op.count 导出各种事件和统计信息 SSID 的计数:
$ sstore export "//:class.svc//:res.fmri/system/name-service/cache:default//:event.adm-action//:op.filter(event=AUE_)//:op.count" TIME VALUE IDENTIFIER 2016-05-11T16:34:20 20 //:class.svc//:res.fmri/system/name-service/cache:default//:event.adm-action//:op.filter(event=AUE_)//:op.count $ sstore export "//:class.event//:event.adm-action//:op.filter(return/errval=failure,event=AUE_login)//:op.count" TIME VALUE IDENTIFIER 2016-05-06T11:57:09 7 //:class.event//:event.adm-action//:op.filter(return/errval=failure,event=AUE_login)//:op.count $ sstore export //:class.system//:stat.//:s.[nodename,physical-memory,product,serial]//:op.count TIME VALUE IDENTIFIER 2016-08-26T11:09:25 69519 //:class.system//:stat.nodename//:op.count 2016-09-13T15:43:42 43532 //:class.system//:stat.physical-memory//:op.count 2016-08-26T11:09:25 69767 //:class.system//:stat.product//:op.count 2016-08-26T11:09:25 69324 //:class.system//:stat.serial//:op.count示例 9 对各个 SSID 应用 op.convert
以下示例将对各个 SSID 应用 op.convert。
net0 资源的 out-bytes 统计信息会转换为千字节。
$ sstore info //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.convert(kilobytes)
Identifier: //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.convert(kilobytes) $schema: //:stat copyright: Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. description: total bytes transmitted id: //:class.link/phys//:stat.out-bytes max-rate: //:stat.ifspeed stability: stable type: counter units: kilobytes
net0 资源的 out-bytes 统计信息会转换为千兆字节或分钟和二进制千兆字节或分钟。
$ sstore capture //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate TIME VALUE IDENTIFIER 2016-03-24T11:23:13 329.9340131973605 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate 2016-03-24T11:23:14 1013.7881182832789 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate
$ sstore capture //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.convert(gigabytes/minutes) TIME VALUE IDENTIFIER 2016-03-24T11:13:11 1.2838793153443577e-05 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.convert(gigabytes/minutes) 2016-03-24T11:13:12 3.9598653645776044e-05 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.convert(gigabytes/minutes)
$ sstore capture //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.convert(gibibytes/minutes) TIME VALUE IDENTIFIER 2016-03-24T11:13:22 1.8422611805723817e-05 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.convert(gibibytes/minutes) 2016-03-24T11:13:23 4.2599657979073085e-05 //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.rate//:op.convert(gibibytes/minutes)
对 units=bytes 的统计信息应用了错误的转换类型时:
$ sstore capture //:class.link/phys//:res.name/net0//:stat.out-bytes//:op.convert(seconds) TIME VALUE IDENTIFIER Warning (//:class.link/phys//:res.name/net0//:stat.out-bytes//:op.convert(seconds)) - Cannot perform op.convert as metadata unit 'bytes' can not be converted to desired unit 'seconds'示例 10 导出已设置格式的事件
启用了 svc:/network/smtp:sendmail 服务时,sstore 允许按如下所示格式化此事件数据。
$ store export //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.label TIME VALUE IDENTIFIER 2015-08-30T00:31:14 ('AUE_smf_enable',) //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.label
$ sstore export //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.description TIME VALUE IDENTIFIER 2015-08-30T00:31:14 ('header, 177, 2, persistently enable service instance, , sy stem1,2015-08-30 00:31:14.027-07:00, subject, usr1, root, root, root, root, 158 706, 4293668494, 58180 22 dhcp.vpn.example.com, use of authorization, solaris.sm f.modify, fmri, svc:/network/smtp:sendmail/:properties/general/enabled, return, success, 0\n',) //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action //:fmt.description
$ sstore export //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.summary TIME VALUE IDENTIFIER 2015-08-30T00:31:14 //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.summary 0: ts: 1440919874027218 label: AUE_smf_enable description: header, 177, 2, persistently enable service instance, , system1, 2015-08-30 00:31:14.027-07:00, subject, usr1, root, root, root, root, 158706, 4293668494, 58180 22 dhcp.vpn.example.com, use of authorizat ion, solaris.smf.modify, fmri, svc:/network/smtp:sendmail/:properties/general/en abled, return, success, 0
$ sstore export //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.raw TIME VALUE IDENTIFIER 2015-08-30T00:31:14 //:class.svc//:res.fmri/network/smtp:sendmail//:event.adm-action//:fmt.raw 0: version: 2 event: AUE_smf_enable host: system1 iso8601: 2015-08-30 00:31:14.027-07:00 subject/audit-uid: usr1 subject/uid: root subject/gid: root subject/ruid: root subject/rgid: root subject/pid: 158706 subject/sid: 4293668494 subject/tid: 58180 22 dhcp.vpn.example.com use_of_authorization/value: solaris.smf.modify fmri/value: svc:/network/smtp:sendmail/:properties/general/enable示例 11 组合运算
可按如下方式组合运算:
$ sstore capture //:class.cpu//:res.id/*//:stat.usage//:part.mode//:op.sum//:op.rate//:op.util TIME VALUE IDENTIFIER 2015-02-19T09:55:17 //:class.cpu//:res.id/0//:stat.usage//:part.mode//:op.sum//:op.rate//:op.util kernel: 0.300850394534 idle: 99.0696367035 stolen: 0.386165574037 user: 0.058161992642 intr: 0.185185335255 $ sstore export -t 2016-04-01T12:52:55 -e 2016-04-01T12:52:57 //:class.link/phys//:res.name/net0//:stat.in-bytes\ TIME VALUE IDENTIFIER 2016-04-01T12:52:55 72684860 //:class.link/phys//:res.name/net0//:stat.in-bytes 2016-04-01T12:52:56 72685388 //:class.link/phys//:res.name/net0//:stat.in-bytes 2016-04-01T12:52:57 72685556 //:class.link/phys//:res.name/net0//:stat.in-bytes $ sstore export -t 2016-04-01T12:52:55 -e 2016-04-01T12:52:57 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.convert(gigabytes/minutes) TIME VALUE IDENTIFIER 2016-04-01T12:52:56 3.167892291662084e-05 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.convert(gigabytes/minutes) 2016-04-01T12:52:57 1.0062812715881275e-05 //:class.link/phys//:res.name/net0//:stat.in-bytes//:op.rate//:op.convert(gigabytes/minutes)
sstore(1)、ssid(7)、ssid-metadata(7)、sstore(7)、sstored(8)