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. 解决ui-router路由监听$stateChangeStart、$stateChangeSuccess、$stateChangeError不执行的问题

    问题解答 angular1项目导入ui-router之后,使用路由监听,代码如下 angular.module('app', ['ui.router', 'ui.router.state.events ...

  2. Android为TV端助力 不需要Socket的跨进程推送消息AIDL!

    上篇介绍了跨进程实时通讯http://www.cnblogs.com/xiaoxiaing/p/5818161.html 但是他有个缺点就是服务端无法推送消息给客户端,今天这篇文章主要说的就是服务器推 ...

  3. MongoDB 安装与配置

    MongoDB下载 官方下载链接:https://www.mongodb.com/download-center/community MongoDB安装 简单,按提示安装即可.安装方式: 1. Com ...

  4. CsQuery获取IDomObject元素的完整CSS选择器

    一.方法说明 通过IDomObject元素,获取完整的CSS选择器,过滤HTML和BODY元素,自动将class.id添加到选择器上,优先添加class,无class再添加id.如: <html ...

  5. JSF中run项目时候Tomcat8启动不了的一种方法

    把另一个博客内容迁移到这 我的问题是Tomcat是可以启动的 但是run那个jsp的时候 七月 10, 2016 3:14:54 下午 org.apache.tomcat.util.digester. ...

  6. 盒子模型、网页自动居中、float浮动与清除、横向两列布局

    1.CSS包含:标准文档流,浮动,绝对定位 标准文档流的特点:从上到下,从左到右,输出文档内容 盒子模型:块级元素(div ui li dl dt p)与行级元素(span strong img in ...

  7. MYSQL主从同步/主主同步

    一.MYSQL主从同步 注意:进行主从同步操作时需要确保DB无写操作 flush tables with read lock:   //全局读锁定,执行了命令之后所有库所有表都被锁定只读. 1.在主机 ...

  8. c/c++叉树的创建与遍历(非递归遍历左右中,不破坏树结构)

    二叉树的创建与遍历(非递归遍历左右中,不破坏树结构) 创建 二叉树的递归3种遍历方式: 1,先中心,再左树,再右树 2,先左树,再中心,再右树 3,先左树,再右树,再中心 二叉树的非递归4种遍历方式: ...

  9. 3. svg学习笔记-基本形状和画笔属性

    svg中可以绘制的基本图形有线段,矩形,多边形,圆,椭圆,分别来看一下这些基本图形: 线段 使用<line>元素创建一条线段,格式如下: <line x1=" start- ...

  10. PHP中判断变量是否存在的方式

    isset()函数判断变量是否设置. thinkPHP中判断select查询时返回值是否为空  $object->isEmpty() empty():当变量存在,并且是一个非空非零的值时,返回 ...