-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdevo-config.sh
127 lines (105 loc) · 2.42 KB
/
devo-config.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
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
#! /bin/bash
# Configure AWS MAS Account host to log to devo relay.
# Cleans up some legacy stuff.
# curl -s https://raw.githubusercontent.com/seomoz/ops-pub/master/devo-config.sh|bash
TEAMTAG=legacy
if [[ $EUID -ne 0 ]]; then
sudo -i
fi
if [ ! -e /etc/rsyslog.d ]; then
echo "/etc/rsyslog.d not found"
exit 1
fi
devo8 () {
cat > /etc/rsyslog.d/00-devo.conf <<DATA
module(
load="imfile"
mode="inotify"
)
module(
load="immark"
interval="60"
)
module(load="imjournal" ratelimit.interval="0")
global(
workDirectory="/var/spool/rsyslog"
)
DATA
cat > /etc/rsyslog.d/49-devo.conf <<DATA2
template(
name = "box-unix"
type = "string"
string = "<%PRI%>%timegenerated% %HOSTNAME%[$TEAMTAG] box.unix.%syslogtag% %msg%"
)
action(
type="omfwd"
template="box-unix"
queue.type="LinkedList"
queue.filename="boxq1"
queue.saveonshutdown="on"
action.resumeRetryCount="-1"
Target="10.40.2.22"
Port="13000"
Protocol="tcp"
)
DATA2
}
devo5 () {
cat > /etc/rsyslog.d/49-devo.conf <<DATA2
\$template box-unix,"<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME%[$TEAMTAG] box.unix.%syslogtag:1:32%%msg:::sp-if-no-1st-sp%%msg%"
*.* @@10.40.2.22:13000;box-unix
DATA2
}
RSYSLOGV=`rsyslogd -v|head -n1|awk {'print substr($2,1,1)'}`
if [[ $RSYSLOGV -eq 8 ]]; then
devo8
elif [[ $RSYSLOGV -eq 5 || $RSYSLOGV -eq 7 ]]; then
devo5
else
echo "rsyslog not v5, v8, or not installed"
exit 1
fi
OLDFILES="05-auth.conf
10-mozstash::emitter-forward-to-collector.conf
11-mozcookbook_devops_logging.conf
22-alert-logic.conf"
for FILE in $OLDFILES; do
if [ -e /etc/rsyslog.d/$FILE ]; then
rm /etc/rsyslog.d/$FILE
fi
done
service rsyslog restart
logger "$(hostname) installed"
# clean up old installs that are not needed.
DEBIAN_FRONTEND=noninteractive
if [ -e /var/alertlogic ]; then
if [ -e /usr/bin/apt ]; then
apt purge -y al-agent
else
aptitude purge -y al-agent
fi
rm -rf /var/alertlogic
fi
if [ -e /opt/dataloop ]; then
if [ -e /usr/bin/apt ]; then
apt purge -y dataloop-agent
else
aptitude purge -y dataloop-agent
fi
rm -rf /opt/dataloop /var/log/dataloop /etc/dataloop
fi
if [ -e /etc/zabbix ]; then
if [ -e /usr/bin/apt ]; then
apt purge -y zabbix-agent
else
aptitude purge -y zabbix-agent
fi
fi
if [ -e /opt/chef ]; then
if [ -e /usr/bin/apt ]; then
apt purge -y chef
else
aptitude purge -y chef
fi
rm -rf /opt/chef /var/log/chef /etc/chef
fi