#!/bin/sh # # Author: Petter Reinholdtsen set -e daylimit=120 makewebreport=/usr/sbin/sitesummary-makewebreport nodes=/usr/sbin/sitesummary-nodes # Modify this in collector.cfg to /etc/munin/ to automatically replace # the default munin configuration. MUNINDIR=/var/lib/sitesummary # Specifies where to save the automatically generated nagios # configuration. Add NAGIOSCFG="/etc/nagios3/sitesummary.cfg" to # /etc/default/nagios3 toget Nagios to use this automatically # generated configuration NAGIOSDIR=/var/lib/sitesummary [ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg # Exit imediately if the package is removed but nor purged if [ ! -x $nodes ] ; then exit 0 fi # The storage area is not configurable, because too many scripts have # it hardcoded entriesdir=/var/lib/sitesummary/entries remove_old_entries() { find $entriesdir/. -mindepth 1 -maxdepth 1 -type d \ -daystart -mtime +$daylimit \ -exec /usr/lib/sitesummary/expire-entry '{}' \; } 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 < $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 } generate_nagios_config() { ( printf "# Generated "; date sitesummary-nodes -n if [ -f $NAGIOSDIR/nagios-generated.cfg.post ] ; then cat $NAGIOSDIR/nagios-generated.cfg.post fi true ) > $NAGIOSDIR/nagios-generated.cfg.new && \ chmod a+r $NAGIOSDIR/nagios-generated.cfg.new && \ mv $NAGIOSDIR/nagios-generated.cfg.new $NAGIOSDIR/nagios-generated.cfg } # Only enable if munin and sitesummary is installed. if [ -f /etc/munin/munin.conf ] && [ -x /usr/sbin/sitesummary-nodes ]; then generate_munin_config fi # Only enable if nagios v3 and sitesummary is installed. if [ -f /etc/init.d/nagios3 ] && [ -x /usr/sbin/sitesummary-nodes ]; then generate_nagios_config invoke-rc.d nagios3 reload fi [ -d $entriesdir ] && remove_old_entries # Update the web report once a day [ -x $makewebreport ] && nice $makewebreport