mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
docker(): added collectd system metrics collector that writes to graphite, just for testing
This commit is contained in:
parent
cf87e8ecf5
commit
ca8543348b
16
docker/blocks/collectd/Dockerfile
Normal file
16
docker/blocks/collectd/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM ubuntu:xenial
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-get -y update
|
||||
RUN apt-get -y install collectd curl python-pip
|
||||
|
||||
# add a fake mtab for host disk stats
|
||||
ADD etc_mtab /etc/mtab
|
||||
|
||||
ADD collectd.conf.tpl /etc/collectd/collectd.conf.tpl
|
||||
|
||||
RUN pip install envtpl
|
||||
ADD start_container /usr/bin/start_container
|
||||
RUN chmod +x /usr/bin/start_container
|
||||
CMD start_container
|
37
docker/blocks/collectd/README.md
Normal file
37
docker/blocks/collectd/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
collectd-write-graphite
|
||||
=======================
|
||||
|
||||
Basic collectd-based server monitoring. Sends stats to Graphite.
|
||||
|
||||
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
|
||||
---------------------
|
||||
|
||||
* `HOST_NAME`
|
||||
- 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.
|
||||
* `COLLECT_INTERVAL`
|
||||
- Collection interval and thus resolution of metrics
|
||||
- Optional, defaults to 10
|
76
docker/blocks/collectd/collectd.conf.tpl
Normal file
76
docker/blocks/collectd/collectd.conf.tpl
Normal file
@ -0,0 +1,76 @@
|
||||
Hostname "{{ HOST_NAME }}"
|
||||
|
||||
FQDNLookup false
|
||||
Interval {{ COLLECT_INTERVAL | default("10") }}
|
||||
Timeout 2
|
||||
ReadThreads 5
|
||||
|
||||
LoadPlugin cpu
|
||||
LoadPlugin df
|
||||
LoadPlugin load
|
||||
LoadPlugin memory
|
||||
LoadPlugin disk
|
||||
LoadPlugin interface
|
||||
LoadPlugin uptime
|
||||
LoadPlugin swap
|
||||
LoadPlugin write_graphite
|
||||
|
||||
<Plugin cpu>
|
||||
ReportByCpu {{ REPORT_BY_CPU | default("false") }}
|
||||
</Plugin>
|
||||
|
||||
<Plugin df>
|
||||
# expose host's mounts into container using -v /:/host:ro (location inside container does not matter much)
|
||||
# ignore rootfs; else, the root file-system would appear twice, causing
|
||||
# one of the updates to fail and spam the log
|
||||
FSType rootfs
|
||||
# ignore the usual virtual / temporary file-systems
|
||||
FSType sysfs
|
||||
FSType proc
|
||||
FSType devtmpfs
|
||||
FSType devpts
|
||||
FSType tmpfs
|
||||
FSType fusectl
|
||||
FSType cgroup
|
||||
FSType overlay
|
||||
FSType debugfs
|
||||
FSType pstore
|
||||
FSType securityfs
|
||||
FSType hugetlbfs
|
||||
FSType squashfs
|
||||
FSType mqueue
|
||||
MountPoint "/etc/resolv.conf"
|
||||
MountPoint "/etc/hostname"
|
||||
MountPoint "/etc/hosts"
|
||||
IgnoreSelected true
|
||||
ReportByDevice false
|
||||
ReportReserved true
|
||||
ReportInodes true
|
||||
</Plugin>
|
||||
|
||||
<Plugin "disk">
|
||||
Disk "/^[hs]d[a-z]/"
|
||||
IgnoreSelected false
|
||||
</Plugin>
|
||||
|
||||
|
||||
<Plugin interface>
|
||||
Interface "lo"
|
||||
Interface "/^veth.*/"
|
||||
Interface "/^docker.*/"
|
||||
IgnoreSelected true
|
||||
</Plugin>
|
||||
|
||||
|
||||
<Plugin "write_graphite">
|
||||
<Carbon>
|
||||
Host "{{ GRAPHITE_HOST }}"
|
||||
Port "{{ GRAPHITE_PORT | default("2003") }}"
|
||||
Prefix "{{ GRAPHITE_PREFIX | default("collectd.") }}"
|
||||
EscapeCharacter "_"
|
||||
SeparateInstances true
|
||||
StoreRates true
|
||||
AlwaysAppendDS false
|
||||
</Carbon>
|
||||
</Plugin>
|
||||
|
1
docker/blocks/collectd/etc_mtab
Normal file
1
docker/blocks/collectd/etc_mtab
Normal file
@ -0,0 +1 @@
|
||||
hostfs /.dockerinit ext4 ro,relatime,user_xattr,barrier=1,data=ordered 0 0
|
11
docker/blocks/collectd/fig
Normal file
11
docker/blocks/collectd/fig
Normal file
@ -0,0 +1,11 @@
|
||||
collectd:
|
||||
build: blocks/collectd
|
||||
environment:
|
||||
HOST_NAME: myserver
|
||||
GRAPHITE_HOST: graphite
|
||||
GRAPHITE_PORT: 2003
|
||||
GRAPHITE_PREFIX: collectd.
|
||||
REPORT_BY_CPU: 'false'
|
||||
COLLECT_INTERVAL: 10
|
||||
links:
|
||||
- graphite
|
5
docker/blocks/collectd/start_container
Normal file
5
docker/blocks/collectd/start_container
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
envtpl /etc/collectd/collectd.conf.tpl
|
||||
|
||||
collectd -f
|
Loading…
Reference in New Issue
Block a user