-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md
103 lines (88 loc) · 2.7 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# collectd
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](https://github.com/pboos/docker-collectd-graphite). But not using python to replace the settings.
## Collectd metrics
* 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
## Environment variables
* `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](https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_cpu))
- 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](https://collectd.org/wiki/index.php/Interval))
- Optional, defaults to 10.
## Example execution
> run command, replace HOSTNAME GRAPHITE_HOST correct with your server.
```bash
#!/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
```bash
#!/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
```