File: sitesummary-update-munin

package info (click to toggle)
sitesummary 0.1.60
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 584 kB
  • sloc: perl: 1,929; sh: 800; makefile: 86
file content (55 lines) | stat: -rwxr-xr-x 1,571 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# Author: Petter Reinholdtsen

set -e

umask 022

nodes=/usr/sbin/sitesummary-nodes
muninopts=""

# Set MUNINDIR in collector.cfg to /etc/munin/ to automatically add hosts to
# the default munin configuration via include files.
[ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg

# Default to /var/lib/sitesummary and canonicalize path.
MUNINDIR="$(realpath -mqs "${MUNINDIR:-/var/lib/sitesummary}")"

# 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/munin.conf to the calls to the munin scripts,
    # or change MUNINDIR as described above.

    mkdir -p "${MUNINDIR}/munin-conf.d"
    chmod a+rx "${MUNINDIR}/munin-conf.d"

    if [ ! -f "${MUNINDIR}/munin.conf" ]; then
        cat > "${MUNINDIR}/munin.conf" <<EOF
# (Exactly one) directory to include all files from.
#
includedir "${MUNINDIR}/munin-conf.d"
EOF
        chown root:root "${MUNINDIR}/munin.conf"
    fi

    (
        cat <<EOF
# Munin server configuration generated from cron using sitesummary
# data by $0
# Do not edit, it will be overwritten.
EOF

        $nodes -m $muninopts
    ) >"${MUNINDIR}/munin-conf.d/sitesummary.conf" &&
        chown root:root "${MUNINDIR}/munin-conf.d/sitesummary.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