Discovered service: 这个类被设计用来处理已发现的服务。
dservice.exists: 检查是否存在已发现的服务
dservice.get: 检索已发现的服务
DServiceExistTest
package cn.com.yeexun.testzabbix.zabbix4j.example.discoveredservice;
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.discoveredservice.DServiceExistRequest;
import com.zabbix4j.discoveredservice.DServiceExistResponse;
/**
* Created by Suguru Yajima on 2014/05/25.
*/
public class DServiceExistTest extends ZabbixApiTestBase {
public DServiceExistTest() {
super();
}
@Test
public void testExist1() throws Exception {
DServiceExistRequest request = new DServiceExistRequest();
DServiceExistRequest.Params params = request.getParams();
params.setNode("hogehoge");
DServiceExistResponse response = zabbixApi.discoveredService().exist(request);
assertNotNull(response);
assertFalse(response.getResult());
logger.debug(getGson().toJson(response));
}
}
DServiceGetTest
package cn.com.yeexun.testzabbix.zabbix4j.example.discoveredservice;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import cn.com.yeexun.testzabbix.zabbix4j.common.ZabbixApiTestBase;
import com.zabbix4j.discoveredservice.DServiceGetRequest;
import com.zabbix4j.discoveredservice.DServiceGetResponse;
/**
* Created by Suguru Yajima on 2014/05/25.
*/
public class DServiceGetTest extends ZabbixApiTestBase {
public DServiceGetTest() {
super();
}
@Test
public void testGet1() throws Exception {
DServiceGetRequest request = new DServiceGetRequest();
DServiceGetRequest.Params params = request.getParams();
params.addDHostId(10084);
DServiceGetResponse response = zabbixApi.discoveredService().get(request);
assertNotNull(response);
logger.debug(getGson().toJson(response));
}
}