-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlogDNA.jps
198 lines (177 loc) · 6.5 KB
/
logDNA.jps
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
_info : 'https://docs.cloudscripting.com/8.4.1/'
version: 8.4.1
build: 20240408
type: update
name: 'logDNA'
id: 'logDNA'
homepage: https://jps.layershift.com/logDNA
baseUrl: https://raw.githubusercontent.com/layershift/jps-logDNA/master
logo: /images/logDNA.png?_r=${fn.random}
categories:
- apps/others
description:
text: /texts/description.md
short: LogDNA is the easiest centralized log management software.
targetNodes:
nodeGroup: '*'
globals:
message: ""
settings:
main:
fields:
- type: string
name: ingestionKey
caption: Ingestion Key
hideLabel: false
required: true
- type: string
name: logDNATag
caption: Tags
hideLabel: false
- type: text
name: logPaths
caption: Logs to monitor. 1/line
default: "#Will parse *.log files from specified folders if they exist\n#Specify log folder or full path to log file for custom file extensions\n#lines starting with # are ignored\n#Nginx\n/var/log/nginx/\n#Apache\n/var/log/httpd/\n#Litespeed\n/var/log/litespeed/\n/var/log/litespeed_adc/\n#Tomcat nodes\n/opt/tomcat/logs/catalina.out\n#NodeJS\n/home/jelastic/log"
menu:
- caption: Restart LogDNA
loadingText: Restarting..
confirmText: Are you sure you wish to restart LogDNA?
action: restartLogDNA
- caption: Configure
loadingText: Updating..
settings: main
confirmText: Are you sure you wish to configure logDNA?
action: doConfigure
successText: /text/success.md
- caption: Show Configuration File
loadingText: Checking..
confirmText: Are you sure you wish to see the content of /etc/logdna.conf?
action: checkLogDNAConf
buttons:
- caption: Status
loadingText: Checking..
action: checkLogDNAStatus
- caption: Dashboard
href: https://app.logdna.com/account/signin
onAfterClone:
- script: delete MANIFEST.id; return {result:0, jps:MANIFEST};
- install[${targetNodes.nodeGroup}]: ${response.jps}
envName: ${event.response.env.envName}
settings:
ingestionKey: ${settings.ingestionKey}
logDNATag: ${settings.logDNATag}
logPaths: ${settings.logPaths}
onAfterRedeployContainer:
forEach(resp:event.response.responses):
doInstall:
nodeId: ${@resp.nodeid}
onAfterScaleOut[${targetNodes.nodeGroup}]:
forEach(node:event.response.nodes):
doInstall:
nodeId: ${@node.id}
onInstall:
- setGlobals:
message: ""
- forEach(node:targetNodes):
doInstall:
nodeId: ${@node.id}
onUninstall:
cmd [${targetNodes.nodeGroup}]:
- systemctl stop logdna-agent;
- yum -y remove logdna-agent;
- rm -f /etc/sudoers.d/logDNA;
- rm -f /etc/profile.d/logdna-agent.sh;
sayYes: true
user: root
actions:
appendMessage:
setGlobals:
message: ${globals.message}${this}
doConfigure:
- setGlobals:
message: ""
- forEach(node:targetNodes):
doInstall:
nodeId: ${@node.id}
doInstall:
- cmd [${this.nodeId}]:
- echo -e "\n\nOn node ${this.nodeId}";
- which rpm 2>/dev/null >/dev/null; if [ $? -gt 0 ]; then echo -e "Issue:\nrpm not found"; exit 0; fi;
- which systemctl 2>/dev/null >/dev/null; if [ $? -gt 0 ]; then echo -e "Issue:\nsystemctl not found"; exit 0; fi;
- rpm --import https://assets.logdna.com/logdna.gpg;
- echo '[logdna]' > /etc/yum.repos.d/logdna.repo;
- echo 'name=LogDNA packages' >> /etc/yum.repos.d/logdna.repo;
- echo 'baseurl=https://assets.logdna.com/el6/' >> /etc/yum.repos.d/logdna.repo;
- echo 'enabled=1' >> /etc/yum.repos.d/logdna.repo;
- echo 'gpgcheck=1' >> /etc/yum.repos.d/logdna.repo;
- echo 'gpgkey=https://assets.logdna.com/logdna.gpg' >> /etc/yum.repos.d/logdna.repo;
- yum -y install logdna-agent; if [ $? -gt 0 ]; then echo -e "\nIssue:\nCan't install logdna-agent"; exit 0; fi;
- rm -f /etc/logdna.conf
- logs=""; delim=""; for log in $(printf "${settings.logPaths}" | egrep -v "#|^/root|^/etc|^/var/lib"); do logs="$logs$delim$log"; delim=","; if [ $? -gt 0 ]; then echo -e "Issue:\nFailed to add $log"; exit 0; fi; done;
- mkdir -p /etc/logdna;
- touch /etc/logdna/config.yaml;
- chown -R jelastic /etc/logdna;
- curl -fsSL '${baseUrl}/scripts/buildConfigYaml.sh' -o /root/buildConfigYaml.sh;
- chmod +x /root/buildConfigYaml.sh;
- /root/buildConfigYaml.sh "${settings.ingestionKey}" "$(hostname)" "${settings.logDNATag}" "$logs"
- systemctl enable logdna-agent;
- systemctl restart logdna-agent;
- curl -fsSL '${baseUrl}/scripts/sudo_logDNA' -o /etc/sudoers.d/logDNA;
- chmod 640 /etc/sudoers.d/logDNA;
- curl -fsSL '${baseUrl}/scripts/profile_logdna-agent' -o /etc/profile.d/logdna-agent.sh;
sayYes: true
user: root
- appendMessage: ${response.out}
- if (globals.message.indexOf("Issue") !== -1):
message: ${globals.message}
script: |
return {result: 2309, message: message.replace(/\n/g, ' \n')}
restartLogDNA:
- setGlobals:
message: ""
- forEach(node:targetNodes):
- cmd [${@node.id}]:
- systemctl restart logdna-agent 2>&1 > /dev/null;
- sleep 5;
- systemctl is-active logdna-agent 2>&1 > /dev/null;
- if [ $? -gt 0 ]; then echo -en " - On node ${@node.id}\nStatus = "; systemctl status logdna-agent | grep Active; echo -e " \n\n"; fi;
user: root
- appendMessage: ${response.out}
- if (globals.message.length > 0):
return:
type: error
message: '${globals.message}'
- return:
type: success
message: 'LogDNA restart complete'
checkLogDNAStatus:
- setGlobals:
message: ""
- forEach(node:targetNodes):
- cmd [${@node.id}]:
- echo -en " - On node ${@node.id}\nStatus = ";
- systemctl status logdna-agent | grep Active;
- echo -e " \n\n";
user: root
- appendMessage: ${response.out}
- message: ${globals.message}
script: |
return {result: 2308, message: message.replace(/\n/g, ' \n')}
checkLogDNAConf:
- setGlobals:
message: ""
- forEach(node:targetNodes):
- cmd [${@node.id}]:
- echo -e "\n - On node ${@node.id}\ncat /etc/logdna.conf";
- cat /etc/logdna.conf;
user: root
- appendMessage: ${response.out}
- message: ${globals.message}
script: |
return {result: 2308, message: message.replace(/\n/g, ' \n')}
responses:
2308:
type: success
2309:
type: error
success: /texts/success.md