subsys-dfx-hisysevent-tool.md 7.6 KB
Newer Older
D
duangavin123 已提交
1 2
# HiSysEvent Tool Usage<a name="EN-US_TOPIC_0000001231614021"></a>

S
shawn_he 已提交
3 4 5 6
-   [Overview](#section1886702718521)
-   [Subscribing to Real-Time System Events](#section1210623418527)
-   [Querying Historical System Events](#section1210623418539)

D
duangavin123 已提交
7 8
## Overview<a name="section1886702718521"></a>

S
shawn_he 已提交
9 10 11 12 13 14 15 16 17
The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** directory of the system. You can use this tool to subscribe to real-time system events or query historical system vents.

## Subscribing to Real-Time System Events<a name="section1210623418527"></a>

-   Command for subscribing to real-time system events:

    ```
    hisysevent -r
    ```
D
duangavin123 已提交
18

S
shawn_he 已提交
19
    Description of command options:
D
duangavin123 已提交
20

S
shawn_he 已提交
21 22 23
    | Option| Description|
    | -------- | --------- |
    | -r&nbsp;        | Subscribes to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.|
D
duangavin123 已提交
24

S
shawn_he 已提交
25
-   Command for enabling the debugging mode:
D
duangavin123 已提交
26 27

    ```
S
shawn_he 已提交
28
    hisysevent -r -d
D
duangavin123 已提交
29 30
    ```

S
shawn_he 已提交
31 32 33 34 35 36 37
    Description of command options:

    | Option| Description|
    | -------- | --------- |
    | -d       | Subscribes to real-time system events in debugging mode.|

-   Command for subscribing to real-time system events by event tag:
D
duangavin123 已提交
38 39

    ```
40
    hisysevent -r -t <tag> [-c [WHOLE_WORD|PREFIX|REGULAR]]
S
shawn_he 已提交
41 42 43 44 45 46 47 48 49
    ```

    Description of command options:

    | Option| Description|
    | -------- | --------- |
    | -t&nbsp;        | Event tag used to filter subscribed real-time system events.|
    | -c&nbsp;        | Matching rule for event tags. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.|

50 51 52 53 54 55 56 57 58 59 60 61 62
    Example commands:

    ```
    # hisysevent -r -t "TAG" -c PREFIX
    {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
    # hisysevent -r -t "TA\w{0,1}" -c REGULAR
    {"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""}
    {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
    # hisysevent -r -t "TA\w+" -c REGULAR
    {"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""}
    {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
    ```

S
shawn_he 已提交
63 64 65 66 67 68
-   Command for subscribing to real-time system events by event domain and event name:

    ```
    hisysevent -r -o <domain> -n <eventName> [-c [WHOLE_WORD|PREFIX|REGULAR]]
    ```

69 70
    Description of command options:

S
shawn_he 已提交
71 72 73 74 75 76
    | Option| Description|
    | -------- | --------- |
    | -o       | Event domain used to filter subscribed real-time system events.|
    | -n       | Event name used to filter subscribed real-time system events.|
    | -c       | Matching rule for event domains and event names. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.|

77 78 79 80 81 82 83 84 85 86 87 88 89 90
    Example commands:

    ```
    # hisysevent -r -o "DOMAINA" -n "EVENTNAMEA"
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    # hisysevent -r -o "DOMA\w{0,10}" -n "EVENT\w+" -c REULAR
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""}
    # hisysevent -r -o "DOMA\w{0,10}" -c REGULAR
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINABC","name_":"EVENTNAMEB","type_":1,"time_":1501940279938,"tz_":"+0000","pid_":1428,"tid_":1344,"uid_":10002,"level_":"CRITICAL","info_":""}
    ```

S
shawn_he 已提交
91 92 93 94 95 96 97 98 99
    >![](../public_sys-resources/icon-note.gif) **NOTE:**
    >If **-t**, **-o**, and **-n** are specified, the system checks whether the configured event tag is null. If the event tag is not null, the system filters system events based on the matching rules for the event tag. Otherwise, the system filters system events based on the matching rules for the event domain and event name.

## Querying Historical System Events<a name="section1210623418539"></a>

-   Command for querying historical system events:

    ```
    hisysevent -l
D
duangavin123 已提交
100 101
    ```

S
shawn_he 已提交
102
    Description of command options:
D
duangavin123 已提交
103

S
shawn_he 已提交
104 105 106 107 108
    | Option| Description|
    | -------- | --------- |
    | -l       | Queries historical system events based on the default settings. A maximum of 1,000 latest system events will be returned.|

-   Command for querying historical system events within the specified period of time:
D
duangavin123 已提交
109 110

    ```
S
shawn_he 已提交
111
    hisysevent -l -s <begin time> -e <end time>
D
duangavin123 已提交
112 113
    ```

S
shawn_he 已提交
114 115 116 117 118 119
    Description of command options:

    | Option| Description|
    | -------- | --------- |
    | -s       | Start time for querying historical system events. Only system events generated after the start time are returned.|
    | -e       | End time for querying historical system events. Only system events generated before the end time are returned.|
D
duangavin123 已提交
120

121 122 123 124 125 126 127 128 129 130
    Example commands:

    ```
    # hisysevent -l -s 20207388633 -e 20207389000
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    ```

S
shawn_he 已提交
131 132 133 134 135
-   Command for setting the maximum number of historical events that can be queried:

    ```
    hisysevent -l -m <max hisysevent count>
    ```
D
duangavin123 已提交
136

S
shawn_he 已提交
137
    Description of command options:
D
duangavin123 已提交
138

S
shawn_he 已提交
139 140 141
    | Option| Description|
    | -------- | --------- |
    | -m       | Maximum number of historical system events that can be queried. The value ranges from **0** to **1000**. The number of returned system events is not more than the value of this parameter.|
142 143 144 145 146 147 148 149 150 151 152 153 154

    Example commands:

    ```
    # hisysevent -l -s 20207388633 -e 20207389000 -m 3
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    # hisysevent -l -m 2
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""}
    ```