-
Notifications
You must be signed in to change notification settings - Fork 4
/
lbprovision.sh
66 lines (53 loc) · 1.81 KB
/
lbprovision.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
#!/bin/bash
source ~/.ddtraining.sh
if [ ! -f /etc/haproxy/haproxy.cfg ]; then
# Install haproxy
sudo /usr/bin/apt-get -y install haproxy
# Configure haproxy
sudo bash -c 'cat > /etc/default/haproxy <<EOD
# Set ENABLED to 1 if you want the init script to start haproxy.
ENABLED=1
# Add extra flags here.
#EXTRAOPTS="-de -m 16"
EOD'
sudo bash -c 'cat > /etc/haproxy/haproxy.cfg <<EOD
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend webservers
backend webservers
balance roundrobin
default-server fall 3 inter 5s
# Poor-mans sticky
# balance source
# JSP SessionID Sticky
# appsession JSESSIONID len 52 timeout 3h
option httpchk
option forwardfor
option http-server-close
server web1 172.28.33.11:80 check
server web2 172.28.33.12:80 check
server web3 172.28.33.13:80 check
listen stats
bind *:8080
mode http
stats uri /haproxy_stats
stats enable
EOD'
sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.orig
sudo /usr/sbin/service haproxy restart
fi
DD_API_KEY=${DD_API_KEY} bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)"
echo -n "training.hosts.started:1|c|#shell" >/dev/udp/localhost/8125
sudo mv /etc/datadog-agent/conf.d/haproxy.d/conf.yaml.example /etc/datadog-agent/conf.d/haproxy.d/conf.yaml
sudo sed -i "s/# tags:/tags:\n - role:lb/" /etc/datadog-agent/datadog.yaml
sudo sed -i "s| - url: http://localhost/admin?stats| - url: http://localhost:8080/haproxy_stats|" /etc/datadog-agent/conf.d/haproxy.d/conf.yaml
printf "\nprocess_config:\n enabled: 'true'" | sudo tee -a /etc/datadog-agent/datadog.yaml
sudo service datadog-agent restart