forked from JasonRivers/Docker-Nagios
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.linux-arm64
357 lines (321 loc) · 13 KB
/
Dockerfile.linux-arm64
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# syntax=docker/dockerfile:1
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true
ARG BUILDKIT_SBOM_SCAN_STAGE=true
FROM ubuntu:24.04
LABEL name="Nagios"
LABEL nagiosVersion="4.5.7"
LABEL nagiosPluginsVersion="2.4.12"
LABEL nrpeVersion="4.1.1"
LABEL nscaVersion="2.10.3"
LABEL ncpaVersion="3.1.1"
LABEL nagiostvVersion="0.9.2"
LABEL homepage="https://www.nagios.com/"
LABEL maintainer="Tronyx <[email protected]>"
# Environment variables
ENV NAGIOS_HOME=/opt/nagios
ENV NAGIOS_USER=nagios
ENV NAGIOS_GROUP=nagios
ENV NAGIOS_CMDUSER=nagios
ENV NAGIOS_CMDGROUP=nagios
ENV NAGIOS_FQDN=nagios.example.com
ENV NAGIOSADMIN_USER=nagiosadmin
ENV NAGIOSADMIN_PASS=nagios
ENV APACHE_RUN_USER=nagios
ENV APACHE_RUN_GROUP=nagios
ENV APACHE_LOCK_DIR=/var/run
ENV APACHE_LOG_DIR=/var/log/apache2
ENV NAGIOS_TIMEZONE=UTC
ENV DEBIAN_FRONTEND=noninteractive
ENV NG_CGI_URL=/cgi-bin
ENV NG_NAGIOS_CONFIG_FILE=${NAGIOS_HOME}/etc/nagios.cfg
ENV NG_CGI_DIR=${NAGIOS_HOME}/sbin
ENV NG_WWW_DIR=${NAGIOS_HOME}/share/nagiosgraph
ENV NAGIOS_BRANCH=nagios-4.5.7
ENV NAGIOS_PLUGINS_BRANCH=release-2.4.12
ENV NRPE_BRANCH=nrpe-4.1.1
ENV NSCA_TAG=nsca-2.10.3
ENV NCPA_BRANCH=v3.1.1
ENV NAGIOSTV_VERSION=0.9.2
RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set-selections && \
echo postfix postfix/mynetworks string "127.0.0.0/8" | debconf-set-selections && \
echo postfix postfix/mailname string ${NAGIOS_FQDN} | debconf-set-selections && \
apt-get -qq update && \
apt-get -qq -y install --no-install-recommends software-properties-common && \
add-apt-repository universe && \
apt-get -qq -y install --no-install-recommends \
apache2 \
apache2-utils \
autoconf \
automake \
bc \
bsd-mailx \
build-essential \
ca-certificates \
curl \
dnsutils \
fping \
freetds-dev \
gettext \
git \
gperf \
iputils-ping \
jq \
libapache2-mod-php \
libcache-memcached-perl \
libcgi-pm-perl \
libcrypt-des-perl \
libcrypt-rijndael-perl \
libcrypt-x509-perl \
libdbd-mysql-perl \
libdbd-pg-perl \
libdbi-dev \
libdbi-perl \
libdigest-hmac-perl \
libfreeradius-dev \
libgdchart-gd2-xpm-dev \
libradsec-dev \
libgd-dev \
libgd-gd2-perl \
libjson-perl \
libldap2-dev \
libmariadb-dev \
libnagios-object-perl \
libmonitoring-plugin-perl \
libnet-snmp-perl \
libnet-tftp-perl \
libnet-xmpp-perl \
libpq-dev \
libpython3-dev \
libredis-perl \
librrds-perl \
libssl-dev \
libswitch-perl \
libtext-glob-perl \
libwww-perl \
m4 \
netcat-traditional \
openssh-client \
parallel \
php-cli \
php-gd \
postfix \
python3-full \
python3-nagiosplugin \
python3-pip \
python3-venv \
rsync \
rsyslog \
runit \
smbclient \
snmp \
snmpd \
snmp-mibs-downloader \
unzip \
xinetd && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/* && \
# Reduce unecesssary git output
git config --global advice.detachedHead false
RUN ( grep -Ei "^${NAGIOS_GROUP}" /etc/group || groupadd $NAGIOS_GROUP ) && \
( grep -Ei "^${NAGIOS_CMDGROUP}" /etc/group || groupadd $NAGIOS_CMDGROUP )
RUN ( id -u $NAGIOS_USER || useradd --system -d $NAGIOS_HOME -g $NAGIOS_GROUP $NAGIOS_USER ) && \
( id -u $NAGIOS_CMDUSER || useradd --system -d $NAGIOS_HOME -g $NAGIOS_CMDGROUP $NAGIOS_CMDUSER )
RUN update-ca-certificates -f
# Install Nagios Core
RUN cd /tmp && \
git clone https://github.com/NagiosEnterprises/nagioscore.git -b ${NAGIOS_BRANCH} && \
cd nagioscore && \
cp /usr/share/misc/config.* . && \
./configure \
--prefix=${NAGIOS_HOME} \
--exec-prefix=${NAGIOS_HOME} \
--enable-event-broker \
--with-command-user=${NAGIOS_CMDUSER} \
--with-command-group=${NAGIOS_CMDGROUP} \
--with-nagios-user=${NAGIOS_USER} \
--with-nagios-group=${NAGIOS_GROUP} && \
make all && \
make install && \
make install-config && \
make install-commandmode && \
make install-webconf && \
make clean
# Install Nagios Plugins
RUN cd /tmp && \
git clone https://github.com/nagios-plugins/nagios-plugins.git -b $NAGIOS_PLUGINS_BRANCH && \
cd nagios-plugins && \
./tools/setup && \
./configure \
--prefix=${NAGIOS_HOME} \
--with-ipv6 \
--with-ping-command="/usr/bin/ping -n -U -W %d -c %d %s" \
--with-ping6-command="/usr/bin/ping -6 -n -U -W %d -c %d %s" && \
make && \
make install && \
make clean && \
mkdir -p /usr/lib/nagios/plugins && \
ln -sf ${NAGIOS_HOME}/libexec/utils.pm /usr/lib/nagios/plugins && \
chown root:root ${NAGIOS_HOME}/libexec/check_icmp && \
chmod u+s ${NAGIOS_HOME}/libexec/check_icmp && \
cd /tmp && rm -Rf nagios-plugins
# Install NCPA
RUN wget -q -O ${NAGIOS_HOME}/libexec/check_ncpa.py https://raw.githubusercontent.com/NagiosEnterprises/ncpa/${NCPA_BRANCH}/client/check_ncpa.py && \
chmod +x ${NAGIOS_HOME}/libexec/check_ncpa.py
# Install NRPE
RUN cd /tmp && \
git clone https://github.com/NagiosEnterprises/nrpe.git -b ${NRPE_BRANCH} && \
cd nrpe && \
./configure && \
make check_nrpe > /dev/null && \
cp src/check_nrpe ${NAGIOS_HOME}/libexec/ && \
make clean
# Install NagiosGraph
RUN cd /tmp && \
git clone https://git.code.sf.net/p/nagiosgraph/git nagiosgraph && \
cd nagiosgraph && \
./install.pl --install \
--prefix /opt/nagiosgraph \
--nagios-user ${NAGIOS_USER} \
--www-user ${NAGIOS_USER} \
--nagios-perfdata-file ${NAGIOS_HOME}/var/perfdata.log \
--nagios-cgi-url /cgi-bin && \
cp share/nagiosgraph.ssi ${NAGIOS_HOME}/share/ssi/common-header.ssi && \
cd /tmp && rm -Rf nagiosgraph
# Install NSCA
RUN cd /tmp && \
git clone https://github.com/NagiosEnterprises/nsca.git && \
cd nsca && \
git checkout ${NSCA_TAG} && \
mv config.guess config.guess.BAD && \
mv config.sub config.sub.BAD && \
wget http://cvs.savannah.gnu.org/viewvc/*checkout*/config/config/config.guess && \
wget http://cvs.savannah.gnu.org/viewvc/*checkout*/config/config/config.sub && \
./configure \
--prefix=${NAGIOS_HOME} \
--with-nsca-user=${NAGIOS_USER} \
--with-nsca-grp=${NAGIOS_GROUP} && \
make all && \
cp src/nsca ${NAGIOS_HOME}/bin/ && \
cp src/send_nsca ${NAGIOS_HOME}/bin/ && \
cp sample-config/nsca.cfg ${NAGIOS_HOME}/etc/ && \
cp sample-config/send_nsca.cfg ${NAGIOS_HOME}/etc/ && \
sed -i 's/^#server_address.*/server_address=0.0.0.0/' ${NAGIOS_HOME}/etc/nsca.cfg
# Install QStat
RUN cd /tmp && \
git clone https://github.com/multiplay/qstat.git && \
cd qstat && \
./autogen.sh && \
./configure && \
make && \
make install && \
make clean
# Install additional plugins
RUN cd /opt && \
#python3 -m venv .venv && \
#. .venv/bin/activate && \
pip3 install --break-system-packages --no-cache-dir pymssql && \
pip3 install --break-system-packages --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ pywbem paramiko pplogger paho-mqtt && \
pip3 install --break-system-packages --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ --upgrade requests && \
git clone https://github.com/willixix/naglio-plugins.git WL-Nagios-Plugins && \
git clone https://github.com/JasonRivers/nagios-plugins.git JR-Nagios-Plugins && \
git clone https://github.com/justintime/nagios-plugins.git JE-Nagios-Plugins && \
git clone https://github.com/nagiosenterprises/check_mssql_collection.git nagios-mssql && \
git clone https://github.com/danfruehauf/nagios-plugins.git DF-Nagios-Plugins && \
git clone https://github.com/jpmens/check-mqtt.git jpmens-mqtt && \
chmod +x /opt/WL-Nagios-Plugins/check* && \
chmod +x /opt/JE-Nagios-Plugins/check_mem/check_mem.pl && \
chmod +x /opt/DF-Nagios-Plugins/check_sql/check_sql && \
chmod +x /opt/DF-Nagios-Plugins/check_jenkins/check_jenkins && \
chmod +x /opt/DF-Nagios-Plugins/check_vpn/check_vpn && \
chmod +x /opt/jpmens-mqtt/check-mqtt.py && \
cp /opt/JE-Nagios-Plugins/check_mem/check_mem.pl ${NAGIOS_HOME}/libexec/ && \
cp /opt/nagios-mssql/check_mssql_database.py ${NAGIOS_HOME}/libexec/ && \
cp /opt/nagios-mssql/check_mssql_server.py ${NAGIOS_HOME}/libexec/ && \
cp /opt/DF-Nagios-Plugins/check_sql/check_sql ${NAGIOS_HOME}/libexec/ && \
cp /opt/DF-Nagios-Plugins/check_jenkins/check_jenkins ${NAGIOS_HOME}/libexec/ && \
cp /opt/DF-Nagios-Plugins/check_vpn/check_vpn ${NAGIOS_HOME}/libexec/ && \
cp /opt/jpmens-mqtt/check-mqtt.py ${NAGIOS_HOME}/libexec/
# Add check_apc.pl check
COPY plugins/check_apc.pl ${NAGIOS_HOME}/libexec/
RUN chmod +x ${NAGIOS_HOME}/libexec/check_apc.pl
# Install NagiosTV
RUN cd /tmp && \
wget -q https://github.com/chriscareycode/nagiostv-react/releases/download/v${NAGIOSTV_VERSION}/nagiostv-${NAGIOSTV_VERSION}.tar.gz && \
tar xf nagiostv-${NAGIOSTV_VERSION}.tar.gz -C /opt/nagios/share/ && \
rm /tmp/nagiostv-${NAGIOSTV_VERSION}.tar.gz
RUN sed -i.bak 's/.*\=www\-data//g' /etc/apache2/envvars
RUN export DOC_ROOT="DocumentRoot ${NAGIOS_HOME}/share" && \
sed -i "s,DocumentRoot.*,${DOC_ROOT}," /etc/apache2/sites-enabled/000-default.conf && \
sed -i "s,</VirtualHost>,<IfDefine ENABLE_USR_LIB_CGI_BIN>\nScriptAlias /cgi-bin/ ${NAGIOS_HOME}/sbin/\n</IfDefine>\n</VirtualHost>," /etc/apache2/sites-enabled/000-default.conf && \
ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
RUN mkdir -p -m 0755 /usr/share/snmp/mibs && \
mkdir -p ${NAGIOS_HOME}/etc/conf.d && \
mkdir -p ${NAGIOS_HOME}/etc/monitor && \
mkdir -p -m 700 ${NAGIOS_HOME}/.ssh && \
chown ${NAGIOS_USER}:${NAGIOS_GROUP} ${NAGIOS_HOME}/.ssh && \
touch /usr/share/snmp/mibs/.foo && \
ln -s /usr/share/snmp/mibs ${NAGIOS_HOME}/libexec/mibs && \
ln -s ${NAGIOS_HOME}/bin/nagios /usr/local/bin/nagios && \
download-mibs && echo "mibs +ALL" > /etc/snmp/snmp.conf
RUN sed -i 's,/bin/mail,/usr/bin/mail,' ${NAGIOS_HOME}/etc/objects/commands.cfg && \
sed -i 's,/usr/usr,/usr,' ${NAGIOS_HOME}/etc/objects/commands.cfg
RUN cp /etc/services /var/spool/postfix/etc/ && \
echo "smtp_address_preference = ipv4" >> /etc/postfix/main.cf
RUN rm -rf /etc/rsyslog.d /etc/rsyslog.conf /etc/sv/getty-5
ADD overlay /
RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg
# Copy example config in-case the user has started with empty var or etc
RUN mkdir -p /orig/var && \
mkdir -p /orig/etc && \
mkdir -p /orig/graph-etc && \
mkdir -p /orig/graph-var && \
mkdir -p /orig/xinetd.d && \
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/ && \
cp -Rp /opt/nagiosgraph/etc/* /orig/graph-etc && \
cp -Rp /opt/nagiosgraph/var/* /orig/graph-var && \
cp -Rp /etc/xinetd.d/* /orig/xinetd.d/
## Set the permissions for example config
RUN find /opt/nagios/etc \! -user ${NAGIOS_USER} -exec chown ${NAGIOS_USER}:${NAGIOS_GROUP} '{}' + && \
find /orig/etc \! -user ${NAGIOS_USER} -exec chown ${NAGIOS_USER}:${NAGIOS_GROUP} '{}' +
RUN a2enmod session && \
a2enmod session_cookie && \
a2enmod session_crypto && \
a2enmod auth_form && \
a2enmod request
# Make scripts executable
RUN chmod +x /usr/local/bin/start_nagios && \
chmod +x /etc/sv/*/run && \
chmod +x /opt/nagiosgraph/etc/fix-nagiosgraph-multiple-selection.sh
RUN cd /opt/nagiosgraph/etc && \
sh fix-nagiosgraph-multiple-selection.sh
# Enable all runit services
RUN ln -sf /etc/sv/* /etc/service
# Fix ping permissions for Nagios user
RUN chmod u+s /usr/bin/ping
# Set ServerName and timezone for Apache
RUN echo "ServerName ${NAGIOS_FQDN}" > /etc/apache2/conf-available/servername.conf && \
echo "PassEnv TZ" > /etc/apache2/conf-available/timezone.conf && \
ln -s /etc/apache2/conf-available/servername.conf /etc/apache2/conf-enabled/servername.conf && \
ln -s /etc/apache2/conf-available/timezone.conf /etc/apache2/conf-enabled/timezone.conf
# Cleanup
# Remove unecessary packages after install/setup are complete
RUN apt-get -qq -y autoremove && \
apt-get -qq -y remove software-properties-common && \
# Remove dirs from git clones, cache, etc.
rm -rf /root/.cache \
/tmp/* \
/var/lib/apt/lists/* && \
# Remove some other files and dirs
rm -f /opt/nagiosgraph/etc/fix-nagiosgraph-multiple-selection.sh \
/opt/get-pip.py \
/var/lib/dpkg/status-old && \
true > /var/log/dpkg.log && \
true > /var/log/lastlog && \
true > /var/log/apt/term.log
# Expose port 80 for the web UI
EXPOSE 80 5667
# Specify volumes
VOLUME "${NAGIOS_HOME}/var" "${NAGIOS_HOME}/etc" "/var/log/apache2" "/opt/Custom-Nagios-Plugins" "/opt/nagiosgraph/var" "/opt/nagiosgraph/etc"
# Start command
CMD [ "/usr/local/bin/start_nagios" ]