zabbixApi4j-Discovered host

Discovered host: 该类旨在与已发现的主机一起工作。

dhost.exists: 检查发现的主机是否存在
dhost.get: 检索发现的主机


zabbixApi4j-Discovered host_第1张图片
Discovered host


DHostExistTest
package cn.com.yeexun.testzabbix.zabbix4j.example.discoverdhost;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;

import cn.com.yeexun.testzabbix.zabbix4j.common.ZabbixApiTestBase;

import com.zabbix4j.discoveredhost.DHostExistRequest;
import com.zabbix4j.discoveredhost.DHostExistResponse;

/**
 * Created by Suguru Yajima on 2014/05/25.
 */
public class DHostExistTest extends ZabbixApiTestBase {

    public DHostExistTest() {
        super();
    }

    @Test
    public void testExist1() throws Exception {
        DHostExistRequest request = new DHostExistRequest();
        DHostExistRequest.Params params = request.getParams();
        params.addDHostId(10084);

        DHostExistResponse response = zabbixApi.discoverdHost().exist(request);
        assertNotNull(response);
        assertFalse(response.getResult());

        logger.debug(getGson().toJson(response));
    }
}


DHostGetTest

package cn.com.yeexun.testzabbix.zabbix4j.example.discoverdhost;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;

import cn.com.yeexun.testzabbix.zabbix4j.common.ZabbixApiTestBase;

import com.zabbix4j.discoveredhost.DHostGetRequest;
import com.zabbix4j.discoveredhost.DHostGetResponse;

/**
 * Created by Suguru Yajima on 2014/05/25.
 */
public class DHostGetTest extends ZabbixApiTestBase {

    public DHostGetTest() {
        super();
    }

    @Test
    public void testGet1() throws Exception {

        DHostGetRequest request = new DHostGetRequest();
        DHostGetRequest.Params params = request.getParams();
        params.addDHostId(10084);

        DHostGetResponse response = zabbixApi.discoverdHost().get(request);
        assertNotNull(response);

        logger.debug(getGson().toJson(response));
    }
}

你可能感兴趣的:(zabbixApi4j-Discovered host)