[comment]: # translation:outdated

[comment]: # ({fc5b81d2-fc5b81d2})
# trigger.get

[comment]: # ({/fc5b81d2-fc5b81d2})

[comment]: # ({f493658b-e77e3d1e})
### 説明

`integer/array trigger.get(object parameters)`

このメソッドは、指定したパラメーターに応じたトリガーを取得できます。

::: noteclassic
このメソッドは、すべてのタイプのユーザーが利用できます。メソッドを呼び出す権限は、ユーザーの役割の設定で取り消すことができます。詳細は[ユーザーの役割](/manual/web_interface/frontend_sections/users/user_roles)を参照してください。
:::

[comment]: # ({/f493658b-e77e3d1e})

[comment]: # ({d7325e11-44938a82})
### パラメータ

`(object)` 必要な出力を定義するパラメータです。

このメソッドは以下のパラメータをサポートしています。

|パラメータ|[型](/manual/api/reference_commentary#data-types)|説明|
|--|--|------|
|triggerids|ID/array|指定したIDのトリガーのみを返します。|
|groupids|ID/array|指定したホストグループまたはテンプレートグループに属するホストまたはテンプレートのトリガーのみを返します。|
|templateids|ID/array|指定したテンプレートに属するトリガーのみを返します。|
|hostids|ID/array|指定したホストに属するトリガーのみを返します。|
|itemids|ID/array|指定したアイテムを含むトリガーのみを返します。|
|functions|string/array|指定した関数を使用するトリガーのみを返します。<br><br>サポートされている関数の一覧については、[supported function](/manual/appendix/functions) ページを参照してください。|
|group|string|指定した名前のホストグループまたはテンプレートグループに属するホストまたはテンプレートのトリガーのみを返します。|
|host|string|指定した技術名のホストに属するトリガーのみを返します。|
|inherited|boolean|`true` に設定した場合、テンプレートから継承されたトリガーのみを返します。|
|templated|boolean|`true` に設定した場合、テンプレートに属するトリガーのみを返します。|
|dependent|boolean|`true` に設定した場合、依存関係を持つトリガーのみを返します。`false` に設定した場合、依存関係を持たないトリガーのみを返します。|
|monitored|flag|監視対象のホストに属し、有効なアイテムのみを含む有効なトリガーのみを返します。|
|active|flag|監視対象のホストに属する有効なトリガーのみを返します。|
|maintenance|boolean|`true` に設定した場合、メンテナンス中のホストに属する有効なトリガーのみを返します。|
|withUnacknowledgedEvents|flag|未確認イベントを持つトリガーのみを返します。|
|withAcknowledgedEvents|flag|すべてのイベントが確認済みであるトリガーのみを返します。|
|withLastEventUnacknowledged|flag|最後のイベントが未確認であるトリガーのみを返します。|
|skipDependent|flag|他のトリガーに依存している障害状態のトリガーをスキップします。なお、他のトリガーが無効である場合、無効なアイテムを持つ場合、または無効なアイテムのホストに属する場合、それらのトリガーは無視されます。|
|lastChangeSince|timestamp|指定した時刻以降に状態が変化したトリガーのみを返します。|
|lastChangeTill|timestamp|指定した時刻以前に状態が変化したトリガーのみを返します。|
|only\_true|flag|最近障害状態になったトリガーのみを返します。|
|min\_severity|integer|指定した深刻度以上のトリガーのみを返します。|
|evaltype|integer|タグの[評価方法](/manual/web_interface/frontend_sections/data_collection/hosts/triggers#using-filter)。<br><br>指定可能な値:<br>0 - *(デフォルト)* And/Or;<br>2 - Or。|
|tags|array|指定したタグを持つトリガーのみを返します。<br>形式: `[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]`。<br>空の配列を指定すると、すべてのトリガーを返します。<br><br>指定可能な[operator](/manual/web_interface/frontend_sections/data_collection/hosts/triggers#using-filter)の値:<br>0 - *(デフォルト)* Contains;<br>1 - Equals;<br>2 - Does not contain;<br>3 - Does not equal;<br>4 - Exists;<br>5 - Does not exist。|
|expandComment|flag|トリガーの説明内のマクロを展開します。|
|expandDescription|flag|トリガー名内のマクロを展開します。|
|expandExpression|flag|トリガー条件式内の関数とマクロを展開します。|
|selectHostGroups|query|トリガーが属するホストグループを [`hostgroups`](/manual/api/reference/hostgroup/object) プロパティで返します。|
|selectHosts|query|トリガーが属するホストを [`hosts`](/manual/api/reference/host/object) プロパティで返します。|
|selectItems|query|トリガーに含まれるアイテムを [`items`](/manual/api/reference/item/object) プロパティで返します。|
|selectFunctions|query|トリガーで使用されている関数を `functions` プロパティで返します。<br><br>関数オブジェクトはトリガー条件式で使用される関数を表し、以下のプロパティを持ちます。<br>`functionid` - `(ID)` 関数のID;<br>`itemid` - `(ID)` 関数で使用されるアイテムのID;<br>`function` - `(string)` 関数名;<br>`parameter` - `(string)` 関数に渡されるパラメータ。クエリパラメータは、返される文字列では `$` 記号に置き換えられます。|
|selectDependencies|query|トリガーが依存しているトリガーを `dependencies` プロパティで返します。|
|selectDiscoveryRule|query|トリガーを作成した[ローレベルディスカバリルール](/manual/api/reference/discoveryrule/object#discovery-rule)を `discoveryRule` プロパティで返します。|
|selectLastEvent|query|最後の重要なトリガーイベントを [`lastEvent`](/manual/api/reference/event/object) プロパティで返します。|
|selectTags|query|トリガーのタグを [`tags`](/manual/api/reference/trigger/object#trigger-tag) プロパティで返します。|
|selectTemplateGroups|query|トリガーが属するテンプレートグループを [`templategroups`](/manual/api/reference/templategroup/object) プロパティで返します。|
|selectTriggerDiscovery|query|トリガーディスカバリオブジェクトを `triggerDiscovery` プロパティで返します。トリガーディスカバリオブジェクトは、トリガーを作成元のトリガープロトタイプに関連付けます。<br><br>このオブジェクトは以下のプロパティを持ちます。<br>`parent_triggerid` - `(ID)` トリガーの作成元となったトリガープロトタイプのID;<br>`status` - `(int)` トリガーディスカバリのステータス:<br>0 - *(デフォルト)* トリガーは検出されています。<br>1 - トリガーはすでに検出されていません。<br>`ts_delete` - `(timestamp)` すでに検出されなくなったトリガーが削除される時刻;<br>`ts_disable` - `(timestamp)` すでに検出されなくなったトリガーが無効化される時刻;<br>`disable_source` - `(int)` トリガーがLLDルールによって無効化されたか、手動で無効化されたかを示す指標:<br>0 - *(デフォルト)* 自動的に無効化,<br>1 - LLDルールによって無効化。|
|filter|object|指定したフィルターに完全一致する結果のみを返します。<br><br>キーがプロパティ名、値が一致対象となる単一の値または値の配列であるオブジェクトを受け付けます。<br><br>`text` [data type](/manual/api/reference_commentary#data-types) のプロパティはサポートしていません。<br><br>追加のプロパティをサポートしています:<br>`host` - トリガーが属するホストの技術名;<br>`hostid` - トリガーが属するホストのID。|
|limitSelects|integer|サブセレクトで返されるレコード数を制限します。<br><br>以下のサブセレクトに適用されます:<br>`selectHosts` - 結果は `host` でソートされます。|
|sortfield|string/array|指定したプロパティで結果を[ソート](/manual/api/reference_commentary#common-get-method-parameters)します。<br><br>指定可能な値: `triggerid`, `description`, `status`, `priority`, `lastchange`, `hostname`。|
|countOutput|boolean|これらのパラメータは [reference commentary](/manual/api/reference_commentary#common-get-method-parameters) で説明されています。|
|editable|boolean|^|
|excludeSearch|boolean|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|
|selectGroups<br>(deprecated)|query|このパラメータは非推奨です。代わりに `selectHostGroups` または `selectTemplateGroups` を使用してください。<br>トリガーが属するホストグループおよびテンプレートグループを `groups` プロパティで返します。|

[comment]: # ({/d7325e11-44938a82})

[comment]: # ({07ca11ca-7223bab1})
### 戻り値

`(integer/array)` 次のいずれかを返します:

-   オブジェクトの配列
-   `countOutput`パラメーターが使用されている場合、取得したオブジェクトの数

[comment]: # ({/07ca11ca-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### 例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({d9d4c665-3d27e76d})
#### トリガーIDによるデータの取得

トリガー「14062」のすべてのデータと、そのトリガーで使用されている関数を取得します。

[リクエスト](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "params": {
        "triggerids": "14062",
        "output": "extend",
        "selectFunctions": "extend"
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "triggerid": "14062",
            "expression": "{13513}<10m",
            "description": "{HOST.NAME} has been restarted (uptime < 10m)",
            "url": "",
            "status": "0",
            "value": "0",
            "priority": "2",
            "lastchange": "0",
            "comments": "The host uptime is less than 10 minutes",
            "error": "",
            "templateid": "10016",
            "type": "0",
            "state": "0",
            "flags": "0",
            "recovery_mode": "0",
            "recovery_expression": "",
            "correlation_mode": "0",
            "correlation_tag": "",
            "manual_close": "0",
            "opdata": "",
            "event_name": "",
            "uuid": "",
            "url_name": "",
            "functions": [
                {
                    "functionid": "13513",
                    "itemid": "24350",
                    "parameter": "$",
                    "function": "last"
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/d9d4c665-3d27e76d})

[comment]: # ({a6701c25-8a31301f})
#### 障害状態のトリガーの取得

障害状態にあるすべてのトリガーの ID、名前、深刻度を取得し、深刻度の降順で並べ替えます。

[リクエスト](/manual/api#performing-requests) :

```json
{
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "params": {
        "output": [
            "triggerid",
            "description",
            "priority"
        ],
        "filter": {
            "value": 1
        },
        "sortfield": "priority",
        "sortorder": "DESC"
    },
    "id": 1
}
```

レスポンス :

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "triggerid": "13907",
            "description": "Zabbix self-monitoring processes < 100% busy",
            "priority": "4"
        },
        {
            "triggerid": "13824",
            "description": "Zabbix discoverer processes more than 75% busy",
            "priority": "3"
        }
    ],
    "id": 1
}
```

[comment]: # ({/a6701c25-8a31301f})

[comment]: # ({d9fc89e0-8005126d})
#### タグ付きの特定のトリガーの取得

タグ付きの特定のトリガーを取得します。

[リクエスト](/manual/api#performing-requests) :

```json
{
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "params": {
        "output": [
            "triggerid",
            "description"
        ],
        "selectTags": "extend",
        "triggerids": [
            "17578"
        ]
    },
    "id": 1
}
```

レスポンス :

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "triggerid": "17370",
            "description": "Service status",
            "tags": [
                {
                    "tag": "service",
                    "value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
                },
                {
                    "tag": "error",
                    "value": ""
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/d9fc89e0-8005126d})

[comment]: # ({cf0cf439-222d46a0})
### 関連項目

-   [ディスカバリルール](/manual/api/reference/discoveryrule/object#discovery-rule)
-   [アイテム](/manual/api/reference/item/object#item)
-   [ホスト](/manual/api/reference/host/object#host)
-   [ホストグループ](/manual/api/reference/hostgroup/object#host-group)
-   [テンプレートグループ](/manual/api/reference/templategroup/object#template-group)

[comment]: # ({/cf0cf439-222d46a0})

[comment]: # ({07515392-07515392})
### ソース

CTrigger::get() in *ui/include/classes/api/services/CTrigger.php*.

[comment]: # ({/07515392-07515392})
