forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
oos-timing-management-of-ecs.yml
117 lines (117 loc) · 3.8 KB
/
oos-timing-management-of-ecs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
EcsInstanceIds:
Type: CommaDelimitedList
Label:
en: Select the ecs instance to execute the cloud assistant command(Used to view
the 10 processes with the highest CPU usage on the instance)
zh-cn: 选择执行云助手命令的ecs实例(用于查看实例上CPU占用最高的10个进程)
Description:
en: Please select running ECS instances.
zh-cn: 请选择运行中状态的ECS实例。
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
ExecuteTime:
Type: String
Label:
en: Timing type
zh-cn: 定时类型
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
Resources:
OosRole:
Type: ALIYUN::RAM::Role
Properties:
RoleName:
Fn::Sub: OosRole-${ALIYUN::StackId}
Policies:
- PolicyName:
Fn::Sub: OosPolicy-${ALIYUN::StackId}
PolicyDocument:
Version: '1'
Statement:
- Action:
- ecs:RunCommand
- ecs:DescribeInstances
- ecs:DescribeInvocationResults
- ecs:DescribeInvocations
Resource:
- '*'
Effect: Allow
AssumeRolePolicyDocument:
Version: '1'
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
RAM:
- Fn::Sub: acs:ram::${ALIYUN::TenantId}:root
Service:
- oos.aliyuncs.com
Execution:
Type: ALIYUN::OOS::Execution
Properties:
Parameters:
timerTrigger:
Ref: ExecuteTime
OOSAssumeRole:
Fn::GetAtt:
- OosRole
- RoleName
templateParameters:
username: ''
rateControl:
MaxErrors: 0
Mode: Concurrency
Concurrency: 10
regionId:
Ref: ALIYUN::Region
workingDir: /root
commandType: RunShellScript
windowsPasswordName: ''
commandContent: "#!/bin/bash\n# Show top processes sorted by cpu usage\n\
# [ECS] ACS-ECS-CpuTopNProcessList-for-linux.sh - Provided by Alibaba\
\ Cloud ECS\n# Version: 1.0\n# \n# The Count of Processes Listed: '{{PROCESS_NUM}}'\n\
TOPN=10\nif [ \"$TOPN\" == \"\" ]\nthen\nTOPN='10'\nfi\nps auxw | head\
\ -1; ps auxw | grep -v PID | sort -rn -k3 | head -$TOPN"
enableParameter: false
timeout: 600
targets:
ResourceIds:
Ref: EcsInstanceIds
RegionId:
Ref: ALIYUN::Region
Type: ResourceIds
templateName: ACS-ECS-BulkyRunCommand
TemplateName: ACS-ECS-ScheduleToExecuteTemplate
ResourceCleaner:
Type: ALIYUN::ROS::ResourceCleaner
Properties:
Action: Scan+CleanUp
CleanUpTimeout: 120
Resources:
- ResourceType: RAM:Role
ResourceId:
Fn::GetAtt:
- OosRole
- RoleId
RegionId: center
- ResourceType: RAM:ManagedPolicy
ResourceId:
Fn::Sub: OosPolicy-${ALIYUN::StackId}
RegionId: center
DependsOn: Execution
Outputs:
Execute:
Description:
en: The template ACS-ECS-BulkyRunCommand has been used to run Bulky Assistant
commands on multiple ECS instances in batches. Please go to the OOS console
to confirm
zh-cn: 已使用模板ACS-ECS-BulkyRunCommand批量在多台ECS实例上运行云助手命令。请前往OOS控制台,在左侧导航栏选择自动化运维>执行管理进行验证,控制台链接:https://oos.console.aliyun.com/。
Value: ACS-ECS-BulkyRunCommand
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- EcsInstanceIds
- ExecuteTime
TemplateTags:
- acs:document:试用教程:OOS实现ECS的定时管理