Skip to content
Usage of Zabbix 4 API From Spring
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mvn/wrapper
src
.gitignore
.travis.yml
README.md
mvnw
mvnw.cmd
pom.xml

README.md

spring-zabbix-api-client

Helper Library for using Zabbix API from a Spring Boot application based on the Zabbix API version 4.0.

Build Status Maven Central License

Usage

Import using:

<dependency>
    <groupId>io.github.mlniang</groupId>
    <artifactId>spring-zabbix-api-client</artifactId>
    <version>0.1.1</version>
</dependency>

Set the property zabbix.api.url in your properties file as the URL of the Zabbix Server (without /api_jsonrpc.php).

The ZabbixApiService offers a general method you can use to make calls to the API. Example:

import io.github.mlniang.zabbix.client.exception.ZabbixApiException;
import io.github.mlniang.zabbix.client.request.CommonGetParams;
import io.github.mlniang.zabbix.client.response.JsonRPCResponse;
import io.github.mlniang.zabbix.client.service.ZabbixApiService;
import org.springframework.stereotype.Component;

@Component
public class TestClass {

   private final ZabbixApiService zabbixApiService;

   public TestClass(ZabbixApiService zabbixApiService) {
       this.zabbixApiService = zabbixApiService;
   }

   public JsonRPCResponse testCall() throws ZabbixApiException {
       CommonGetParams params = CommonGetParams.builder()
               .output("extended")
               .build();
       return zabbixApiService.call("host.get", params, "0424bd59b807674191e7d77572075f33");
   }
}

It contains also a shortcut method for authentication (zabbixApiService.authenticate("user", "password")).

The ZabbixHostService is just a helper class built for Zabbix Host method.

Next Steps

  • Build more helpers.
  • Propose caching user auth tokens ?
You can’t perform that action at this time.