Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
J
jfzabbix
  • Overview
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • jfmonitor
  • jfzabbix
  • Wiki
  • 创建报警规则

创建报警规则

Last edited by zhengtianbao Apr 12, 2018
Page history

获取主机列表

Payload:

{
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
        "output": ["host","available"]
    },
    "auth": "54ec7f0d103f635ada0a76147d8a93a5",
    "id": 1
}

Response:

{
  "jsonrpc": "2.0",
  "result": [
    {
      "hostid": "10084",
      "host": "Zabbix server",
      "available": "1"
    },
    {
      "hostid": "10254",
      "host": "jfgitlab",
      "available": "1"
    }
  ],
  "id": 1
}

这里能够获取到主机的host,用于组成下面的expression

创建触发器trigger

Payload:

{
    "jsonrpc": "2.0",
    "method": "trigger.create",
    "params": {
            "description": "Total memory is lower than 4G at host: jfgitlab (中文测试)",
            "expression": "{jfgitlab:vm.memory.size[total].avg(1m)}<4G",
            "priority":"1"
      },
    "auth": "54ec7f0d103f635ada0a76147d8a93a5",
    "id": 1
}

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "triggerids": [
      "15405"
    ]
  },
  "id": 1
}

TODO: 表达式expression规则说明
结构为:

{<server>:<key>.<function>(<parameter>)}

server: jfgitlab 
key:  vm.memory.size[total]
function: avg(1m)

设置主机动作action

通过主机id与触发器名决定该action

Payload:

{
    "jsonrpc": "2.0",
    "method": "action.create",
    "params": {
        "name": "test action",
        "eventsource": 0,
        "status": 0,
        "filter": {
            "evaltype": "1",
            "formula": "A and B",
            "conditions": [
              {
                "conditiontype": "1",
                "operator": "0",
                "value": "10254",
                "formulaid": "A"
              },
              {
                "conditiontype": "3",
                "operator": "2",
                "value": "Total memory is lower than 4G at host: jfgitlab (中文测试)",
                "formulaid": "B"
              }
            ]
        },
        "operations": [
            {
                "operationtype": 0,
                "esc_period": "24h",
                "esc_step_from": 1,
                "esc_step_to": 1,
                "evaltype": 0,
                "opmessage_grp": [
                    {
                        "usrgrpid": "14"
                    }
                ],
                "opmessage": {
                    "subject": "Problem: {TRIGGER.NAME}",
                    "message": "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {TRIGGER.NAME}\r\nHost: {HOST.NAME}\r\nSeverity: {TRIGGER.SEVERITY}\r\n\r\nOriginal problem ID: {EVENT.ID}\r\n{TRIGGER.URL}",
                    "mediatypeid": "4"
                }
            }
        ],
        "recovery_operations": [
        ],
        "acknowledge_operations": [
        ]
    },
    "auth": "54ec7f0d103f635ada0a76147d8a93a5",
    "id": 1
}

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "actionids": [
      11
    ]
  },
  "id": 1
}
Clone repository
  • Home
  • Zabbix api ref
  • Zabbix_agent安装配置
  • Zabbix_server安装配置
  • 产品原型图
  • 创建报警规则
  • 创建用户组, 用户
  • 删除报警规则
  • 删除用户, 用户组
  • 测试脚本
  • 登入登出
  • 获取cpu使用率
  • 获取主机信息
  • 获取内存使用率
  • 获取报警信息
More Pages
×

New Wiki Page

Tip: You can specify the full path for the new file. We will automatically create any missing directories.