object action.create(object/array actions)
このメソッドでは、新しいアクションを作成することができます。
このメソッドは、Admin および Super admin ユーザータイプにのみ使用できます。このメソッドを呼び出す許可は、ユーザーのロール設定で取り消すことができます。詳しくは、ユーザーロールを参照してください。
(object/array)
Actions to create.
standard action properties に加えて、このメソッドは以下のパラメータを受け付けます。
パラメータ | Type | 説明 |
---|---|---|
filter | object | Action filter object for the action. |
operations | array | Action operations to create for the action. |
recovery_operations | array | Action recovery operations to create for the action. |
update_operations | array | Action update operations to create for the action. |
(object)
は actionids
プロパティの下に作成されたアクションの ID を含むオブジェクトを返します。
返される ID の順序は、渡されたアクションの順序と一致します。
ホスト "10084" からのトリガーで、その名前に "memory" が含まれているものが問題状態になったときに実行される
アクションを作成しなさい。このアクションは、まず、ユーザーグループ "7" のすべてのユーザーにメッセージを送信
しなければなりません。もし、このイベントが4分以内に解決されない場合、グループ "2" のすべてのホストでスクリプト
"3" を実行する。トリガー回復時には、その問題に関して以前にメッセージを受け取ったすべてのユーザーに通知されます。
トリガーが更新されると、メッセージの件名と本文を含むメッセージが、すべてのメディアタイプで備考とコメントを
残したすべてのユーザーに送信されます。
Request:
{
"jsonrpc": "2.0",
"method": "action.create",
"params": {
"name": "Trigger action",
"eventsource": 0,
"status": 0,
"esc_period": "2m",
"filter": {
"evaltype": 0,
"conditions": [
{
"conditiontype": 1,
"operator": 0,
"value": "10084"
},
{
"conditiontype": 3,
"operator": 2,
"value": "memory"
}
]
},
"operations": [
{
"operationtype": 0,
"esc_period": "0s",
"esc_step_from": 1,
"esc_step_to": 2,
"evaltype": 0,
"opmessage_grp": [
{
"usrgrpid": "7"
}
],
"opmessage": {
"default_msg": 1,
"mediatypeid": "1"
}
},
{
"operationtype": 1,
"esc_step_from": 3,
"esc_step_to": 4,
"evaltype": 0,
"opconditions": [
{
"conditiontype": 14,
"operator": 0,
"value": "0"
}
],
"opcommand_grp": [
{
"groupid": "2"
}
],
"opcommand": {
"scriptid": "3"
}
}
],
"recovery_operations": [
{
"operationtype": "11",
"opmessage": {
"default_msg": 1
}
}
],
"update_operations": [
{
"operationtype": "12",
"opmessage": {
"default_msg": 0,
"message": "Custom update operation message body",
"subject": "Custom update operation message subject"
}
}
],
"pause_suppressed": "0",
"notify_if_canceled": "0"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
検出されたホストをテンプレート "10091" にリンクさせるアクションを作成します。
Request:
{
"jsonrpc": "2.0",
"method": "action.create",
"params": {
"name": "Discovery action",
"eventsource": 1,
"status": 0,
"filter": {
"evaltype": 0,
"conditions": [
{
"conditiontype": 21,
"operator": 0,
"value": "1"
},
{
"conditiontype": 10,
"operator": 0,
"value": "2"
}
]
},
"operations": [
{
"operationtype": 6,
"optemplate": [
{
"templateid": "10091"
}
]
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
カスタムフィルター条件を使用するトリガーアクションを作成します。このアクションは、ホスト "10084"と "10106" に
対して、"Warning" 以上の重大度を持つ各トリガーのメッセージを送信する必要があります。式 ID "A"、"B"、"C"は
任意に選択しました。
Request:
{
"jsonrpc": "2.0",
"method": "action.create",
"params": {
"name": "Trigger action",
"eventsource": 0,
"status": 0,
"esc_period": "2m",
"filter": {
"evaltype": 3,
"formula": "A and (B or C)",
"conditions": [
{
"conditiontype": 4,
"operator": 5,
"value": "2",
"formulaid": "A"
},
{
"conditiontype": 1,
"operator": 0,
"value": "10084",
"formulaid": "B"
},
{
"conditiontype": 1,
"operator": 0,
"value": "10106",
"formulaid": "C"
}
]
},
"operations": [
{
"operationtype": 0,
"esc_period": "0s",
"esc_step_from": 1,
"esc_step_to": 2,
"evaltype": 0,
"opmessage_grp": [
{
"usrgrpid": "7"
}
],
"opmessage": {
"default_msg": 1,
"mediatypeid": "1"
}
}
],
"pause_suppressed": "0",
"notify_if_canceled": "0"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
ホスト名に "SRV "が含まれているか、メタデータに"AlmaLinux"が含まれている場合、ホストをホストグループ "Linux servers "に追加します。
リクエスト:
{
"jsonrpc": "2.0",
"method": "action.create",
"params": {
"name": "Register Linux servers",
"eventsource": "2",
"status": "0",
"filter": {
"evaltype": "2",
"conditions": [
{
"conditiontype": "22",
"operator": "2",
"value": "SRV"
},
{
"conditiontype": "24",
"operator": "2",
"value": "AlmaLinux"
}
]
},
"operations": [
{
"operationtype": "4",
"opgroup": [
{
"groupid": "2"
}
]
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
CAction::create() in ui/include/classes/api/services/CAction.php.