Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-service
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
qinchao
7 years ago
Commit
f436f2419a0947383b35d693359ae5b84a1bd4c9
1 parent
ce8c22e1
标签管理
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
10 deletions
monitor-service-cmdb/src/main/java/com/monitor/cmdb/ctrl/HostInfoCtrl.java
monitor-service-common/src/main/java/com/monitor/common/HostTagConstant.java
monitor-service-compare/src/main/java/com/monitor/compare/service/NignxCompare.java
monitor-service-mysql/src/main/resources/META-INF/mybatis/HostInfoMapper.xml
monitor-service-switch/src/main/java/com/monitor/switchs/NginxLimit.java
monitor-service-cmdb/src/main/java/com/monitor/cmdb/ctrl/HostInfoCtrl.java
View file @
f436f24
...
...
@@ -3,6 +3,7 @@ package com.monitor.cmdb.ctrl;
import
com.alibaba.fastjson.JSON
;
import
com.model.HostInfo
;
import
com.monitor.cmdb.service.IHostInfoService
;
import
com.monitor.common.HostTagConstant
;
import
com.monitor.model.page.PageResponse
;
import
com.monitor.model.request.HostInfoReq
;
import
com.monitor.model.request.SetHostTagsReq
;
...
...
@@ -149,7 +150,7 @@ public class HostInfoCtrl {
@RequestMapping
(
"/getHostInfoByTagNginx"
)
@ResponseBody
public
String
getHostInfoByTagNginx
()
throws
Exception
{
List
<
HostInfo
>
hostInfoList
=
hostInfoService
.
getHostInfosByTag
(
"upstream-switch"
);
List
<
HostInfo
>
hostInfoList
=
hostInfoService
.
getHostInfosByTag
(
HostTagConstant
.
tag_upstreamSwitch
);
Set
<
String
>
ips
=
new
HashSet
<
String
>();
if
(
hostInfoList
!=
null
&&
hostInfoList
.
size
()>
0
){
for
(
HostInfo
host:
hostInfoList
){
...
...
monitor-service-common/src/main/java/com/monitor/common/HostTagConstant.java
View file @
f436f24
package
com
.
monitor
.
common
;
public
class
HostTagConstant
{
public
static
final
String
tag_upstreamSwitch
=
"upstream-switch"
;
public
static
final
String
tag_gateway
=
"gateway"
;
public
static
final
String
tag_az1
=
"az1"
;
public
static
final
String
tag_az2
=
"az2"
;
public
static
final
String
tag_az3
=
"az3"
;
public
static
final
String
tag_huidu_cn
=
"灰度"
;
public
static
final
String
tag_upstreamSwitch
=
"upstream-switch"
;
public
static
final
String
tag_NginxJAVA
=
"Nginx-JAVA"
;
public
static
final
String
tag_luaSwitch
=
"lua-switch"
;
public
static
final
String
tag_lbSwitch
=
"lb-switch"
;
public
static
final
String
tag_limitSwitch
=
"limit-switch"
;
}
...
...
monitor-service-compare/src/main/java/com/monitor/compare/service/NignxCompare.java
View file @
f436f24
...
...
@@ -2,6 +2,7 @@ package com.monitor.compare.service;
import
com.model.HostInfo
;
import
com.monitor.cmdb.service.IHostInfoService
;
import
com.monitor.common.HostTagConstant
;
import
com.monitor.compare.comparator.IpComparator
;
import
com.yoho.ops.cmdb.aws.lb.AwsLoadBalance
;
import
com.yoho.ops.cmdb.models.Host
;
...
...
@@ -70,7 +71,7 @@ public class NignxCompare {
List
<
String
>
cmdbIpList
=
new
ArrayList
<>();
for
(
HostInfo
hostInfo
:
hostInfoService
.
getHostInfosByTag
(
"Nginx-JAVA"
))
{
for
(
HostInfo
hostInfo
:
hostInfoService
.
getHostInfosByTag
(
HostTagConstant
.
tag_NginxJAVA
))
{
//1 aws 2 qcloud
if
(
2
==
hostInfo
.
getCloudType
())
{
...
...
@@ -128,7 +129,7 @@ public class NignxCompare {
List
<
String
>
cmdbIpList
=
new
ArrayList
<>();
for
(
HostInfo
hostInfo
:
hostInfoService
.
getHostInfosByTag
(
"Nginx-JAVA"
))
{
for
(
HostInfo
hostInfo
:
hostInfoService
.
getHostInfosByTag
(
HostTagConstant
.
tag_NginxJAVA
))
{
//1 aws 2 qcloud
if
(
1
==
hostInfo
.
getCloudType
())
{
cmdbIpList
.
add
(
hostInfo
.
getHostIp
());
...
...
monitor-service-mysql/src/main/resources/META-INF/mybatis/HostInfoMapper.xml
View file @
f436f24
...
...
@@ -172,7 +172,7 @@
select
<include
refid=
"Base_Column_List"
/>
from host_info
where instr(
tags, concat(
#{tag},','))
>
0
where instr(
concat(',',IFNULL(tags,'')), concat(',',
#{tag},','))
>
0
</select>
<select
id=
"selectHostInfosByTagList"
resultMap=
"BaseResultMap"
>
...
...
@@ -182,9 +182,9 @@
where 1=1
<if
test=
"tagsList != null && tagsList.size > 0"
>
and
<foreach
open=
"("
close=
")"
item=
"item"
index=
"index"
collection=
"tagsList"
separator=
"and"
>
instr(tags, concat(#{item},','))
>
0
</foreach>
<foreach
open=
"("
close=
")"
item=
"item"
index=
"index"
collection=
"tagsList"
separator=
"and"
>
instr(concat(',',IFNULL(tags,'')), concat(',',#{item},','))
>
0
</foreach>
</if>
</select>
...
...
monitor-service-switch/src/main/java/com/monitor/switchs/NginxLimit.java
View file @
f436f24
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.model.HostInfo
;
import
com.monitor.common.HostTagConstant
;
import
com.monitor.common.util.HandlebarsUtils
;
import
com.monitor.model.response.BaseResponse
;
import
com.monitor.mysql.mapper.HostInfoMapper
;
...
...
@@ -44,7 +45,7 @@ public class NginxLimit {
@RequestMapping
(
value
=
"viewConf"
)
@ResponseBody
public
BaseResponse
viewConf
()
throws
Exception
{
List
<
HostInfo
>
qcloudNginxHosts
=
hostInfoMapper
.
selectHostInfosByTag
(
"limit-switch"
);
List
<
HostInfo
>
qcloudNginxHosts
=
hostInfoMapper
.
selectHostInfosByTag
(
HostTagConstant
.
tag_limitSwitch
);
if
(
CollectionUtils
.
isEmpty
(
qcloudNginxHosts
))
{
return
new
BaseResponse
(
500
,
"没有找到限流的nginx服务器"
,
new
HashMap
<
String
,
Object
>());
}
...
...
@@ -95,7 +96,7 @@ public class NginxLimit {
@ResponseBody
public
BaseResponse
switchNginxConf
(
HttpServletRequest
httpRequest
)
{
//获取对应cloud的机器 aws 1 qcloud 2
List
<
HostInfo
>
nginxHosts
=
hostInfoMapper
.
selectHostInfosByTag
(
"limit-switch"
);
List
<
HostInfo
>
nginxHosts
=
hostInfoMapper
.
selectHostInfosByTag
(
HostTagConstant
.
tag_limitSwitch
);
if
(
CollectionUtils
.
isEmpty
(
nginxHosts
))
{
return
new
BaseResponse
(
500
,
"在cmdb中未找到限流对应的nginx服务器!"
);
}
...
...
Please
register
or
login
to post a comment