diff options
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | debian/changelog | 7 | ||||
-rwxr-xr-x | debian/sitesummary.cron.daily | 97 | ||||
-rw-r--r-- | debian/sitesummary.install | 2 | ||||
-rwxr-xr-x | sitesummary-update-munin | 60 | ||||
-rwxr-xr-x | sitesummary-update-nagios | 65 |
6 files changed, 143 insertions, 97 deletions
@@ -1,13 +1,13 @@ DESTDIR = prefix = /usr -sbindir = $(prefix)/sbin +sbindir = $(prefix)/sbin datadir = $(prefix)/share libdir = $(prefix)/lib cgibindir = $(libdir)/cgi-bin pkgdatadir = $(datadir)/sitesummary pkgdir = $(libdir)/sitesummary -collectordir = $(libdir)/sitesummary/collect.d +collectordir = $(pkgdir)/collect.d perldir = $(datadir)/perl5 pkgvardir = /var/lib/sitesummary @@ -38,8 +38,9 @@ install-server: $(INSTALL) sitesummary-collector.cgi $(DESTDIR)$(cgibindir) $(INSTALL) -d $(DESTDIR)$(sbindir) - $(INSTALL) sitesummary-makewebreport $(DESTDIR)$(sbindir) - $(INSTALL) sitesummary-nodes $(DESTDIR)$(sbindir) + for f in sitesummary-makewebreport sitesummary-nodes sitesummary-update-munin sitesummary-update-nagios ; do \ + $(INSTALL) $$f $(DESTDIR)$(sbindir) ; \ + done $(INSTALL) -d $(DESTDIR)$(perldir) $(INSTALL) -d $(DESTDIR)$(pkgdir) diff --git a/debian/changelog b/debian/changelog index 7ddaa83..81fcbc1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +sitesummary (0.0.59) UNRELEASED; urgency=low + + * Restructure cron job, move munin and nagios updating code to + separate scripts to make it possible to update them individually. + + -- Petter Reinholdtsen <pere@debian.org> Tue, 26 Jan 2010 08:56:53 +0100 + sitesummary (0.0.58) unstable; urgency=low * Ignore entries from host failing to report MAC address, and log this diff --git a/debian/sitesummary.cron.daily b/debian/sitesummary.cron.daily index ae74ba3..bc7022d 100755 --- a/debian/sitesummary.cron.daily +++ b/debian/sitesummary.cron.daily @@ -7,18 +7,6 @@ set -e daylimit=120 makewebreport=/usr/sbin/sitesummary-makewebreport nodes=/usr/sbin/sitesummary-nodes -muninopts="" -nagiosopts="" - -# 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 @@ -37,89 +25,12 @@ remove_old_entries() { -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 <<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 $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 -} - -generate_nagios_config() { - ( - sitesummary-nodes -n $nagiosopts - - 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 - if [ ! -s $NAGIOSDIR/nagios-generated.cfg.new ] || \ - cmp -s $NAGIOSDIR/nagios-generated.cfg.new \ - $NAGIOSDIR/nagios-generated.cfg - then - rm $NAGIOSDIR/nagios-generated.cfg.new - false - else - mv $NAGIOSDIR/nagios-generated.cfg.new $NAGIOSDIR/nagios-generated.cfg - true - fi -} - -# Only enable if munin and sitesummary is installed. -if [ -f /etc/munin/munin.conf ] && [ -x /usr/sbin/sitesummary-nodes ]; then - generate_munin_config +if [ -x /usr/sbin/sitesummary-update-nagios ] ; then + /usr/sbin/sitesummary-update-nagios fi -# Only enable if nagios v3 and sitesummary is installed. -if [ -f /etc/init.d/nagios3 ] && [ -x /usr/sbin/sitesummary-nodes ]; then - # Only reload nagios if the configuration changed - if generate_nagios_config ; then - # subshell to avoid passing all variables from - # /etc/default/nagios3 to other parts of this script - ( - if [ -r /etc/default/nagios3 ] ; then - . /etc/default/nagios3 - fi - # Only reload nagios if the sitesummary config is the active - # one and nagios3 is currently running. - if [ /etc/nagios3/sitesummary.cfg = "$NAGIOSCFG" ] && \ - invoke-rc.d nagios3 status >/dev/null ; then - invoke-rc.d nagios3 reload >/dev/null - fi - ) - fi +if [ -x /usr/sbin/sitesummary-update-munin ] ; then + /usr/sbin/sitesummary-update-munin fi [ -d $entriesdir ] && remove_old_entries diff --git a/debian/sitesummary.install b/debian/sitesummary.install index e8e02b4..71c26e3 100644 --- a/debian/sitesummary.install +++ b/debian/sitesummary.install @@ -5,6 +5,8 @@ debian/tmp/usr/lib/sitesummary/*-summary debian/tmp/usr/lib/sitesummary/expire-entry debian/tmp/usr/sbin/sitesummary-makewebreport debian/tmp/usr/sbin/sitesummary-nodes +debian/tmp/usr/sbin/sitesummary-update-munin +debian/tmp/usr/sbin/sitesummary-update-nagios debian/tmp/usr/share/munin/plugins debian/tmp/usr/share/perl5 debian/tmp/var/lib/sitesummary 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 diff --git a/sitesummary-update-nagios b/sitesummary-update-nagios new file mode 100755 index 0000000..96db4ee --- /dev/null +++ b/sitesummary-update-nagios @@ -0,0 +1,65 @@ +#!/bin/sh +# +# Author: Petter Reinholdtsen + +set -e + +nodes=/usr/sbin/sitesummary-nodes +nagiosopts="" + +# Specifies where to save the automatically generated nagios +# configuration. Add NAGIOSCFG="/etc/nagios3/sitesummary.cfg" to +# /etc/default/nagios3 to get Nagios to use this automatically +# generated configuration +NAGIOSDIR=/var/lib/sitesummary + +if [ -f /etc/sitesummary/collector.cfg ] ; then + . /etc/sitesummary/collector.cfg +fi + +# The storage area is not configurable, because too many scripts have +# it hardcoded +entriesdir=/var/lib/sitesummary/entries + +generate_nagios_config() { + ( + $nodes -n $nagiosopts + + 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 + if [ ! -s $NAGIOSDIR/nagios-generated.cfg.new ] || \ + cmp -s $NAGIOSDIR/nagios-generated.cfg.new \ + $NAGIOSDIR/nagios-generated.cfg + then + rm $NAGIOSDIR/nagios-generated.cfg.new + false + else + mv $NAGIOSDIR/nagios-generated.cfg.new $NAGIOSDIR/nagios-generated.cfg + true + fi +} + +# Only enable if nagios v3 and sitesummary is installed. +if [ -f /etc/init.d/nagios3 ] && [ -x $nodes ]; then + # Only reload nagios if the configuration changed + if generate_nagios_config ; then + # subshell to avoid passing all variables from + # /etc/default/nagios3 to other parts of this script + ( + if [ -r /etc/default/nagios3 ] ; then + . /etc/default/nagios3 + fi + # Only reload nagios if the sitesummary config is the active + # one and nagios3 is currently running. + if [ /etc/nagios3/sitesummary.cfg = "$NAGIOSCFG" ] && \ + invoke-rc.d nagios3 status >/dev/null ; then + invoke-rc.d nagios3 reload >/dev/null + fi + ) + fi +fi |