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
caf8d4d55eedd71932bb1f37f49a5a1e9c7563ec
1 parent
8994c54d
master
...
dev
devMha
dev_addtag
dev_autoscal_java
dev_config_center
dev_deploy_uic
dev_deploy_yohosearchservice
dev_deply_image
dev_dock_release
dev_docker2
dev_gml
dev_host_topo
dev_influx_upgrade
dev_mip_hbasesource
dev_mysql
dev_nginx
dev_nginx_checkbox_back
dev_ops_agent
dev_store
dev_zkmaster
dockerMaster
自动伸缩
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
32 deletions
monitor-service-awstools/src/main/java/com/monitor/awstools/service/AwsQueryService.java
monitor-service-awstools/src/main/java/com/monitor/cloudtools/controller/CloudToolController.java
monitor-service-awstools/src/main/java/com/monitor/awstools/service/AwsQueryService.java
View file @
caf8d4d
...
...
@@ -119,13 +119,13 @@ public class AwsQueryService {
AmazonAutoScaling
client
=
new
AmazonAutoScalingClient
(
awsClientComp
.
getAWSCredentials
());
client
.
setRegion
(
awsClientComp
.
getRegion
(
Regions
.
CN_NORTH_1
));
DescribeAutoScalingGroupsRequest
request
=
null
;
/*
if(StringUtils.isNotBlank(equalsName)){
if
(
StringUtils
.
isNotBlank
(
equalsName
)){
request
=
new
DescribeAutoScalingGroupsRequest
()
.
withAutoScalingGroupNames
(
equalsName
);
}else{
*/
}
else
{
request
=
new
DescribeAutoScalingGroupsRequest
()
.
withAutoScalingGroupNames
();
//
}
}
DescribeAutoScalingGroupsResult
result
=
client
.
describeAutoScalingGroups
(
request
);
if
(
result
==
null
){
return
null
;
...
...
@@ -144,41 +144,71 @@ public class AwsQueryService {
}
}
if
(!
nameTag
.
equals
(
group
.
getAutoScalingGroupName
())&&!
equalsName
.
equals
(
group
.
getAutoScalingGroupName
())){
continue
;
}
}
if
(
nameTag
.
equals
(
group
.
getAutoScalingGroupName
())||
equalsName
.
equals
(
group
.
getAutoScalingGroupName
())){
commGroup
=
new
CommAutoScalingGroup
();
commGroup
.
setScalingGroupName
(
group
.
getAutoScalingGroupName
());
commGroup
.
setMinSize
(
group
.
getMinSize
());
commGroup
.
setMaxSize
(
group
.
getMaxSize
());
commGroup
.
setDesiredCapacity
(
group
.
getDesiredCapacity
());
if
(
CollectionUtils
.
isNotEmpty
(
group
.
getInstances
())){
Collection
<
String
>
ids
=
new
ArrayList
<>();
Map
<
String
,
Boolean
>
idsMap
=
new
HashMap
<>();
for
(
com
.
amazonaws
.
services
.
autoscaling
.
model
.
Instance
instance
:
group
.
getInstances
()){
ids
.
add
(
instance
.
getInstanceId
());
idsMap
.
put
(
instance
.
getInstanceId
(),
instance
.
getProtectedFromScaleIn
());
}
//根据InstanceId获取详细信息
List
<
CommAutoScalingInstances
>
commInstancess
=
getDescribeInstances
(
ids
,
idsMap
);
//计算出几台是受保护的机器,方便前台使用
if
(
CollectionUtils
.
isNotEmpty
(
commInstancess
)){
int
count
=
0
;
for
(
CommAutoScalingInstances
awsInstance
:
commInstancess
){
if
(
"TRUE"
.
equals
(
awsInstance
.
getProtectedFrom
().
toUpperCase
())){
count
+=
1
;
}
}
commGroup
.
setProtectedFromCount
(
count
);
}
commGroup
.
setScalingInstancess
(
commInstancess
);
commGroup
=
new
CommAutoScalingGroup
();
commGroup
.
setScalingGroupName
(
group
.
getAutoScalingGroupName
());
commGroup
.
setMinSize
(
group
.
getMinSize
());
commGroup
.
setMaxSize
(
group
.
getMaxSize
());
commGroup
.
setDesiredCapacity
(
group
.
getDesiredCapacity
());
if
(
CollectionUtils
.
isNotEmpty
(
group
.
getInstances
())){
Collection
<
String
>
ids
=
new
ArrayList
<>();
Map
<
String
,
Boolean
>
idsMap
=
new
HashMap
<>();
for
(
com
.
amazonaws
.
services
.
autoscaling
.
model
.
Instance
instance
:
group
.
getInstances
()){
ids
.
add
(
instance
.
getInstanceId
());
idsMap
.
put
(
instance
.
getInstanceId
(),
instance
.
getProtectedFromScaleIn
());
commGroups
.
add
(
commGroup
);
}
}
//根据InstanceId获取详细信息
List
<
CommAutoScalingInstances
>
commInstancess
=
getDescribeInstances
(
ids
,
idsMap
);
//计算出几台是受保护的机器,方便前台使用
if
(
CollectionUtils
.
isNotEmpty
(
commInstancess
)){
int
count
=
0
;
for
(
CommAutoScalingInstances
awsInstance
:
commInstancess
){
if
(
"TRUE"
.
equals
(
awsInstance
.
getProtectedFrom
().
toUpperCase
())){
count
+=
1
;
}
else
{
commGroup
=
new
CommAutoScalingGroup
();
commGroup
.
setScalingGroupName
(
group
.
getAutoScalingGroupName
());
commGroup
.
setMinSize
(
group
.
getMinSize
());
commGroup
.
setMaxSize
(
group
.
getMaxSize
());
commGroup
.
setDesiredCapacity
(
group
.
getDesiredCapacity
());
if
(
CollectionUtils
.
isNotEmpty
(
group
.
getInstances
())){
Collection
<
String
>
ids
=
new
ArrayList
<>();
Map
<
String
,
Boolean
>
idsMap
=
new
HashMap
<>();
for
(
com
.
amazonaws
.
services
.
autoscaling
.
model
.
Instance
instance
:
group
.
getInstances
()){
ids
.
add
(
instance
.
getInstanceId
());
idsMap
.
put
(
instance
.
getInstanceId
(),
instance
.
getProtectedFromScaleIn
());
}
//根据InstanceId获取详细信息
List
<
CommAutoScalingInstances
>
commInstancess
=
getDescribeInstances
(
ids
,
idsMap
);
//计算出几台是受保护的机器,方便前台使用
if
(
CollectionUtils
.
isNotEmpty
(
commInstancess
)){
int
count
=
0
;
for
(
CommAutoScalingInstances
awsInstance
:
commInstancess
){
if
(
"TRUE"
.
equals
(
awsInstance
.
getProtectedFrom
().
toUpperCase
())){
count
+=
1
;
}
}
commGroup
.
setProtectedFromCount
(
count
);
}
commGroup
.
setProtectedFromCount
(
count
);
}
commGroup
.
setScalingInstancess
(
commInstancess
);
commGroup
.
setScalingInstancess
(
commInstancess
);
commGroups
.
add
(
commGroup
);
commGroups
.
add
(
commGroup
);
}
}
}
}
catch
(
Exception
e
){
DEBUG
.
error
(
" - AwsController - getAwsAutoScaling - error"
,
e
);
...
...
monitor-service-awstools/src/main/java/com/monitor/cloudtools/controller/CloudToolController.java
View file @
caf8d4d
...
...
@@ -137,7 +137,13 @@ public class CloudToolController {
public
BaseResponse
getIpsByScalingGroupId
(
int
cloudType
,
String
groupName
,
String
groupId
){
BaseResponse
response
=
new
BaseResponse
();
List
<
String
>
ipList
=
null
;
if
(
1
==
cloudType
){
if
(
groupName
==
null
||
groupName
.
length
()<=
0
){
response
.
setCode
(
300
);
response
.
setMessage
(
"aws伸缩组名字为空"
);
return
response
;
}
List
<
CommAutoScalingGroup
>
autoScalingGroups
=
awsQueryService
.
autoScalingConfig
(
groupName
);
if
(
autoScalingGroups
!=
null
&&
autoScalingGroups
.
get
(
0
)!=
null
&&
autoScalingGroups
.
get
(
0
).
getScalingInstancess
()!=
null
){
ipList
=
new
ArrayList
<
String
>();
...
...
Please
register
or
login
to post a comment