- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.sdg.cmdb.service.impl.ZabbixServiceImpl
类的一些代码示例,展示了ZabbixServiceImpl
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZabbixServiceImpl
类的具体详情如下:
包路径:com.sdg.cmdb.service.impl.ZabbixServiceImpl
类名称:ZabbixServiceImpl
[英]Created by liangjian on 2016/12/16.
[中]梁健于2016年12月16日创作。
代码示例来源:origin: ixrjog/opsCloud
/**
* 初始化
*
* @return
*/
private void init() {
HashMap<String, String> configMap = acqConifMap();
String zabbixApiUrl = configMap.get(ZabbixItemEnum.ZABBIX_API_URL.getItemKey());
String zabbixApiUser = configMap.get(ZabbixItemEnum.ZABBIX_API_USER.getItemKey());
String zabbixAipPasswd = configMap.get(ZabbixItemEnum.ZABBIX_API_PASSWD.getItemKey());
logger.info("Zabbix login api url : {}", zabbixApiUrl);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(5 * 1000).setConnectionRequestTimeout(5 * 1000)
.setSocketTimeout(5 * 1000).build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(connManager)
.setDefaultRequestConfig(requestConfig).build();
setUrl(zabbixApiUrl);
setHttpClient(httpclient);
boolean login = login(zabbixApiUser, zabbixAipPasswd);
if (!login) {
logger.error("zabbix 登陆失败");
}
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 普通服务器监控添加(废弃)
*
* @return
*/
private boolean hostCreate(ServerDO serverDO) {
if (hostExists(serverDO)) return true;
if (!hostgroupCreate(serverDO)) return false;
ZabbixRequest request = ZabbixRequestBuilder.newBuilder()
.method("host.create").build();
request.putParam("host", acqZabbixServerName(serverDO));
request.putParam("interfaces", acqInterfaces(serverDO));
request.putParam("groups", acqGroup(serverDO));
request.putParam("templates", acqTemplate(serverDO));
request.putParam("macros", acqMacros(serverDO));
int proxyid = proxyGet(serverDO);
if (proxyid != 0) {
request.putParam("proxy_hostid", proxyid);
}
JSONObject getResponse = call(request);
int hostids = getResultId(getResponse, "hostids");
if (hostids == 0) return false;
return true;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 获取当前主机的接口(java类有jmx)
*
* @return
*/
private JSONArray acqInterfaces(ServerDO serverDO) {
if (serverDO == null) return null;
ConfigPropertyDO confPropertyDO = configDao.getConfigPropertyByName("TOMCAT_JMX_rmiRegistryPortPlatform_OPT");
JSONArray interfaces = new JSONArray();
String ip = this.acqServerMonitorIp(serverDO);
interfaces.add(buildInterfaces(ip, 1, "10050"));
if (confPropertyDO != null && !confPropertyDO.getProValue().isEmpty()) {
String port = this.acqServerGroupPropertiesValue(serverDO, confPropertyDO);
if (port != null && !port.isEmpty())
interfaces.add(buildInterfaces(ip, 4, port));
}
return interfaces;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 内网ip查询hostid
*
* @return
*/
private int hostGet(ServerDO serverDO) {
if (serverDO == null) return 0;
JSONObject filter = new JSONObject();
filter.put("ip", acqServerMonitorIp(serverDO));
ZabbixRequest request = ZabbixRequestBuilder.newBuilder()
.method("host.get").paramEntry("filter", filter)
.build();
JSONObject getResponse = call(request);
return getResultId(getResponse, "hostid");
}
代码示例来源:origin: ixrjog/opsCloud
ZabbixRequest request = ZabbixRequestBuilder.newBuilder()
.method("user.update").build();
request.putParam("userid", userGet(userDO));
request.putParam("name", userDO.getDisplayName());
request.putParam("usrgrps", acqUsergrps(userDO));
JSONArray userMedias = new JSONArray();
userMedias.add(acqUserMedias(1, userDO.getMail()));
if (userDO.getMobile() != null && !userDO.getMobile().isEmpty()) {
userMedias.add(acqUserMedias(3, userDO.getMobile()));
JSONObject getResponse = call(request);
int userids = getResultId(getResponse, "userids");
if (userids != 0) {
userDO.setZabbixAuthed(UserDO.ZabbixAuthType.authed.getCode());
代码示例来源:origin: ixrjog/opsCloud
@Override
public ZabbixHost getHost(long serverId) {
ServerDO serverDO = serverDao.getServerInfoById(serverId);
if (serverDO == null) return new ZabbixHost();
List<ZabbixTemplateVO> templates = getTemplates(serverDO.getServerGroupId());
ZabbixHost host = new ZabbixHost(templates);
invokeProxy(serverDO.getServerGroupId(), host);
host.setHost(serverDO.acqServerName());
host.setIp(acqServerMonitorIp(serverDO));
return host;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 获取当前主机的Zabbix监控模版
*
* @return
*/
private JSONArray acqTemplate(ServerDO serverDO) {
if (serverDO == null) return null;
JSONArray templates = new JSONArray();
ConfigPropertyDO confPropertyDO = configDao.getConfigPropertyByName("TOMCAT_APP_NAME_OPT");
int templateid = 0;
if (confPropertyDO != null) {
String value = this.acqServerGroupPropertiesValue(serverDO, confPropertyDO);
if (value == null || value.isEmpty()) {
templateid = templateGet("Template OS Linux");
} else {
templateid = templateGet("Template Java");
}
JSONObject template = new JSONObject();
template.put("templateid", templateid);
templates.add(template);
return templates;
}
return null;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 获取zabbixProxyId
* 1:zabbix_proxy_id
* 2:zabbix_proxy_name
*
* @return
*/
private int proxyGet(ServerDO serverDO) {
if (serverDO == null) return 0;
ConfigPropertyDO confPropertyDO = configDao.getConfigPropertyByName(zabbix_proxy_id);
if (confPropertyDO != null && !confPropertyDO.getProValue().isEmpty()) {
String value = acqServerPropertiesValue(serverDO, confPropertyDO);
if (value != null && !value.isEmpty()) return Integer.valueOf(value);
}
confPropertyDO = configDao.getConfigPropertyByName(zabbix_proxy_name);
if (confPropertyDO != null && !confPropertyDO.getProValue().isEmpty()) {
String value = acqServerPropertiesValue(serverDO, confPropertyDO);
if (value != null && !value.isEmpty()) return proxyGet(confPropertyDO.getProValue());
}
if (serverDO.getServerType() == 2) {
return proxyGet("proxy1.zabbix3.51xianqu.net");
}
return 0;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 检查key
*
* @param key
* @return
*/
private boolean apiCheckKey(String key) {
HashMap<String, String> configMap = acqConifMap();
String zabbixApiKey = configMap.get(ZabbixItemEnum.ZABBIX_API_KEY.getItemKey());
if (key == null) {
logger.error("cmdb.zabbix.api.key为空");
return false;
}
if (!key.equals(zabbixApiKey)) {
logger.error("cmdb.zabbix.api.key不匹配");
return false;
}
return true;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 获取当前主机的宏(macros)
*
* @return
*/
private JSONArray acqMacros(ServerDO serverDO) {
if (serverDO == null) return null;
ConfigPropertyDO confPropertyDO = configDao.getConfigPropertyByName("TOMCAT_APP_NAME_OPT");
if (confPropertyDO == null) return null;
String appName = this.acqServerGroupPropertiesValue(serverDO, confPropertyDO);
if (appName != null && !appName.isEmpty()) {
JSONArray macros = new JSONArray();
confPropertyDO = configDao.getConfigPropertyByName("TOMCAT_HTTP_PORT_OPT");
String httpPort = this.acqServerGroupPropertiesValue(serverDO, confPropertyDO);
JSONObject jsonAppName = new JSONObject();
jsonAppName.put("macro", "{$APP_NAME}");
jsonAppName.put("value", appName);
JSONObject jsonHttpPort = new JSONObject();
jsonHttpPort.put("macro", "{$HTTP_PORT}");
jsonHttpPort.put("value", httpPort);
macros.add(jsonAppName);
macros.add(jsonHttpPort);
return macros;
}
return null;
}
代码示例来源:origin: ixrjog/opsCloud
/**
* 获取主机用于zabbix监控的接口ip
*
* @return
*/
private String acqServerMonitorIp(ServerDO serverDO) {
if (serverDO == null) return null;
ConfigPropertyDO confPropertyDO = configDao.getConfigPropertyByName(zabbix_host_monitor_public_ip);
String value = acqServerPropertiesValue(serverDO, confPropertyDO);
if (value == null || value.equalsIgnoreCase("false")) {
return serverDO.getInsideIp();
}
return serverDO.getPublicIp();
}
代码示例来源:origin: ixrjog/opsCloud
request.putParam("name", userDO.getDisplayName());
request.putParam("passwd", "");
request.putParam("usrgrps", acqUsergrps(userDO));
JSONArray userMedias = new JSONArray();
userMedias.add(acqUserMedias(1, userDO.getMail()));
if (userDO.getMobile() != null && !userDO.getMobile().isEmpty()) {
userMedias.add(acqUserMedias(3, userDO.getMobile()));
JSONObject getResponse = call(request);
int userids = getResultId(getResponse, "userids");
代码示例来源:origin: ixrjog/opsCloud
/**
* 查询主机监控状态
*
* @param serverDO
* @return
*/
@Override
public int hostGetStatus(ServerDO serverDO) {
if (serverDO == null) return 0;
JSONObject filter = new JSONObject();
filter.put("ip", acqServerMonitorIp(serverDO));
JSONObject getResponse = call(ZabbixRequestBuilder.newBuilder()
.method("host.get").paramEntry("filter", filter)
.build());
return getResultId(getResponse, "status");
}
代码示例来源:origin: ixrjog/opsCloud
private boolean hostCreate(ServerDO serverDO, ZabbixHost host) {
if (hostExists(serverDO)) return true;
if (!hostgroupCreate(serverDO)) return false;
ZabbixRequest request = ZabbixRequestBuilder.newBuilder()
.method("host.create").build();
request.putParam("host", serverDO.acqServerName());
request.putParam("interfaces", acqInterfaces(serverDO));
request.putParam("groups", acqGroup(serverDO));
request.putParam("templates", acqTemplate(host.getTemplates()));
if (host.isUseProxy()) {
for (ZabbixProxy zp : host.getProxys()) {
if (zp.isSelected()) {
request.putParam("proxy_hostid", proxyGet(zp.getHost()));
}
break;
}
}
JSONObject getResponse = call(request);
int hostids = getResultId(getResponse, "hostids");
if (hostids == 0) return false;
return true;
}
我创建了一个子网,在其中连接 Cosmos DB 作为服务端点。除了 Cosmos DB 的 IP 防火墙之外,我还想通过 NSG 规则控制出站。但是,如果我创建一条规则,拒绝所有出站(也通过拒绝所有
本文整理了Java中com.sdg.cmdb.service.ZabbixHistoryService类的一些代码示例,展示了ZabbixHistoryService类的具体用法。这些代码示例主要来源
本文整理了Java中com.sdg.cmdb.service.impl.ZabbixServiceImpl类的一些代码示例,展示了ZabbixServiceImpl类的具体用法。这些代码示例主要来源于
本文整理了Java中com.sdg.cmdb.service.ZabbixHistoryService.queryFreeDiskSpaceOnData()方法的一些代码示例,展示了ZabbixHis
本文整理了Java中com.sdg.cmdb.service.ZabbixHistoryService.acqResultValue()方法的一些代码示例,展示了ZabbixHistoryServic
本文整理了Java中com.sdg.cmdb.service.ZabbixHistoryService.queryFreeDiskSpaceOnSys()方法的一些代码示例,展示了ZabbixHist
本文整理了Java中com.sdg.cmdb.domain.configCenter.itemEnum.ZabbixItemEnum类的一些代码示例,展示了ZabbixItemEnum类的具体用法。这
嗨,所有使用 Spring 数据图的耐心开发人员。由于文档太少且测试覆盖率很低,因此有时很难理解底层框架的预期行为是什么,框架应该如何工作。目前我有一些与 SDG 1.1 中引入的新获取方法相关的问题
本文整理了Java中com.sdg.cmdb.domain.configCenter.itemEnum.ZabbixItemEnum.getItemKey()方法的一些代码示例,展示了ZabbixIt
我是一名优秀的程序员,十分优秀!