1、模拟登录

curl -i -X POST -H 'Content-Type:application/json' -d '{"jsonrpc":"2.0","method":"user.login","params":{"user":"admin","password":"zabbix"},"auth":null,"id":0}' http://10.10.2.249/zabbix/api_jsonrpc.php 

  结果:

 {"jsonrpc":"2.0","result":"b740fd0ba59a531e2513fb0ffd5b3eb9","id":}

2、获取所有监控主机的hostid

curl -i -X POST -H 'Content-Type:application/json' -d
'{"jsonrpc":"2.,"method":"host.get","params":{"output":["hostid","host"]},"auth":"b740fd0ba59a531e2513fb0ffd5b3eb9","id":0}' http://10.10.2.249/zabbix/api_jsonrpc.php

  结果:

{"jsonrpc":"2.0","result":[{"hostid":"10084","host":"Zabbix server"},{"hostid":"10105","host":"10.10.2.109"},{"hostid":"10106","host":"10.10.2.107"}],"id":0}

3、特定监控主机的预警信息

  监控主机id:10105,过滤,只选择esc_step为1(异常报警)的

curl -i -X POST -H 'Content-Type:application/json' -d
'{"jsonrpc":"2.0","method":"alert.get","params":{"output":["10456"],"hostids":"10105","filter":{"esc_step":1}},"auth":"b740fd0ba59a531e2513fb0ffd5b3eb9","id":0}' http://10.10.2.249/zabbix/api_jsonrpc.php

  结果:

{"jsonrpc":"2.0","result":[{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},
{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""},{"alertid":""}],"id":}

4、检测当前所有主机的检测项对应的异常,以及异常级别:

curl -i -X POST -H 'Content-Type:application/json' -d
'

{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"output": [
"triggerid",
"description",
"priority",

"lastchange"
],
"filter": {
  "value": 1
},
"sortfield": "priority",
"sortorder": "DESC",
"min_severity": 1,
"skipDependent": 1,
"monitored": 1,
"active": 1,
"expandDescription": 1,
"selectHosts": [
"host"
],
"selectGroups": [
"name"
],

"selectItems": [
"name"
],
"only_true": 1
},
"auth": "b740fd0ba59a531e2513fb0ffd5b3eb9",
"id": 0
}

'
http://10.10.2.249/zabbix/api_jsonrpc.php

curl -i -X POST -H 'Content-Type:application/json' -d '{"jsonrpc": "2.0","method": "trigger.get","params": {"output": ["triggerid","description","priority","lastchange"], "filter": {"value": 1},"sortfield": "priority","sortorder": "DESC","min_severity": 1,"skipDependent": 1,"monitored": 1, "active": 1,"expandDescription": 1,"selectHosts": ["host"],"selectGroups": ["name"],"selectItems": [ "name"],"only_true": 1},"auth": "f7caf0143aa4eba470a57d7c4c6d546f","id": 0}' http://10.10.2.249/zabbix/api_jsonrpc.php

结果:

{
"jsonrpc": "2.0",
"result": [
{
"triggerid": "13491",
"description": "Zabbix agent on 10.10.2.249 is unreachable for 5 minutes",
"priority": "3",
"groups": [
{
"groupid": "4",
"name": "Zabbix servers"
}
],
"hosts": [
{
"hostid": "10084",
"host": "10.10.2.249"
}
],
"items": [
{
"itemid": "23287",
"name": "Agent ping"
}
]
}
],
"id": 0
}

相关资料:

通过api获取历史信息:http://www.linuxidc.com/Linux/2014-02/96997.htm

通过API获取最新告警信息:http://blog.csdn.net/honux5i/article/details/78612469

API基础信息:http://www.mamicode.com/info-detail-211211.html

基于JAVA访问zabbixAPI:

http://blog.csdn.net/u012743772/article/details/78049322

http://blog.csdn.net/itest_2016/article/details/72356238?locationNum=14&fps=1

https://www.zabbix.com/documentation/2.2/manual/api/reference/host/create

关于Python调用zabbixAPI:

http://blog.51cto.com/rfyiamcool/1358792

https://www.cnblogs.com/dreamer-fish/p/5485869.html

5、异常监控项查询

select items.* FROM items, functions fun, triggers tri where fun.itemid = items.itemid and fun.triggerid = tri.triggerid and tri.value#

SELECT itemid, FROM_UNIXTIME(clock),VALUE  from history_uint where itemid=23748 ORDER BY clock DESC

zabbix API应用的更多相关文章

  1. python 调用zabbix api接口实现主机的增删改查

    python程序调用zabbix系统的api接口实现对zabbix_server端主机的增删改查,使用相关功能时候,需要打开脚本中的相关函数. 函数说明: zabbixtools()  调用zabbi ...

  2. Zabbix Api的使用

    API使用 zabbix官网文档:https://www.zabbix.com/documentation/2.2/manual/api, Zabbix API是基于JSON-RPC 2.0规格,具体 ...

  3. 基于curl 的zabbix API调用

    1,认证并取得加密字段 curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0&q ...

  4. PHP通过ZABBIX API获取主机信息 VS 直接从数据库获取主机信息

    最近项目需要获取linux主机的一些信息,如CPU使用率,内存使用情况等.由于我们本身就装了zabbix系统,所以我只用知道如何获取信息即可,总结有两种方法可以获取. 一.通过ZABBIX API获取 ...

  5. zabbix API基本使用方法介绍

    前言: 以下内容根据zabbix 3.2官方文档总结:https://www.zabbix.com/documentation/3.2/manual/api 此文档只是简单的介绍API的基本使用,关于 ...

  6. 利用zabbix api添加、删除、禁用主机

    python环境配置yum -y install python-pip安装argparse模块pip install -i https://pypi.douban.com/simple/ argpar ...

  7. python3调用zabbix api

    前言 今天写了一个zabbix api,这里整理一下,过程中自己也学习了一些东西. 需求 我们需要查一个文件内容如下: cat /ops/flume_hosts node1 node2 需要把这个文件 ...

  8. python 调用zabbix api实现查询主机信息,输出所有主机ip

    之前发现搜索出来的主机调用zabbix api信息都不是那么明确,后来通过zabbix官方文档,查到想要的api信息,随后写一篇自己这次项目中用到的api. #!/usr/bin/env python ...

  9. Python通过Zabbix API获得数据

    Zabbix API查询:https://www.zabbix.com/documentation/2.0/manual/appendix/api/api import json,urllib2 fr ...

  10. 03: zabbix API接口 对 主机、主机组、模板、应用集、监控项、触发器等增删改查

    目录:Django其他篇 01: 安装zabbix server 02:zabbix-agent安装配置 及 web界面管理 03: zabbix API接口 对 主机.主机组.模板.应用集.监控项. ...

随机推荐

  1. Django之Ajax文件上传

    请求头ContentType ContentType指的是请求体的编码类型,常见的类型共有3种: 1 application/x-www-form-urlencoded(看下图) 这应该是最常见的 P ...

  2. 照葫芦画瓢系列之Java --- Maven的介绍和安装

    一.Maven是什么? Maven 是一个项目管理工具.它负责管理项目开发过程中的几乎所有的东西. 版本 maven有自己的版本定义和规则 构建 maven支持许多种的应用程序类型,对于每一种支持的应 ...

  3. Elasticsearch Search APIs

    Elasticsearch Search APIs By:授客 QQ:1033553122 1. 搜索 1 在单个索引的所有类型中搜索 1 在单个索引的指定类型中搜索 1 在多个指定的索引中搜索 1 ...

  4. 使用MUI/html5plus集成微信支付需要注意的几点问题

    1)需要在服务器根目录放上证书,从微信开放平台下载 2)客户端组件目录名一定要按照微信要求

  5. CSS杂谈(2)

    opacity 属性设置元素的不透明级别.   语法 opacity: value|inherit; 值 描述   value 规定不透明度.从 0.0 (完全透明)到 1.0(完全不透明).   i ...

  6. [20180926]共享池中的NETWORK BUFFER.txt

    [20180926]共享池中的NETWORK BUFFER.txt --//最近几天一直在探究SQL*Net more data from client 相关等待事件,发现SDU相关,自己也网上探究一 ...

  7. Django之--POST方法处理表单请求

    上一篇:Django之--MVC的Model 演示了如何使用GET方法处理表单请求,本文讲述直接在当前页面返回结果,并使用更常用的POST方法处理. 一.首先我们修改下page.html <!D ...

  8. Linux进程上下文切换过程context_switch详解--Linux进程的管理与调度(二十一)

    1 前景回顾 1.1 Linux的调度器组成 2个调度器 可以用两种方法来激活调度 一种是直接的, 比如进程打算睡眠或出于其他原因放弃CPU 另一种是通过周期性的机制, 以固定的频率运行, 不时的检测 ...

  9. python函数的用法

    python函数的用法 目录: 1.定义.使用函数 1.函数定义:def 2.函数调用:例:myprint() 3.函数可以当作一个值赋值给一个变量 例:a=myprint()    a() 4.写r ...

  10. ctf学习(web题二)

    web 下面是做bugku上一些web的总结 内容链接