This is a translation of the original English documentation page. Help us make it better.

Sidebar

Zabbix Summit 2022
Register for Zabbix Summit 2022

alert.get

説明

integer/array alert.get(object parameters)

このメソッドは、指定されたパラメータに従ってアラートを取得することができます。

このメソッドは、どのタイプのユーザーでも利用可能です。このメソッドを呼び出す許可は、ユーザーロール設定で取り消す
ことができます。詳しくは User roles をご覧ください。

パラメータ

(object) 希望する出力を定義するパラメータ。

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

パラメータ Type 説明
alertids string/array Return only alerts with the given IDs.
actionids string/array Return only alerts generated by the given actions.
eventids string/array Return only alerts generated by the given events.
groupids string/array Return only alerts generated by objects from the given host groups.
hostids string/array Return only alerts generated by objects from the given hosts.
mediatypeids string/array Return only message alerts that used the given media types.
objectids string/array Return only alerts generated by the given objects
userids string/array Return only message alerts that were sent to the given users.
eventobject integer Return only alerts generated by events related to objects of the given type.

See event "object" for a list of supported object types.

Default: 0 - trigger.
eventsource integer Return only alerts generated by events of the given type.

See event "source" for a list of supported event types.

Default: 0 - trigger events.
time_from timestamp Return only alerts that have been generated after the given time.
time_till timestamp Return only alerts that have been generated before the given time.
selectHosts query Return a hosts property with data of hosts that triggered the action operation.
selectMediatypes query Return a mediatypes property with an array of the media types that were used for the message alert.
selectUsers query Return a users property with an array of the users that the message was addressed to.
sortfield string/array Sort the result by the given properties.

Possible values are: alertid, clock, eventid, mediatypeid, sendto and status.
countOutput boolean These parameters being common for all get methods are described in the reference commentary.
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

戻り値

(integer/array) のどちらかを返します:

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

アクションIDでアラートを取得する

アクション "3" によって生成されたすべてのアラートを取得します。

Request:

{
           "jsonrpc": "2.0",
           "method": "alert.get",
           "params": {
               "output": "extend",
               "actionids": "3"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "alertid": "1",
                   "actionid": "3",
                   "eventid": "21243",
                   "userid": "1",
                   "clock": "1362128008",
                   "mediatypeid": "1",
                   "sendto": "[email protected]",
                   "subject": "PROBLEM: Zabbix agent on Linux server is unreachable for 5 minutes: ",
                   "message": "Trigger: Zabbix agent on Linux server is unreachable for 5 minutes: \nTrigger status: PROBLEM\nTrigger severity: Not classified",
                   "status": "0",
                   "retries": "3",
                   "error": "",
                   "esc_step": "1",
                   "alerttype": "0",
                   "p_eventid": "0",
                   "acknowledgeid": "0"
               }
           ],
           "id": 1
       }

参照

ソース

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