zabbix4j 接口文档
时间: 2023-11-24 16:06:26 浏览: 64
以下是zabbix4j的接口文档:
1.获取Zabbix API版本号
```java
ZabbixApi zabbixApi = new ZabbixApi("http://localhost/zabbix/api_jsonrpc.php");
zabbixApi.init();
String apiVersion = zabbixApi.apiVersion();
System.out.println(apiVersion);
```
2.用户登录
```java
ZabbixApi zabbixApi = new ZabbixApi("http://localhost/zabbix/api_jsonrpc.php");
zabbixApi.init();
String user = "Admin";
String password = "zabbix";
zabbixApi.login(user, password);
```
3.获取所有主机
```java
ZabbixApi zabbixApi = new ZabbixApi("http://localhost/zabbix/api_jsonrpc.php");
zabbixApi.init();
String user = "Admin";
String password = "zabbix";
zabbixApi.login(user, password);
Request request = RequestBuilder.newBuilder().method("host.get").build();
List<Host> hosts = zabbixApi.getApi().host().get(request);
System.out.println(hosts);
```
4.获取主机接口信息
```java
ZabbixApi zabbixApi = new ZabbixApi("http://localhost/zabbix/api_jsonrpc.php");
zabbixApi.init();
String user = "Admin";
String password = "zabbix";
zabbixApi.login(user, password);
Request request = RequestBuilder.newBuilder().method("hostinterface.get").paramEntry("output", "extend").build();
List<HostInterface> hostInterfaces = zabbixApi.getApi().hostInterface().get(request);
System.out.println(hostInterfaces);
```
阅读全文