-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy path30_setup-logging.sh
85 lines (81 loc) · 3.23 KB
/
30_setup-logging.sh
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
#!/usr/bin/env bash
#
# Copyright 2021-2024 The MathWorks, Inc.
# Print commands for logging purposes, including timestamps.
PS4='+ [\d \t] '
set -x
if [[ -n ${CLOUD_LOG_NAME} ]]; then
# Prepare cloudwatch config file
cat > /opt/aws/amazon-cloudwatch-agent/bin/config.json << EOF
{
"agent": {
"metrics_collection_interval": 60
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/var/log/xrdp.log",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "xrdp"
},
{
"file_path": "/var/log/mathworks/startup.log",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "startup"
},
{
"file_path": "/tmp/mathworks_ubuntu.log",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "matlab"
},
{
"file_path": "/var/log/mathworks/swap_desktop_solution.log",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "desktop_swap"
},
{
"file_path": "/home/ubuntu/matlab_crash_dump*",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "matlab_crashes"
},
{
"file_path": "/var/log/dcv/server.log*",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "dcv_server"
},
{
"file_path": "/var/log/dcv/sessionlauncher.log*",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "dcv_sessionlauncher"
},
{
"file_path": "/var/log/dcv/agent.*log*",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "dcv_agent"
},
{
"file_path": "/var/log/syslog",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "syslog"
},
{
"file_path": "/home/*/.MathWorks/mwrefarch/mwrefarch.log",
"log_group_name": "${CLOUD_LOG_NAME}",
"log_stream_name": "mwrefarch"
}
]
}
}
}
}
EOF
# In this command:
# -a fetch-config causes the agent to load the latest version of the CloudWatch agent configuration file;
# -m tells the agent the host is on ec2;
# -s starts the agent;
# -c points to the configuration file
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
systemctl enable amazon-cloudwatch-agent
fi