我试图开始收集docker里面,我已经尝试了一切从运行命令开始在dockerfile collectd使用脚本来运行service collectd start使用supervisord,但仍然不工作
我的supervisord.conf文件是
[unix_http_server] file=/tmp/supervisor.sock ; (the path to the socket file) [supervisord] logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) loglevel=info ; (log level;default info; others: debug,warn,trace) pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=false ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) user=root ; ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be ; added by defining them in separate rpcinterface: sections [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket [program:collectd] command=/usr/sbin/collectd -C /etc/collectd/collectd.conf -f autostart=true autorestart=true priority=5 stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0
我也尝试在我的Dockerfile中运行它
RUN service collectd start
由Dockerfile使用Ubuntu 16.04和我安装collectd与apt-get install collectd它精美安装collectd版本5.5.1对我来说(这是我想要的)
无论如何,当我运行容器,并做ps aux我看到
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.6 0.0 18180 2000 ? Ss 20:27 0:00 bash root 11 0.0 0.0 34364 1544 ? R+ 20:27 0:00 ps aux
所以基本上collectd仍然没有运行
和容器内我开始与service collectd start ,它工作正常
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 18180 2008 ? Ss 20:27 0:00 bash root 27 0.0 0.0 4300 320 ? Ss 20:27 0:00 /usr/sbin/collectdmon -P /var/run/collectd.pid -- -C /etc/collectd root 30 0.0 0.0 799820 2368 ? Sl 20:27 0:00 collectd -C /etc/collectd/collectd.conf -f root 42 0.0 0.0 34364 1544 ? R+ 20:30 0:00 ps aux
那么基本上,如何在运行docker镜像时自动运行collectd?
PS即使我不必使用supervisrod,罚款我只是想要一个方法让我运行容器collectd运行
谢谢
更新:在容器内部运行的单个collectd命令也会启动collectd
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 18180 2020 ? Ss 21:09 0:00 bash root 36 0.0 0.0 799820 1680 ? Ssl 21:10 0:00 collectd root 47 0.0 0.0 34364 1544 ? R+ 21:10 0:00 ps aux
collectd的容器不需要主pipe。
例如,您创build了名为“my_collectd:latest”的映像,那么您需要运行以下命令:
docker run -d --name my_test my_collectd:latest collectd -f
这将创build名为“my_test”的守护进程模式的容器。 它应该在里面运行collectd -f命令。