zabbix API应用
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应用的更多相关文章
- python 调用zabbix api接口实现主机的增删改查
python程序调用zabbix系统的api接口实现对zabbix_server端主机的增删改查,使用相关功能时候,需要打开脚本中的相关函数. 函数说明: zabbixtools() 调用zabbi ...
- Zabbix Api的使用
API使用 zabbix官网文档:https://www.zabbix.com/documentation/2.2/manual/api, Zabbix API是基于JSON-RPC 2.0规格,具体 ...
- 基于curl 的zabbix API调用
1,认证并取得加密字段 curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0&q ...
- PHP通过ZABBIX API获取主机信息 VS 直接从数据库获取主机信息
最近项目需要获取linux主机的一些信息,如CPU使用率,内存使用情况等.由于我们本身就装了zabbix系统,所以我只用知道如何获取信息即可,总结有两种方法可以获取. 一.通过ZABBIX API获取 ...
- zabbix API基本使用方法介绍
前言: 以下内容根据zabbix 3.2官方文档总结:https://www.zabbix.com/documentation/3.2/manual/api 此文档只是简单的介绍API的基本使用,关于 ...
- 利用zabbix api添加、删除、禁用主机
python环境配置yum -y install python-pip安装argparse模块pip install -i https://pypi.douban.com/simple/ argpar ...
- python3调用zabbix api
前言 今天写了一个zabbix api,这里整理一下,过程中自己也学习了一些东西. 需求 我们需要查一个文件内容如下: cat /ops/flume_hosts node1 node2 需要把这个文件 ...
- python 调用zabbix api实现查询主机信息,输出所有主机ip
之前发现搜索出来的主机调用zabbix api信息都不是那么明确,后来通过zabbix官方文档,查到想要的api信息,随后写一篇自己这次项目中用到的api. #!/usr/bin/env python ...
- Python通过Zabbix API获得数据
Zabbix API查询:https://www.zabbix.com/documentation/2.0/manual/appendix/api/api import json,urllib2 fr ...
- 03: zabbix API接口 对 主机、主机组、模板、应用集、监控项、触发器等增删改查
目录:Django其他篇 01: 安装zabbix server 02:zabbix-agent安装配置 及 web界面管理 03: zabbix API接口 对 主机.主机组.模板.应用集.监控项. ...
随机推荐
- C# 8.0的三个值得关注的新特性
本文翻译自:https://dzone.com/articles/3-new-c-8-features-we-are-excited-about 转载请注明出自:葡萄城官网,葡萄城为开发者提供专业的开 ...
- Javascript 对象 - 数学对象
数学对象 JavaScript中提供了math对象,math对象包含一些常用的属相和方法.Math对象与Array对象.String对象.Data对象不同,没有构造函数,因此不能创建Math对象.可直 ...
- 章节四、3-While循环-DoWhile语句
一.while死循环 package introduction5; public class WhileDemo { public static void main(String[] args) { ...
- MyBatis笔记----SSM框架mybatis3整合springmvc spring4
上节 无springmvc框架 http://www.cnblogs.com/tk55/p/6661786.html 结构 jar包 web.xml 与index.jsp <?xml versi ...
- Windows Server 2016-管理Active Directory复制任务
Repadmin.exe可帮助管理员诊断运行Microsoft Windows操作系统的域控制器之间的Active Directory复制问题. Repadmin.exe内置于Windows Serv ...
- .gho文件检查
虽然目前windows10的接受程度越来越广泛,但我接触到的一些非IT人士还是钟爱于windows7系统,本文记录一下在使用ghost还原系统遇到的问题. gho还原失败 在还原ghost系统过程中, ...
- [Hive_8] Hive 设计优化
0. 说明 在 Hive 中,数据库是一个文件夹,表也是文件夹 partition,是一个字段,是文件 前提:在 Hive 进行 where 子句查询的时候,会将条件语句和全表进行比对,搜索出所需的数 ...
- 安全之路 —— 利用APC队列实现跨进程注入
简介 在之前的文章中笔者曾经为大家介绍过使用CreateRemoteThread函数来实现远程线程注入(链接),毫无疑问最经典的注入方式,但也因为如此,这种方式到今天已经几乎被所有安全软件所防御.所以 ...
- jQuery -- 光阴似箭(一):初见 jQuery -- 基本用法,语法,选择器
jQuery -- 知识点回顾篇(一):初见jQuery -- 基本用法,语法,选择器 1. 使用方法 jQuery 库位于一个 JavaScript 文件中,其中包含了所有的 jQuery 函数. ...
- win10升级后蓝牙不见了,设备管理器里没有,多了个串行控制器里的未知USB设备?
win10更新后,蓝牙功能不见了,也没有打开的选项,设备管理器里也没有,多了个未知USB设备,重启无效,重装蓝牙驱动无效,BIOS中的Bluetooth是开的. 试了网上能找到的所有方法,包括更新wi ...