-
Notifications
You must be signed in to change notification settings - Fork 3
/
GNUmakefile
245 lines (203 loc) · 9.65 KB
/
GNUmakefile
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# Copyright Omega Noc (C) 2014 Omega Cube and contributors
# Nicolas Lantoing, nicolas@omegacube.fr
# Xavier Roger-Machart, xrm@omegacube.fr
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
SHELL = /bin/sh
WHOAMI = $(shell whoami)
#clear out the suffix list
.SUFFIXES:
.IGNORE: check-dependencies graphite-prebuild shinken-prebuild
#prevent up-to-date return
.PHONY: mock help default install debian centos clean test
default: help
help:
@echo "Commands\n"
@egrep -o "(^[a-z]+):" ./GNUmakefile
sudoer:
@if [ $(WHOAMI) != root ]; then \
echo "Please run this script as root or with sudo"; \
exit 1; \
fi
install: dependencies sudoer graphite shinken on-reader hokuto clean
shinken-init: sudoer shinken-install
shinken --init
debian: debian-prebuild shinken-init install nanto init-daemons
ubuntu: ubuntu-prebuild shinken-init install nanto init-daemons
ubuntu-prebuild:
@echo "Installing ubunt build"
echo 'deb http://cran.rstudio.com/bin/linux/ubuntu trusty/' >> /etc/apt/sources.list
apt-get update
apt-get install python-pip python-pycurl sqlite3 graphviz graphviz-dev pkg-config python-dev libxml2-dev libcurl4-gnutls-dev libgcrypt11-dev libgnutls-dev libreadline-dev r-base r-base-dev
useradd --user-group shinken || echo "User shinken already exist" > /dev/null;
debian-prebuild: sudoer
@echo "Installing debian build"
apt-get install python-pip python-pycurl sqlite3 graphviz graphviz-dev pkg-config python-dev libxml2-dev libcurl4-gnutls-dev libgcrypt20-dev gnutls-dev libreadline-dev r-base r-base-dev
useradd --user-group shinken || echo "User shinken already exist" > /dev/null;
init-daemons: sudoer
@echo "Cleaning debian specific files"
sed -i "s/modules.*/modules graphite, livestatus, hokuto/g" /etc/shinken/brokers/broker-master.cfg
sed -i "s/modules.*/modules named-pipe, PickleRetentionArbiter/g" /etc/shinken/arbiters/arbiter-master.cfg
cp vendor/scripts/carbon-cache-init.sh /etc/init.d/carbon-cache
cp hokuto/etc/init.d/hokuto /etc/init.d/hokuto
cp nanto/etc/init.d/nanto /etc/init.d/nanto
update-rc.d carbon-cache defaults
update-rc.d hokuto defaults
update-rc.d nanto defaults
update-rc.d shinken defaults
/etc/init.d/carbon-cache start
/etc/init.d/shinken start
/etc/init.d/nanto start
/etc/init.d/hokuto start
/etc/init.d/cron restart
chown shinken:shinken /var/lib/shinken/hokuto.db
chown -R shinken:shinken /tmp/shinken
chown shinken:shinken /var/log/shinken/arbiterd.log
centos: centos-prebuild shinken-init install nanto systemd-daemons
centos-prebuild: sudoer
@echo "Installing centos build"
curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python -
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python -
easy_install pip
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum update
yum install sqlite graphviz graphviz-devel gcc gcc-c++ python-devel libxml2-devel readline-devel R
useradd --user-group shinken || echo "User shinken already exist" > /dev/null;
systemd-daemons:
@echo "Cleaning centos install"
sed -i "s/modules.*/modules graphite, livestatus, hokuto/g" /etc/shinken/brokers/broker-master.cfg
sed -i "s/modules.*/modules named-pipe, PickleRetentionArbiter/g" /etc/shinken/arbiters/arbiter-master.cfg
cp vendor/scripts/carbon-cache-systemd.service /etc/systemd/system/carbon-cache.service
cp vendor/scripts/carbon-cache-systemd.sh /usr/bin/carbon-cache.sh
chmod +x /usr/bin/carbon-cache.sh
cp vendor/scripts/shinken-systemd.service /etc/systemd/system/shinken.service
cp hokuto/etc/systemd/system/hokuto.service /etc/systemd/system/hokuto.service
cp hokuto/etc/systemd/system/hokuto.sh /usr/bin/hokuto.sh
chmod +x /usr/bin/hokuto.sh
cp nanto/etc/systemd/system/nanto.service /etc/systemd/system/nanto.service
cp nanto/etc/systemd/system/nanto.sh /usr/bin/nanto.sh
chmod +x /usr/bin/nanto.sh
systemctl enable carbon-cache.service
systemctl enable shinken.service
systemctl enable hokuto.service
systemctl enable nanto.service
systemctl start hokuto.service
systemctl start carbon-cache.service
systemctl start shinken.service
systemctl start nanto.service
systemctl restart crond
chown shinken:shinken /var/lib/shinken/hokuto.db
chown -R shinken:shinken /tmp/shinken
chown shinken:shinken /var/log/shinken/arbiterd.log
dependencies: shinken-dependencies graphite-dependencies
check-dependencies:
@echo "Checking global dependencies..."
@command -v python 2>&1 || { echo >&2 "Missing python"; exit 1;}
@command -v shinken 2>&1 || { echo >&2 "Missing shinken, please run 'make shinken-install'"; exit 1;}
@command -v R 2>&1 || { echo >&2 "Missing R"; exit 1;}
@command -v pip 2>&1 || { echo >&2 "Missing pip."; exit 1;}
clean: on-reader-clean
#tools
#update script
update: sudoer
@python hokuto/module/update.py
@echo "Updating hokuto files"
cp -r hokuto/standalone/* /usr/local/hokuto
import-sla: sudoer
@sqlite3 /var/lib/shinken/hokuto.db "CREATE TABLE IF NOT EXISTS sla (id INTEGER NOT NULL, host_name VARCHAR(128) NOT NULL, service_description VARCHAR(32), time INTEGER NOT NULL, state INTEGER, PRIMARY KEY (id));"
@python hokuto/module/import_sla.py
#graphite
graphite-dependencies:
@command -v pip 2>&1 || { echo >&2 "Missing pip."; exit 1;}
graphite: graphite-prebuild graphite-dependencies sudoer
pip install 'graphite-query==0.11.3'
#shinken
shinken-dependencies:
# Checks that Shinken is installed
@command -v python 2>&1 || { echo >&2 "Missing python"; exit 1;}
@command -v shinken 2>&1 || { echo >&2 "Missing shinken"; exit 1;}
shinken-install-dependencies: sudoer
@echo -n "\033]0;Installing shinken plugins dependencies\007"
pip install pycurl 'flask==0.10.1' 'flask-login==0.2.11' 'flask-sqlalchemy==2.0' 'flask-babel==0.9' 'python-igraph==0.7' wtforms 'flask-assets==0.10' 'whisper==0.9.13' carbon 'Twisted<12.0' 'networkx==1.10rc2' 'graphviz==0.4.5' 'pygraphviz==1.3rc2' 'graphite-query==0.11.3' 'python-mk-livestatus==0.4' 'gunicorn==19.3.0' pynag chardet
shinken-install-plugins: sudoer vendors
@mkdir -p /var/lib/shinken/share && chown shinken:shinken /var/lib/shinken/share
-useradd --user-group graphite
@echo -n "\033]0;Installing shinken - livestatus plugin\007"
shinken install --local vendor/livestatus
@echo -n "\033]0;Installing shinken - graphite plugin\007"
shinken install graphite
@echo -n "\033]0;Installing shinken - logstore-sqlite plugin\007"
shinken install --local vendor/logstore-sqlite
@echo -n "\033]0;Installing shinken - hokuto plugin\007"
shinken install --local hokuto
@echo -n "\033]0;Installing shinken - named pipe\007"
shinken install named-pipe
@echo -n "\033]0;Installing shinken - pickle retention\007"
shinken install pickle-retention-file-generic
shinken-plugins-config: sudoer watcher
@echo -n "\033]0;Initialize livestatus config files\007"
@if ! ls /opt/graphite/conf/carbon.conf >/dev/null 2>&1; then\
cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf; \
fi
@if ! ls /opt/graphite/conf/storage-schemas.conf >/dev/null 2>&1; then\
cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf; \
fi
shinken: shinken-prebuild shinken-install-dependencies shinken-install-plugins shinken-plugins-config
@echo Omeganoc have been succefully installed
@echo Add "'modules graphite, livestatus, hokuto'" to your broker-master.cfg file
@echo Add modules named-pipe, PickleRetentionArbiter to your arbiter-master.cfg file
@echo Add modules logstore-sqlite to livestatus.cfg.
# Hokuto - Copy hokuto files to their install directory
hokuto: sudoer
@echo Installing Hokuto
@mkdir -p /usr/local/hokuto
cp -r hokuto/standalone/* /usr/local/hokuto
cp hokuto/etc/hokuto.cfg /etc/hokuto.cfg
#install shinken from sources
vendors:
@if ! ls vendor/shinken >/dev/null 2>&1; then echo "Missing vendors file, please run 'git submodules update'" & exit 1; fi
shinken-install: vendors sudoer
@cd vendor/shinken && python setup.py install clean
# Nanto
nanto: nanto-dependencies nanto-libs
cp -r nanto/src /usr/local/nanto
cp nanto/etc/nanto.cfg /etc/nanto.cfg
# Checks that R is installed
nanto-dependencies:
@command -v Rscript 2>&1 || { echo >&2 "Missing R"; exit 1; }
# Installs R and Python libraries required by the default forecasting scripts
nanto-libs: sudoer
Rscript -e "install.packages('forecast', repos='http://cran.r-project.org')"
Rscript -e "install.packages('changepoint', repos='http://cran.r-project.org')"
pip install singledispatch rpy2 python-daemon
#libs
watcher: sudoer
@echo -n "\033]0;Installing hokuto-watcher scripts.\007"
@echo -n "Installing watcher and cron routine...\n"
@cp hokuto/shinken_watcher.py /usr/local/bin/
@cp hokuto/mplock.py /usr/local/bin/
@grep -q 'shinken_watcher.py' /etc/crontab || echo '* * * * * root /usr/local/bin/shinken_watcher.py' >> /etc/crontab
on-reader: sudoer
@echo -n "\033]0;Installing livestatus libraries.\007"
@cd lib/on_reader && python setup.py install
on-reader-clean: sudoer
@cd lib/on_reader && python setup.py clean
@rm -rf lib/on_reader/build
#prebuilds messages
graphite-prebuild:
@echo -n "\033]0;Installing graphite python API/\007"
shinken-prebuild:
@echo -n "\033]0;Configuring shinken\007"
#TODO
# python-igraph