Skip to content

Instantly share code, notes, and snippets.

@motiejus
Created November 18, 2014 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motiejus/635863db7a4b7ebd389f to your computer and use it in GitHub Desktop.
Save motiejus/635863db7a4b7ebd389f to your computer and use it in GitHub Desktop.
graphite server on CoreOS (userdata script)
#!/bin/bash
# Begin graphite.service
set -euo pipefail
cat > /etc/systemd/system/graphite.service <<EOF
[Unit]
Description=graphite server
After=docker.service
Requires=docker.service
[Service]
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin \
ibuildthecloud/systemd-docker
ExecStartPre=mkdir -p /storage && chmod 777 /storage
ExecStartPre=/bin/sh -c '[ ! -f /storage/graphite.db ] && \
/usr/bin/docker run --rm -v /storage/:/mnt/ \
cdegroot/collectd-graphite:1.0 cp -a /opt/graphite/storage/. /mnt || :'
ExecStart=/opt/bin/systemd-docker run --net=host \
-v /storage/:/opt/graphite/storage/ \
--rm --name %n cdegroot/collectd-graphite:1.0
Restart=always
RestartSec=10s
Type=notify
NotifyAccess=all
TimeoutStartSec=600
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target
EOF
systemctl enable graphite.service
systemctl start graphite.service
# End graphite.service
#!/bin/bash
# Begin graphite-write.service
set -euo pipefail
cat > /etc/systemd/system/graphite-write.service <<EOF
[Unit]
Description=write stats to graphite
After=docker.service
Requires=docker.service
[Service]
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
ExecStart=/opt/bin/systemd-docker run \
--net=host \
--env HOST_NAME=%H --env GRAPHITE_HOST=127.0.0.1 \
--rm --name %n andreasjansson/collectd-write-graphite
Restart=always
RestartSec=10s
Type=notify
NotifyAccess=all
TimeoutStartSec=600
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target
EOF
systemctl enable graphite-write.service
systemctl start graphite-write.service
# End graphite-write.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment