在 Docker Alpine 映像中设置 NSCA 以进行被动 nagios 检查

Setting up NSCA in Docker Alpine image for passive nagios check

在 Alpine linux 包站点 https://pkgs.alpinelinux.org/packages NSCA 软件包尚未添加。是否有替代方法在 Alpine Linux 中设置 NSCA 以进行被动检查?

如果没有它的包,你总是可以自己构建它。

FROM alpine AS builder

ARG NSCA_VERSION=2.9.2

RUN apk update && apk add build-base build-base gcc wget git

RUN wget http://prdownloads.sourceforge.net/nagios/nsca-$NSCA_VERSION.tar.gz
RUN tar xzf nsca-$NSCA_VERSION.tar.gz
RUN cd nsca-$NSCA_VERSION&& ./configure && make all
RUN ls -lah nsca-$NSCA_VERSION/src
RUN mkdir -p /dist/bin && cp nsca-$NSCA_VERSION/src/nsca /dist/bin
RUN mkdir -p /dist/etc && cp nsca-$NSCA_VERSION/sample-config/nsca.cfg /dist/etc

FROM alpine

COPY --from=builder /dist/bin/nsca /bin/
COPY --from=builder /dist/etc/nsca.cfg /etc/

由于这是使用多个阶段,因此生成的图像将不包含开发文件并且仍然很小。