diff options
Diffstat (limited to 'debian/sitesummary.cron.daily')
-rwxr-xr-x | debian/sitesummary.cron.daily | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/debian/sitesummary.cron.daily b/debian/sitesummary.cron.daily index bb8dbc7..e3ed7cc 100755 --- a/debian/sitesummary.cron.daily +++ b/debian/sitesummary.cron.daily @@ -2,12 +2,19 @@ # # Author: Petter Reinholdtsen +set -e + daylimit=120 makewebreport=/usr/sbin/sitesummary-makewebreport +# 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 +# The storage area is not configurable, because too many scripts have +# it hardcoded entriesdir=/var/lib/sitesummary/entries remove_old_entries() { @@ -16,6 +23,48 @@ remove_old_entries() { xargs -0 -r rm -rf } +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 + + sitesummary-nodes -m + + [ -f $MUNINDIR/munin.conf.pre ] && 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 is installed. +if [ -f /etc/munin/munin.conf ] ; then + generate_munin_config +fi + [ -d $entriesdir ] && remove_old_entries # Update the web report once a day |