probe_service.mojom 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // API and definitions exposed by the Telemetry Services. This API is normally
  5. // consumed by the Telemetry Extension APIs implementation.
  6. // Note: this is a subset of the cros_healthd probe service interface which is
  7. // located in
  8. // //chromeos/ash/services/cros_healthd/public/mojom/cros_healthd.mojom.
  9. // This interface serves as PII filtering and data post-processing service
  10. // between the source (cros_healthd) and the clients
  11. // (third-party telemetry extensions).
  12. // The subset is not as is but has the following differences:
  13. // 1) Make all fields in the following structures optional in case we want to
  14. // filter them out later:
  15. // - ProbeNonRemovableBlockDeviceInfo
  16. // - ProbeCpuCStateInfo
  17. // - ProbeLogicalCpuInfo
  18. // - ProbePhysicalCpuInfo
  19. // - ProbeCpuInfo
  20. // - ProbeTimezoneInfo
  21. // - ProbeMemoryInfo
  22. // - ProbeBacklightInfo
  23. // - ProbeFanInfo
  24. // - ProbeStatefulPartitionInfo
  25. // - ProbeBluetoothAdapterInfo
  26. // 2) ProbeNonRemovableBlockDeviceInfo:
  27. // 2.1) use uint32 to store manufacturer_id instead of uint8 in case we
  28. // want to extend manufacturer range.
  29. // 2.2) use string to store serial in a decimal numeral system instead
  30. // of uint32 in case we want to extend serial number range.
  31. // 3) ProbeLogicalCpuInfo:
  32. // 3.1) rename idle_time_user_hz to idle_time_ms and use milliseconds
  33. // instead of USER_HZ units, because USER_HZ system constant is not
  34. // available in the web.
  35. // 3.2) use uint64 to store idle_time_ms instead of uint32, idle_time_ms
  36. // can easily be more than uint32 range.
  37. // 4) ProbeMemoryInfo: use uint64 to store page_faults_since_last_boot instead
  38. // of uint32, it can be more than uint32 range.
  39. module crosapi.mojom;
  40. import "chromeos/crosapi/mojom/nullable_primitives.mojom";
  41. // Interface for getting device telemetry information. Implemented in
  42. // ash-chrome.
  43. [Stable, Uuid="f3dbbe3b-a810-43a9-889e-b130b4f94869"]
  44. interface TelemetryProbeService {
  45. // Returns telemetry information for the desired categories.
  46. //
  47. // The request:
  48. // * |categories| - list of each of the categories that ProbeTelemetryInfo
  49. // should return information for.
  50. //
  51. // The response:
  52. // * |telemetry_info| - information for each of the requested categories. Only
  53. // the fields corresponding to the requested categories
  54. // will be non-null.
  55. ProbeTelemetryInfo@0(array<ProbeCategoryEnum> categories)
  56. => (ProbeTelemetryInfo telemetry_info);
  57. // Returns OEM data.
  58. //
  59. // The response:
  60. // * |oem_data| - OEM data.
  61. GetOemData@1() => (ProbeOemData oem_data);
  62. };
  63. // An enumeration of each category of information that cros_healthd can report.
  64. //
  65. // Next ID: 12
  66. [Stable, Extensible]
  67. enum ProbeCategoryEnum {
  68. [Default] kUnknown = 11,
  69. kBattery = 0,
  70. kNonRemovableBlockDevices = 1,
  71. kCachedVpdData = 2,
  72. kCpu = 3,
  73. kTimezone = 4,
  74. kMemory = 5,
  75. kBacklight = 6,
  76. kFan = 7,
  77. kStatefulPartition = 8,
  78. kBluetooth = 9,
  79. kSystem = 10,
  80. };
  81. // An enumeration of the different categories of errors that can occur when
  82. // probing telemetry information.
  83. //
  84. // Next ID: 5
  85. [Stable, Extensible]
  86. enum ProbeErrorType {
  87. // Default value.
  88. [Default] kUnknown = 4,
  89. // An error reading a system file.
  90. kFileReadError = 0,
  91. // An error parsing data into a consumable form.
  92. kParseError = 1,
  93. // An error using a system utility.
  94. kSystemUtilityError = 2,
  95. // The external service used to probe the information is not available.
  96. kServiceUnavailable = 3,
  97. };
  98. // Structure that contains error information for a telemetry probe.
  99. //
  100. // Next ID: 2
  101. [Stable]
  102. struct ProbeError {
  103. // The type of error that occurred.
  104. ProbeErrorType type@0;
  105. // A debug message with more information about the error. This string is not
  106. // intended to be shown to the user.
  107. string msg@1;
  108. };
  109. // Information related to the main battery.
  110. //
  111. // Next ID: 14
  112. [Stable]
  113. struct ProbeBatteryInfo {
  114. // Cycle count.
  115. Int64Value? cycle_count@0;
  116. // Current battery voltage (V)
  117. DoubleValue? voltage_now@1;
  118. // Manufacturer of the battery
  119. string? vendor@2;
  120. // Serial number of the battery
  121. string? serial_number@3;
  122. // Design capacity (Ah)
  123. DoubleValue? charge_full_design@4;
  124. // Full capacity (Ah)
  125. DoubleValue? charge_full@5;
  126. // Desired minimum output voltage (V)
  127. DoubleValue? voltage_min_design@6;
  128. // Model name.
  129. string? model_name@7;
  130. // Current battery charge (Ah)
  131. DoubleValue? charge_now@8;
  132. // Current battery current (A)
  133. DoubleValue? current_now@9;
  134. // Technology of the battery
  135. string? technology@10;
  136. // Status of the battery
  137. string? status@11;
  138. // The fields below are optionally included if the main battery is a Smart
  139. // Battery as defined in http://sbs-forum.org/specs/sbdat110.pdf.
  140. // Manufacture date converted to yyyy-mm-dd format.
  141. string? manufacture_date@12;
  142. // Temperature in 0.1K. Included when the main battery is a Smart Battery.
  143. UInt64Value? temperature@13;
  144. };
  145. // Battery probe result. Can either be populated with the BatteryInfo or an
  146. // error retrieving the information.
  147. [Stable]
  148. union ProbeBatteryResult {
  149. // Valid BatteryInfo. Null value if a battery is not present.
  150. ProbeBatteryInfo? battery_info;
  151. // The error that occurred attempting to retrieve the BatteryInfo.
  152. ProbeError error;
  153. };
  154. // Information related to a specific non-removable block device.
  155. //
  156. // Next ID: 12
  157. [Stable]
  158. struct ProbeNonRemovableBlockDeviceInfo {
  159. // The path of this storage on the system. It is useful if caller needs to
  160. // correlate with other information.
  161. string? path@0;
  162. // Exact size of this storage, reported in bytes.
  163. UInt64Value? size@1;
  164. // Storage type, could be MMC / NVMe / ATA, based on udev subsystem.
  165. string? type@2;
  166. // Manufacturer ID, 8 bits.
  167. UInt32Value? manufacturer_id@3;
  168. // PNM: Product name, ASCII characters for 6 bytes.
  169. string? name@4;
  170. // PSN: Product serial number, encoded unsigned integer in decimal numeral
  171. // system.
  172. string? serial@5;
  173. // Bytes read since last boot.
  174. UInt64Value? bytes_read_since_last_boot@6;
  175. // Bytes written since last boot.
  176. UInt64Value? bytes_written_since_last_boot@7;
  177. // Time spent reading since last boot.
  178. UInt64Value? read_time_seconds_since_last_boot@8;
  179. // Time spent writing since last boot.
  180. UInt64Value? write_time_seconds_since_last_boot@9;
  181. // Time spent doing I/O since last boot. Counts the time the disk and queue
  182. // were busy, so unlike the fields above, parallel requests are not counted
  183. // multiple times.
  184. UInt64Value? io_time_seconds_since_last_boot@10;
  185. // Time spent discarding since last boot. Discarding is writing to clear
  186. // blocks which are no longer in use. Supported on kernels 4.18+.
  187. UInt64Value? discard_time_seconds_since_last_boot@11;
  188. };
  189. // Non-removable block device probe result. Can either be populated with the
  190. // NonRemovableBlockDeviceInfo or an error retrieving the information.
  191. [Stable]
  192. union ProbeNonRemovableBlockDeviceResult {
  193. // Valid NonRemovableBlockDeviceInfo.
  194. array<ProbeNonRemovableBlockDeviceInfo> block_device_info;
  195. // The error that occurred attempting to retrieve the
  196. // NonRemovableBlockDeviceInfo.
  197. ProbeError error;
  198. };
  199. // Cached VPD read from sysfs.
  200. //
  201. // Next ID: 4
  202. [Stable]
  203. struct ProbeCachedVpdInfo {
  204. // Contents of /sys/firmware/vpd/rw/ActivateDate, if the device supports it.
  205. string? first_power_date@0;
  206. // Contents of /sys/firmware/vpd/ro/sku_number, if the device supports it.
  207. string? sku_number@1;
  208. // Contents of /sys/firmware/vpd/ro/serial_number, if the device supports it.
  209. string? serial_number@2;
  210. // Contents of /sys/firmware/vpd/ro/model_name, if the device supports it.
  211. string? model_name@3;
  212. };
  213. // Cached VPD probe result. Can either be populated with the CachedVpdInfo or an
  214. // error retrieving the information.
  215. [Stable]
  216. union ProbeCachedVpdResult {
  217. // Valid CachedVpdInfo.
  218. ProbeCachedVpdInfo vpd_info;
  219. // The error that occurred attempting to retrieve the CachedVpdInfo.
  220. ProbeError error;
  221. };
  222. // Information about a CPU's C-states.
  223. //
  224. // Next ID: 2
  225. [Stable]
  226. struct ProbeCpuCStateInfo {
  227. // Name of the state.
  228. string? name@0;
  229. // Time spent in the state since the last reboot, in microseconds.
  230. UInt64Value? time_in_state_since_last_boot_us@1;
  231. };
  232. // Information related to a particular logical CPU.
  233. //
  234. // Next ID: 5
  235. [Stable]
  236. struct ProbeLogicalCpuInfo {
  237. // The max CPU clock speed in kHz.
  238. UInt32Value? max_clock_speed_khz@0;
  239. // Maximum frequency the CPU is allowed to run at, by policy.
  240. UInt32Value? scaling_max_frequency_khz@1;
  241. // Current frequency the CPU is running at.
  242. UInt32Value? scaling_current_frequency_khz@2;
  243. // Idle time since last boot, in milliseconds.
  244. UInt64Value? idle_time_ms@3;
  245. // Information about the logical CPU's time in various C-states.
  246. array<ProbeCpuCStateInfo> c_states@4;
  247. };
  248. // Information related to a particular physical CPU.
  249. //
  250. // Next ID: 2
  251. [Stable]
  252. struct ProbePhysicalCpuInfo {
  253. // The CPU model name.
  254. string? model_name@0;
  255. // Logical CPUs corresponding to this physical CPU.
  256. array<ProbeLogicalCpuInfo> logical_cpus@1;
  257. };
  258. // An enumeration of CPU architectures.
  259. //
  260. // Next ID: 4
  261. [Stable, Extensible]
  262. enum ProbeCpuArchitectureEnum {
  263. [Default] kUnknown = 3,
  264. kX86_64 = 0,
  265. kAArch64 = 1,
  266. kArmv7l = 2,
  267. };
  268. // Information about the device's CPUs.
  269. //
  270. // Next ID: 3
  271. [Stable]
  272. struct ProbeCpuInfo {
  273. // Number of total threads available.
  274. UInt32Value? num_total_threads@0;
  275. // The CPU architecture - it's assumed all of a device's CPUs share an
  276. // architecture.
  277. ProbeCpuArchitectureEnum architecture@1;
  278. // Information about the device's physical CPUs.
  279. array<ProbePhysicalCpuInfo> physical_cpus@2;
  280. };
  281. // CPU probe result. Can either be populated with the CpuInfo or an error
  282. // retrieving the information.
  283. [Stable]
  284. union ProbeCpuResult {
  285. // Valid CpuInfo.
  286. ProbeCpuInfo cpu_info;
  287. // The error that occurred attempting to retrieve the CpuInfo.
  288. ProbeError error;
  289. };
  290. // Timezone information.
  291. //
  292. // Next ID: 2
  293. [Stable]
  294. struct ProbeTimezoneInfo {
  295. // The timezone of the device in POSIX standard.
  296. string? posix@0;
  297. // The timezone region of the device.
  298. string? region@1;
  299. };
  300. // Timezone probe result. Can either be populated with the TimezoneInfo or an
  301. // error retrieving the information.
  302. [Stable]
  303. union ProbeTimezoneResult {
  304. // Valid TimezoneInfo.
  305. ProbeTimezoneInfo timezone_info;
  306. // The error that occurred attempting to retrieve the TimezoneInfo.
  307. ProbeError error;
  308. };
  309. // Memory information.
  310. //
  311. // Next ID: 4
  312. [Stable]
  313. struct ProbeMemoryInfo {
  314. // Total memory, in KiB.
  315. UInt32Value? total_memory_kib@0;
  316. // Free memory, in KiB.
  317. UInt32Value? free_memory_kib@1;
  318. // Available memory, in KiB.
  319. UInt32Value? available_memory_kib@2;
  320. // Number of page faults since the last boot.
  321. UInt64Value? page_faults_since_last_boot@3;
  322. };
  323. // Memory probe result. Can either be populated with the MemoryInfo or an
  324. // error retrieving the information.
  325. [Stable]
  326. union ProbeMemoryResult {
  327. // Valid MemoryInfo.
  328. ProbeMemoryInfo memory_info;
  329. // The error that occurred attempting to retrieve the MemoryInfo.
  330. ProbeError error;
  331. };
  332. // Backlight information.
  333. //
  334. // Next ID: 3
  335. [Stable]
  336. struct ProbeBacklightInfo {
  337. // Path to this backlight on the system. Useful if the caller needs to
  338. // correlate with other information.
  339. string? path@0;
  340. // Maximum brightness for the backlight.
  341. UInt32Value? max_brightness@1;
  342. // Current brightness of the backlight, between 0 and max_brightness.
  343. UInt32Value? brightness@2;
  344. };
  345. // Backlight probe result. Can either be populated with the BacklightInfo or an
  346. // error retrieving the information.
  347. [Stable]
  348. union ProbeBacklightResult {
  349. // Valid BacklightInfo.
  350. array<ProbeBacklightInfo> backlight_info;
  351. // The error that occurred attempting to retrieve the BacklightInfo.
  352. ProbeError error;
  353. };
  354. // Fan information.
  355. [Stable]
  356. struct ProbeFanInfo {
  357. // Fan speed in RPM.
  358. UInt32Value? speed_rpm@0;
  359. };
  360. // Fan probe result. Can either be populated with the FanInfo or an error
  361. // retrieving the information.
  362. [Stable]
  363. union ProbeFanResult {
  364. // A list of valid FanInfo.
  365. array<ProbeFanInfo> fan_info;
  366. // The error that occurred attempting to retrieve the FanInfo.
  367. ProbeError error;
  368. };
  369. // Stateful partition info
  370. //
  371. // Next ID: 2
  372. [Stable]
  373. struct ProbeStatefulPartitionInfo {
  374. // Available space for user data storage in the device in bytes. Rounded down
  375. // to multiples of 100MiB (100 * 1024 * 1024 bytes).
  376. UInt64Value? available_space@0;
  377. // Total space for user data storage in the device in bytes.
  378. UInt64Value? total_space@1;
  379. };
  380. // Stateful partition probe result. Can either be populated with a valid
  381. // StatefulPartitionInfo or an error retrieving the information.
  382. [Stable]
  383. union ProbeStatefulPartitionResult {
  384. // A valid StatefulPartitionInfo.
  385. ProbeStatefulPartitionInfo partition_info;
  386. // The error that occurred attempting to retrieve the StatefulPartitionInfo.
  387. ProbeError error;
  388. };
  389. // Information related to one of a device's Bluetooth adapters.
  390. //
  391. // Next ID: 4
  392. [Stable]
  393. struct ProbeBluetoothAdapterInfo {
  394. // The name of the adapter.
  395. string? name@0;
  396. // The MAC address of the adapter.
  397. string? address@1;
  398. // Indicates whether the adapter is on or off.
  399. BoolValue? powered@2;
  400. // The number of devices connected to this adapter.
  401. UInt32Value? num_connected_devices@3;
  402. };
  403. // Bluetooth probe result. Can either be populated with the BluetoothAdapterInfo
  404. // or an error retrieving the information.
  405. [Stable]
  406. union ProbeBluetoothResult {
  407. // Valid BluetoothAdapterInfo.
  408. array<ProbeBluetoothAdapterInfo> bluetooth_adapter_info;
  409. // The error that occurred attempting to retrieve the BluetoothAdapterInfo.
  410. ProbeError error;
  411. };
  412. // OS Version information.
  413. // This structure decomposes a full version string
  414. // (e.g. "87.13544.59.0") into its parts.
  415. [Stable]
  416. struct ProbeOsVersion {
  417. // The OS version release milestone (e.g. "87").
  418. string? release_milestone@0;
  419. // The OS version build number (e.g. "13544").
  420. string? build_number@1;
  421. // The OS version patch number (e.g. "59.0").
  422. string? patch_number@2;
  423. // The OS release channel (e.g. "stable-channel").
  424. string? release_channel@3;
  425. };
  426. // The OS information.
  427. [Stable]
  428. struct ProbeOsInfo {
  429. // Contents of CrosConfig in /branding/oem-name.
  430. string? oem_name@0;
  431. // OS Version information.
  432. [MinVersion=1] ProbeOsVersion? os_version@1;
  433. };
  434. // System Information.
  435. [Stable]
  436. struct ProbeSystemInfo {
  437. // The info related to the OS.
  438. ProbeOsInfo os_info@0;
  439. };
  440. // System probe result. Can either be populated with the SystemInfo or an
  441. // error retrieving the information.
  442. [Stable]
  443. union ProbeSystemResult {
  444. // Valid SystemInfo.
  445. ProbeSystemInfo system_info;
  446. // The error that occurred attempting to retrieve SystemInfo.
  447. ProbeError error;
  448. };
  449. // A collection of all the device's telemetry information that cros_healthd is
  450. // capable of reporting. Note that every field in TelemetryInfo is nullable, and
  451. // the response for a particular ProbeTelemetryInfo request will only contain
  452. // fields corresponding to the categories passed to the ProbeTelemetryInfo
  453. // request. All optional array members will be null if cros_healthd did not
  454. // attempt to fetch that information, and size zero if cros_healthd did attempt
  455. // to fetch that information, but was unable to.
  456. //
  457. // Next ID: 11
  458. [Stable]
  459. struct ProbeTelemetryInfo {
  460. // Information about the device's main battery. Only present when kBattery was
  461. // included in the categories input to ProbeTelemetryInfo.
  462. ProbeBatteryResult? battery_result@0;
  463. // Information about all of the device's non-removable block devices. Only
  464. // present when kNonRemovableBlockDevices was included in the categories input
  465. // to ProbeTelemetryInfo.
  466. ProbeNonRemovableBlockDeviceResult? block_device_result@1;
  467. // Only present when kCachedVpdData was included in the categories input to
  468. // ProbeTelemetryInfo.
  469. ProbeCachedVpdResult? vpd_result@2;
  470. // Information about each of the device's CPUs. Only present when kCpu was
  471. // included in the categories input to ProbeTelemetryInfo.
  472. ProbeCpuResult? cpu_result@3;
  473. // Information about the device's timezone. Only present when kTimezone was
  474. // included in the categories input to ProbeTelemetryInfo.
  475. ProbeTimezoneResult? timezone_result@4;
  476. // Information about the system's memory. Only present when kMemory was
  477. // included in the categories input to ProbeTelemetryInfo.
  478. ProbeMemoryResult? memory_result@5;
  479. // Information about all of the device's backlights. Only present when
  480. // kBacklight was included in the categories input to ProbeTelemetryInfo.
  481. ProbeBacklightResult? backlight_result@6;
  482. // Information about each of the device's fans. Only present when kFan was
  483. // included in the categories input to ProbeTelemetryInfo.
  484. ProbeFanResult? fan_result@7;
  485. // Information about the stateful partition. Only present when
  486. // kStatefulPartition was included in the categories input to
  487. // ProbeTelemetryInfo.
  488. ProbeStatefulPartitionResult? stateful_partition_result@8;
  489. // Information about the device's Bluetooth adapters and devices. Only present
  490. // when kBluetooth was included in the categories input to ProbeTelemetryInfo.
  491. ProbeBluetoothResult? bluetooth_result@9;
  492. // Information about the system. Only present when kSystem was included in
  493. // the categories input to ProbeTelemetryInfo.
  494. ProbeSystemResult? system_result@10;
  495. };
  496. // Result of running /usr/share/cros/oemdata.sh script.
  497. [Stable]
  498. struct ProbeOemData {
  499. string? oem_data@0;
  500. };