Monitor group: grafana & graphite & collectd, collectd is member of group. Basic collectd-based server monitoring. Sends stats to Graphite.
With inspiration from pboos/docker-collectd-graphite. But not using python to replace the settings.
- CPU used/free/idle/etc
- Free disk (via mounting hosts '/' into container, eg: -v /:/hostfs:ro)
- Disk performance
- Load average
- Memory used/free/etc
- Uptime
- Network interface
- Swap
HOSTNAME
- Will be sent to Graphite
- Required
GRAPHITE_HOST
- Graphite IP or hostname
- Required
GRAPHITE_PORT
- Graphite port
- Optional, defaults to 2003
GRAPHITE_PREFIX
- Graphite prefix
- Optional, defaults to collectd.
REPORT_BY_CPU
- Report per-CPU metrics if true, global sum of CPU metrics if false (details: collectd.conf man page)
- Optional, defaults to false.
INTERVAL
- Controls how often registered read functions are called and with that the resolution of the collected data. (details: collectd.conf man page)
- Optional, defaults to 10.
run command, replace HOSTNAME GRAPHITE_HOST correct with your server.
#!/bin/bash
#
# Created by William Guozi
#
# 获取镜像地址
DOCKER_IMAGE="${1:-williamguozi/collectd:latest}"
# 判断容器是否存在,并将其删除
docker pull $DOCKER_IMAGE && \
docker ps -a | awk -F' ' '{print $NF}' | grep "devops-collectd" && \
docker stop devops-collectd && \
docker rm -f "devops-collectd" || \
echo "Image $image_url pull failed or No container devops-collectd."
# 启动容器
docker run -d \
--cpus 1 \
-m 1G \
-e HOSTNAME=servername \
-e GRAPHITE_PREFIX=collectd \
-e GRAPHITE_PORT=2003 \
-e GRAPHITE_HOST=locahost \
-e REPORT_BY_CPU=false \
-e INTERVAL=10 \
--privileged \
--restart always \
-v /:/hostfs:ro \
--name devops-collectd \
$DOCKER_IMAGE
or run command, use your customize config file
#!/bin/bash
#
# Created by William Guozi
#
# 获取镜像地址
DOCKER_IMAGE="${1:-williamguozi/collectd:latest}"
# 判断容器是否存在,并将其删除
docker pull $DOCKER_IMAGE && \
docker ps -a | awk -F' ' '{print $NF}' | grep "devops-collectd" && \
docker stop devops-collectd && \
docker rm -f "devops-collectd" || \
echo "Image $image_url pull failed or No container devops-collectd."
# 启动容器
docker run -d \
--cpus 1 \
-m 1G \
--privileged \
--restart always \
-v /:/hostfs:ro \
-v /opt/devops-collectd/collectd.conf:/etc/collectd/collectd.conf \
--name devops-collectd \
$DOCKER_IMAGE