-
Notifications
You must be signed in to change notification settings - Fork 0
/
newrelic-infra.jps
104 lines (87 loc) · 3.37 KB
/
newrelic-infra.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
version: 0.1
type: update
name: 'Newrelic Infrastructure Agent'
homepage: https://github.com/layershift/jps-newrelic-infra
baseUrl: https://raw.githubusercontent.com/layershift/jps-newrelic-infra/master
id: 'newrelic-infra'
description:
short: Installs and makes the new relic infra-agent replicate when horizontal scaling
logo: /images/newrelic_.png
categories:
- apps/others
targetNodes:
nodeType:
- "*"
settings:
fields:
- type: string
caption: License Key
name: license
menu:
- caption: Restart Newrelic Infra
loadingText: Restarting..
confirmText: Are you sure you wish to restart Newrelic Infra?
action: restartService
buttons:
- caption: Status
loadingText: Checking..
action: checkServiceSetatus
onInstall:
deployRPM:
nodeId: ${targetNodes.nodeGroup}
onAfterRedeployContainer:
- forEach(event.response.responses):
deployRPM:
nodeId: ${@i.nodeid}
onAfterScaleOut:
- forEach(event.response.nodes):
deployRPM:
nodeId: ${@i.id}
onUninstall: removeRPM
actions:
deployRPM:
cmd[${this.nodeId}]: |-
grep -q license_key /etc/newrelic-infra.yml 2>/dev/null; if [ $? -eq 0 ]; then sed -i -e 's/license_key:.*/license_key: ${settings.license}/' /etc/newrelic-infra.yml; else echo 'license_key: ${settings.license}' >> /etc/newrelic-infra.yml; fi;
grep -q enable_process_metrics /etc/newrelic-infra.yml 2>/dev/null; if [ $? -ne 0 ]; then echo "enable_process_metrics: true" >> /etc/newrelic-infra.yml; fi;
grep -q kernel_modules_refresh_sec /etc/newrelic-infra.yml 2>/dev/null; if [ $? -ne 0 ]; then echo "kernel_modules_refresh_sec: -1" >> /etc/newrelic-infra.yml; fi;
grep -q selinux_enable_semodule /etc/newrelic-infra.yml 2>/dev/null; if [ $? -ne 0 ]; then echo "selinux_enable_semodule: false" >> /etc/newrelic-infra.yml; fi;
grep -q sysctl_interval_sec /etc/newrelic-infra.yml 2>/dev/null; if [ $? -ne 0 ]; then echo "sysctl_interval_sec: 600" >> /etc/newrelic-infra.yml; fi;
curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/7/x86_64/newrelic-infra.repo;
yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra';
yum -q install newrelic-infra -y;
chown -R jelastic /etc/newrelic-infra /etc/newrelic-infra.yml;
systemctl enable newrelic-infra;
systemctl start newrelic-infra;
curl -fsSL '${baseUrl}/scripts/sudo_newrelicInfra' -o /etc/sudoers.d/newrelicInfra;
sayYes: true
user: root
removeRPM:
cmd[${targetNodes.nodeGroup}]:
- systemctl stop newrelic-infra
- systemctl disable newrelic-infra
- yum -q autoremove newrelic-infra -y
- rm -f /etc/yum.repos.d/newrelic-infra.repo
- rm -f /etc/sudoers.d/newrelicInfra;
sayYes: true
user: root
restartService:
- cmd[${targetNodes.nodeGroup}]:
- systemctl restart newrelic-infra
sayYes: true
user: root
- message: ${response.out}
script: |
return {result: 2308, message: message.replace(/\n/g, ' \n')}
checkServiceSetatus:
- cmd[${targetNodes.nodeGroup}]:
- systemctl status newrelic-infra --lines=0
sayYes: true
user: root
- message: ${response.out}
script: |
return {result: 2308, message: message.replace(/\n/g, ' \n')}
responses:
2308:
type: success
2309:
type: error