我在 docker 容器中启动了一个服务器实例,与 Facette 前端连接,看起来很酷,facette 读取 rrd 数据。
当我想从其他计算机接收数据时,问题就开始了。我在本地尝试了从 docker 到本地机器的暴露端口。
version: '2.1'
services:
collectd:
build: ./containers/collectd
ports:
- 28596:28596
- 8125:8125
volumes:
- ./var/rrd/:/var/lib/collectd/rrd
frontend:
build: ./containers/facette
ports:
- 12003:12003
volumes:
- ./var/rrd:/var/lib/collectd/rrd
- ./var/facette:/var/lib/facette/
服务器的 Dockerfile:
FROM alpine:latest
ENV ARCH=x86
RUN apk --update add perl-dev python3-dev wget alpine-sdk linux-headers rsyslog rrdtool rrdtool-dev rrdtool-utils
# Get and untar sources files
RUN wget https://collectd.org/files/collectd-5.7.1.tar.bz2
RUN tar jxvf collectd-5.7.1.tar.bz2 && rm collectd-5.7.1.tar.bz2
# Compile and purge source files
RUN cd collectd-5.7.1 && ./configure --with-rrdtool && make all install
RUN cd .. && rm -rf collectd-5.7.1
# Optionnal post installation tasks
RUN ln -s /opt/collectd/sbin/collectd /usr/sbin/collectd
RUN ln -s /opt/collectd/sbin/collectdmon /usr/sbin/collectdmon
RUN rm -rf /var/cache/apk/*
RUN apk del alpine-sdk linux-headers perl-dev python3-dev
#RUN apk add --update collectd rrdtool rsyslog collectd-dns collectd-curl collectd-sensors collectd-ping collectd-utils collectd-nginx collectd-iptables collectd-bind collectd-write_http collectd-rrdtool collectd-network collectd-disk collectd-libs
ADD ./etc/* /etc/
ADD ./entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
服务器的collectd.conf
Hostname "bakunin-tower"
FQDNLookup true
LoadPlugin syslog
<plugin syslog>
LogLevel info
File "/var/log/collectd.log"
Timestamp true
</plugin>
LoadPlugin cpu
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin nfs
LoadPlugin rrdtool
LoadPlugin swap
<plugin network>
Listen "0.0.0.0" "28596"
</plugin>
<plugin rrdtool>
DataDir "/var/lib/collectd/rrd"
</plugin>
#Include "/etc/collectd.d/*.conf"
客户的 collectd.conf
Hostname "kropotkin"
FQDNLookup true
LoadPlugin syslog
LoadPlugin "logfile"
<Plugin "logfile">
LogLevel "info"
File "/var/log/collectd.log"
Timestamp true
</Plugin>
<plugin syslog>
LogLevel info
</plugin>
LoadPlugin cpu
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
<Plugin network>
Server "127.0.0.1" "28596"
</Plugin>
在服务器上,我在 rrd 目录中只看到“bakunin-tower”,但我希望 kropotkin 也会出现。怎么了?我的头要爆炸了。
谢谢。