forked from aheimsbakk/container-munin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-cmd.sh
executable file
·76 lines (60 loc) · 1.91 KB
/
docker-cmd.sh
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
#!/bin/bash
set -eu
echo "Munin for Docker v$(</run/version)..."
NODES="${NODES:-}"
# Set timezone
if ! [[ ! -z "$TZ" && -f "/usr/share/zoneinfo/$TZ" ]]; then
TZ="UTC"
fi
cp "/usr/share/zoneinfo/$TZ" /etc/localtime
echo "$TZ" > /etc/timezone
# Make directories before setting permissions
mkdir -p /run/munin
mkdir -p /var/log/munin
mkdir -p /var/lib/munin/cgi-tmp
# Fix ownership
chown munin:munin \
/var/log/munin /run/munin /var/lib/munin /var/lib/munin/cgi-tmp \
/etc/munin/munin-conf.d /etc/munin/plugin-conf.d
chmod 755 /usr/share/webapps/munin/html
chown -R munin:munin /usr/share/webapps/munin/html
# Prepare for rrdcached
sudo -u munin -- mkdir -p /var/lib/munin/rrdcached-journal
chown munin:munin /var/lib/munin/rrdcached-journal
# Start rrdcached
sudo -u munin -- /usr/sbin/rrdcached \
-p /run/munin/rrdcached.pid \
-B -b /var/lib/munin/ \
-F -j /var/lib/munin/rrdcached-journal/ \
-m 0660 -l unix:/run/munin/rrdcached.sock \
-w 1800 -z 1800 -f 3600
# Generate node list
[[ ! -z "$NODES" ]] && for NODE in $NODES
do
NAME=`echo "$NODE" | cut -d ":" -f1`
HOST=`echo "$NODE" | cut -d ":" -f2`
PORT=`echo "$NODE" | cut -d ":" -f3`
if [ ${#PORT} -eq 0 ]; then
PORT=4949
fi
if ! grep -q "$HOST" /etc/munin/munin-conf.d/nodes.conf 2>/dev/null ; then
cat << EOF >> /etc/munin/munin-conf.d/nodes.conf
[$NAME]
address $HOST
use_node_name yes
port $PORT
EOF
fi
done
# Run once before we start fcgi
sudo -u munin -- /usr/bin/munin-cron munin
# Spawn fast cgi process for generating graphs on the fly
spawn-fcgi -s /var/run/munin/fastcgi-graph.sock -U nginx -u munin -g munin -- \
/usr/share/webapps/munin/cgi/munin-cgi-graph
# Spawn fast cgi process for generating html on the fly
spawn-fcgi -s /var/run/munin/fastcgi-html.sock -U nginx -u munin -g munin -- \
/usr/share/webapps/munin/cgi/munin-cgi-html
# Munin and logrotate runs in cron, start cron
crond
# Start web-server
nginx