blob: f1d4ce5de524bbaf92ae7121737ffc79bf06a831 (
plain)
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
|
#!/bin/sh
#
# Author: Petter Reinholdtsen
set -e
nodes=/usr/sbin/sitesummary-nodes
muninopts=""
# Modify this in collector.cfg to /etc/munin/ to automatically replace
# the default munin configuration.
MUNINDIR=/var/lib/sitesummary
if [ -d /var/cache/munin/www ] ; then
# Used since munin version 1.4.0-1
muninhtmldir="/var/cache/munin/www"
else
muninhtmldir="/var/www/munin"
fi
# Based on of active config from munin version 1.2.5-1
munindbdir=/var/lib/munin
muninlogdir=/var/log/munin
muninrundir=/var/run/munin
munintmpldir=/etc/munin/templates
[ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg
# The storage area is not configurable, because too many scripts have
# it hardcoded
entriesdir=/var/lib/sitesummary/entries
generate_munin_config() {
# Generate munin config. Edit /etc/cron.d/munin to enable it.
# Add -c /var/lib/sitesummary/sitesummary-munin.conf to the calls
# to the munin scripts, or change MUNINDIR above.
(
if [ -f $MUNINDIR/munin.conf.pre ] ; then
cat $MUNINDIR/munin.conf.pre
else
cat <<EOF
# Munin server configuration generated from cron using sitesummary
# data by $0
# Do not edit, it will be overwritten.
# Edit $MUNINDIR/munin.conf.pre and
# $MUNINDIR/munin.conf.post instead.
dbdir $munindbdir
htmldir $muninhtmldir
logdir $muninlogdir
rundir $muninrundir
tmpldir $munintmpldir
EOF
# Munin supports the includedir statement since Squeeze
muninver=$(dpkg -l munin|grep munin|awk '{print $3}')
if dpkg --compare-versions "1.4.5" le "$muninver" ; then
cat <<EOF
# (Exactly one) directory to include all files from.
#
includedir /etc/munin/munin-conf.d
EOF
fi
fi
$nodes -m $muninopts
[ -f $MUNINDIR/munin.conf.post ] && cat $MUNINDIR/munin.conf.post
# Make sure the subshell return true to trigger the mv below.
true
) > $MUNINDIR/munin.conf.new && \
chown root:root $MUNINDIR/munin.conf.new && \
chmod a+r $MUNINDIR/munin.conf.new && \
mv $MUNINDIR/munin.conf.new $MUNINDIR/munin.conf
}
# Only enable if munin and sitesummary is installed.
if [ -f /etc/munin/munin.conf ] && [ -x /usr/sbin/sitesummary-nodes ]; then
generate_munin_config
fi
|