• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# hisysevent
2
3hisysevent is a built-in tool that helps you subscribe to real-time system events and query historical system events.
4
5## Environment requirements
6
7- The environment for OpenHarmony Device Connector (hdc) has been set up. For details, see [Environment Setup](hdc.md#environment-setup).
8
9- The devices are properly connected and **hdc shell** is executed.
10
11- The **hisysevent** command is executed on the device to call related capabilities.
12
13## Subscribing to Real-Time System Events
14
15- Run the **hisysevent -r** command to subscribe to system events.
16
17   ![](figures/hisysevent-r.png)
18
19- To specify the type of system event to subscribe to, use the **-g** option.
20
21  > **NOTE**<br>
22  > With the **-g** option, four event types are available: **FAULT**, **STATISTIC**, **SECURITY**, and **BEHAVIOR**.
23  >
24  > If no event type is specified, hisysevent subscribes to all types of system events.
25
26  Example: Subscribe to system events of the **FAULT** type.
27
28  ![](figures/hisysevent-r-g.png)
29
30- To subscribe to system events by event domain and event name, use the **-o**, **-n**, and **-c** options. **-o** specifies the event domain, **-n** specifies the event name, and **-c** specifies the rule for matching the specified event domain and name.
31
32  > **NOTE**<br>
33  > With the **-c** option, the following matching rules are available: **WHOLE_WORD**, **PREFIX**, and **REGULAR**.
34  >
35  > If no matching rule is specified, the **WHOLE_WORD** matching rule is used by default.
36
37  Example 1: Subscribe to the system event that matches the domain of **AAFWK** and event name of **CONNECT_SERVICE**.
38
39  ![](figures/hisysevent-r-o-wholeword.png)
40
41  Example 2: Subscribe to system events that match the domain prefix of **AAF** and event name prefix of **CONNECT**.
42
43  ![](figures/hisysevent-r-o-prefix.png)
44
45  Example 3: Subscribe to system events whose domain matches the **AA\*** regular expression and whose event name matches the **CONNE\*** regular expression.
46
47  ![](figures/hisysevent-r-o-regular.png)
48
49- To subscribe to system events by event tag, use the **-t** and **-c** options. **-t** specifies the event tag, and **-c** specifies the rule for matching the event tag.
50
51  Example 1: Subscribe to system events whose tag is **ability**.
52
53  ![](figures/hisysevent-r-t-wholeword.png)
54
55  Example 2: Subscribe to system events whose tag prefix is **abili**.
56
57  ![](figures/hisysevent-r-t-prefix.png)
58
59  Example 3: Subscribe to system events whose tag matches the **abi\*** regular expression.
60
61  ![](figures/hisysevent-r-t-regular.png)
62
63## Querying Historical System Events
64
65- Run the **hisysevent -l** command to query system events that are stored.
66
67  ![](figures/hisysevent-l.png)
68
69- To specify the type of system event to query, use the **-g** option.
70
71  > **NOTE**<br>
72  > With the **-g** option, four event types are available: **FAULT**, **STATISTIC**, **SECURITY**, and **BEHAVIOR**.
73  >
74  > If no event type is specified, hisysevent queries all types of system events.
75
76  Example: Query system events of the **SECURITY** type.
77
78  ![](figures/hisysevent-l-g.png)
79
80- To query historical system events within the specified period of time, use the **-s** and **-e** options to specify raw timestamps. **-s** specifies the start timestamp, and **-e** the end timestamp.
81
82  > **NOTE**<br>
83  > The raw timestamps are of millisecond precision.
84
85  Example: Query all system events reported between 1708604541551 and 1708604558551.
86
87  ![](figures/hisysevent-l-s-e.png)
88
89- You can use the **-S** and **-E** options to specify formatted start and end timestamps, respectively.
90
91  > **NOTE**<br>
92  > The timestamp format is YYYY-MM-DD hh:mm:ss.
93
94  Example: Query all system events reported between 2024-02-22 20:22:21 and 2024-02-22 20:22:38.
95
96  ![](figures/hisysevent-l-S-E-format.png)
97
98- To query system events by event domain and event name, use the **-o**, **-n**, and **-c** options. **-o** specifies the event domain, **-n** specifies the event name, and **-c** specifies the rule for matching the specified event domain and name.
99
100  > **NOTE**<br>
101  > The **-c** option for querying historical system events must be **WHOLE_WORD**.
102  >
103  > If no matching rule is specified, the **WHOLE_WORD** matching rule is used by default.
104
105  Example: Query the system event that matches the domain of **AAFWK** and event name of **CONNECT_SERVICE**.
106
107  ![](figures/hisysevent-l-o-n-c.png)
108
109- You can use the **-m** option to set the maximum number of historical events that can be queried.
110
111  > **NOTE**<br>
112  > If **-m** is not specified, a maximum of 10,000 system events are queried by default.
113
114  ![](figures/hisysevent-l-m.png)
115
116  ![](figures/hisysevent-l-wc-l.png)
117
118## Checking System Event Validity
119
120To enable system event validity check, use the **-v** option.
121
122If system event validity check is enabled, invalid content contained in system events will be highlighted in red.
123
124> **NOTE**<br>
125>
126> Invalid content is defined as follows:
127>
128> 1. Custom parameter key that is not configured.
129> 2. Type mismatch.
130
131Example: For the system event named **INTERACTION_APP_JANK** of the **ACE** domain, the <!--RP1-->[system event configuration](../../device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md)<!--RP1End--> does not contain the custom parameters **DURITION** and **DISPLAY_ANIMATOR**. If these parameters are contained in the event saved, they will be highlighted in red when system event validity check is enabled.
132
133![](figures/hisysevent-v.png)
134