diff options
Diffstat (limited to 'sitesummary-update-munin')
-rwxr-xr-x | sitesummary-update-munin | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sitesummary-update-munin b/sitesummary-update-munin new file mode 100755 index 0000000..e94f23e --- /dev/null +++ b/sitesummary-update-munin @@ -0,0 +1,60 @@ +#!/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 + +[ -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 + # Copy of active config from munin version 1.2.5-1 + 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 /var/lib/munin +htmldir /var/www/munin +logdir /var/log/munin +rundir /var/run/munin +tmpldir /etc/munin/templates + +EOF + 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 |