AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 790132
Accepted
uberrebu
uberrebu
Asked: 2016-07-16 12:56:03 +0800 CST2016-07-16 12:56:03 +0800 CST 2016-07-16 12:56:03 +0800 CST

我如何在 docker 中开始收集?

  • 772

我正在尝试在docker中启动collectd,我已经尝试了从运行命令到在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
docker collectd supervisord
  • 1 1 个回答
  • 1615 Views

1 个回答

  • Voted
  1. Best Answer
    Navern
    2016-07-19T11:15:42+08:002016-07-19T11:15:42+08:00

    您不需要带有 collectd 的容器的主管。

    例如,您创建了名为“my_collectd:latest”的图像,那么您需要运行以下命令:

    docker run -d --name my_test my_collectd:latest collectd -f

    这将在守护进程模式下创建名为“my_test”的容器。它应该在里面运行 collectd -f 命令。

    • 2

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve