From 75ea3dcbd8ad5baa6fc2cf734666a2ab3ba3cd55 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Mon, 24 Nov 2008 21:48:07 -0500 Subject: [PATCH 1/1] Initial checkin of xvm-munin-config package svn path=/trunk/packages/xvm-munin-config/; revision=1761 --- TODO | 2 + common/etc/munin/plugin-conf.d/postfix | 10 ++ debian/changelog | 5 + debian/compat | 1 + debian/control | 44 +++++ debian/copyright | 17 ++ debian/rules | 24 +++ debian/transform_munin-node.conf.xvm.mako | 26 +++ debian/xvm-munin-console-config.init | 19 +++ debian/xvm-munin-console-config.install | 2 + debian/xvm-munin-console-config.postinst | 54 ++++++ debian/xvm-munin-console-config.prerm | 41 +++++ debian/xvm-munin-host-config.init | 19 +++ debian/xvm-munin-host-config.install | 3 + debian/xvm-munin-host-config.postinst | 55 ++++++ debian/xvm-munin-host-config.prerm | 41 +++++ debian/xvm-munin-master-config.init | 19 +++ debian/xvm-munin-master-config.install | 3 + debian/xvm-munin-master-config.postinst | 64 +++++++ debian/xvm-munin-master-config.prerm | 41 +++++ debian/xvm-munin-remote-config.init | 41 +++++ debian/xvm-munin-remote-config.install | 3 + debian/xvm-munin-remote-config.postinst | 54 ++++++ debian/xvm-munin-remote-config.prerm | 41 +++++ host/etc/munin/plugin-conf.d/hddtemp_smartctl | 4 + host/etc/munin/plugin-conf.d/smart | 3 + master/etc/munin/plugin-conf.d/postgres | 2 + .../etc/munin/plugins/postgres_block_read_invirt | 1 + master/etc/munin/plugins/postgres_connections | 1 + master/etc/munin/plugins/postgres_locks | 1 + master/etc/munin/plugins/postgres_space_invirt | 1 + .../plugins/postgres_block_read_ | 165 ++++++++++++++++++ .../plugins/postgres_connections | 44 +++++ .../xvm-munin-master-config/plugins/postgres_locks | 77 +++++++++ .../plugins/postgres_space_ | 176 ++++++++++++++++++++ remote/etc/munin/plugins/loggrep_remctl | 1 + .../xvm-munin-remote-config/loggrep_remctl.mako | 16 ++ 37 files changed, 1121 insertions(+) create mode 100644 TODO create mode 100644 common/etc/munin/plugin-conf.d/postfix create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100755 debian/transform_munin-node.conf.xvm.mako create mode 100755 debian/xvm-munin-console-config.init create mode 100644 debian/xvm-munin-console-config.install create mode 100755 debian/xvm-munin-console-config.postinst create mode 100755 debian/xvm-munin-console-config.prerm create mode 100755 debian/xvm-munin-host-config.init create mode 100644 debian/xvm-munin-host-config.install create mode 100755 debian/xvm-munin-host-config.postinst create mode 100755 debian/xvm-munin-host-config.prerm create mode 100755 debian/xvm-munin-master-config.init create mode 100644 debian/xvm-munin-master-config.install create mode 100755 debian/xvm-munin-master-config.postinst create mode 100755 debian/xvm-munin-master-config.prerm create mode 100755 debian/xvm-munin-remote-config.init create mode 100644 debian/xvm-munin-remote-config.install create mode 100755 debian/xvm-munin-remote-config.postinst create mode 100755 debian/xvm-munin-remote-config.prerm create mode 100644 host/etc/munin/plugin-conf.d/hddtemp_smartctl create mode 100644 host/etc/munin/plugin-conf.d/smart create mode 100644 master/etc/munin/plugin-conf.d/postgres create mode 120000 master/etc/munin/plugins/postgres_block_read_invirt create mode 120000 master/etc/munin/plugins/postgres_connections create mode 120000 master/etc/munin/plugins/postgres_locks create mode 120000 master/etc/munin/plugins/postgres_space_invirt create mode 100755 master/usr/share/xvm-munin-master-config/plugins/postgres_block_read_ create mode 100755 master/usr/share/xvm-munin-master-config/plugins/postgres_connections create mode 100755 master/usr/share/xvm-munin-master-config/plugins/postgres_locks create mode 100755 master/usr/share/xvm-munin-master-config/plugins/postgres_space_ create mode 120000 remote/etc/munin/plugins/loggrep_remctl create mode 100644 remote/usr/share/xvm-munin-remote-config/loggrep_remctl.mako diff --git a/TODO b/TODO new file mode 100644 index 0000000..a9e1183 --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ +Track incoming connections on console +Track CPU utilization on the hosts diff --git a/common/etc/munin/plugin-conf.d/postfix b/common/etc/munin/plugin-conf.d/postfix new file mode 100644 index 0000000..6f5b41d --- /dev/null +++ b/common/etc/munin/plugin-conf.d/postfix @@ -0,0 +1,10 @@ +[postfix_mailqueue] +user munin +command sudo -u postfix -E %c + +[postfix_mailvolume] +user munin +command sudo -u munin -E %c + +env.logfile mail.log +env.logdir /var/log diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..a2f14fe --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +xvm-munin-config (0.0.1) unstable; urgency=low + + * Initial Release. + + -- Evan Broder Sat, 22 Nov 2008 05:52:10 -0500 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..de5f717 --- /dev/null +++ b/debian/control @@ -0,0 +1,44 @@ +Source: xvm-munin-config +Section: servers +Priority: extra +Maintainer: SIPB XVM Project +Build-Depends: cdbs, debhelper (>= 5), config-package-dev, munin-node +Standards-Version: 3.7.2 + +Package: xvm-munin-host-config +Architecture: all +Pre-Depends: smartmontools +Depends: ${shlibs:Depends}, ${misc:Depends}, munin-node, adduser +Description: Configure Munin monitoring on XVM hosts + Configure the munin-node daemon on all XVM servers. Each server gets + a set of plugins configured based on its function. + . + This package configures Munin on the XVM hosts + +Package: xvm-munin-master-config +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, munin-node, adduser, libdbd-pg-perl +Description: Configure Munin monitoring on XVM master server + Configure the munin-node daemon on all XVM servers. Each server gets + a set of plugins configured based on its function. + . + This package configures Munin on the master (web and database) + server. + +Package: xvm-munin-remote-config +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, munin-node, adduser +Description: Configure Munin monitoring on XVM remote servers + Configure the munin-node daemon on all XVM servers. Each server gets + a set of plugins configured based on its function. + . + This package configures Munin on the remote (remctl) server. + +Package: xvm-munin-console-config +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, munin-node, adduser +Description: Configure Munin monitoring on XVM console server + Configure the munin-node daemon on all XVM servers. Each server gets + a set of plugins configured based on its function. + . + This package configures Munin on the console server. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..381dc35 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,17 @@ +This software was written for the XVM project +of the MIT Student Information Processing Board. + +Copyright : + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +On Debian systems, the complete text of the GNU General Public License +can be found in the file /usr/share/common-licenses/GPL. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..e9fbe1e --- /dev/null +++ b/debian/rules @@ -0,0 +1,24 @@ +#!/usr/bin/make -f + +DEB_DIVERT_EXTENSION = .xvm + +DEB_DIVERT_FILES_xvm-munin-host-config += \ + /etc/munin/munin-node.conf.xvm +DEB_DIVERT_FILES_xvm-munin-master-config += \ + /etc/munin/munin-node.conf.xvm +DEB_DIVERT_FILES_xvm-munin-remote-config += \ + /etc/munin/munin-node.conf.xvm +DEB_DIVERT_FILES_xvm-munin-console-config += \ + /etc/munin/munin-node.conf.xvm + +include /usr/share/cdbs/1/rules/config-package.mk +include /usr/share/cdbs/1/rules/debhelper.mk + +common-build-indep:: debian/munin-node.conf.xvm.mako + +binary-post-install/%:: + mkdir -p $(DEB_DESTDIR)/etc/munin + touch $(DEB_DESTDIR)/etc/munin/munin-node.conf.xvm + +debian/munin-node.conf.xvm.mako: $(call debian_check_files,/etc/munin/munin-node.conf) + debian/transform_munin-node.conf.xvm.mako < $< > $@ diff --git a/debian/transform_munin-node.conf.xvm.mako b/debian/transform_munin-node.conf.xvm.mako new file mode 100755 index 0000000..2572e76 --- /dev/null +++ b/debian/transform_munin-node.conf.xvm.mako @@ -0,0 +1,26 @@ +#!/usr/bin/perl -n +BEGIN { + print <<'EOF'; +<% +from invirt.config import structs as cfg +%> +EOF +} + +s/^user root/user munin/m; +s/^group root/group munin/m; +s/^node.startup = manual/node.startup = automatic/m; +# mako just generally doesn't deal well with lines that start with +# hashes, so we'll strip them +# +# And empty lines too, just for cleanliness +s/^#.*$//m; +print unless /^$/; + +END { + print <<'EOF'; +% for host in cfg.monitoring: +allow ^${host.ip.replace('.', '\.')}$ +% endfor +EOF +} diff --git a/debian/xvm-munin-console-config.init b/debian/xvm-munin-console-config.init new file mode 100755 index 0000000..0183687 --- /dev/null +++ b/debian/xvm-munin-console-config.init @@ -0,0 +1,19 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: xvm-munin-console-config +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: XVM Munin config +# Description: +### END INIT INFO + +PACKAGE=xvm-munin-console-config +PARENTPACKAGE=munin-node +GEN_FILES=/etc/munin/munin-node.conf.xvm + +dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0 + +. /lib/init/config-init.sh +config_init "$1" diff --git a/debian/xvm-munin-console-config.install b/debian/xvm-munin-console-config.install new file mode 100644 index 0000000..c0d3211 --- /dev/null +++ b/debian/xvm-munin-console-config.install @@ -0,0 +1,2 @@ +common/* . +debian/munin-node.conf.xvm.mako etc/munin diff --git a/debian/xvm-munin-console-config.postinst b/debian/xvm-munin-console-config.postinst new file mode 100755 index 0000000..e19832a --- /dev/null +++ b/debian/xvm-munin-console-config.postinst @@ -0,0 +1,54 @@ +#!/bin/sh +# postinst script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + # So munin can read the mail log + adduser munin adm + + # So munin can sudo to get to postfix queue info + cat >>/etc/sudoers <&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/xvm-munin-console-config.prerm b/debian/xvm-munin-console-config.prerm new file mode 100755 index 0000000..3306876 --- /dev/null +++ b/debian/xvm-munin-console-config.prerm @@ -0,0 +1,41 @@ +#!/bin/sh +# prerm script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + perl -i.bak -ne 's%^### (BEGIN|END) xvm-munin-config\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/xvm-munin-host-config.init b/debian/xvm-munin-host-config.init new file mode 100755 index 0000000..5bcd550 --- /dev/null +++ b/debian/xvm-munin-host-config.init @@ -0,0 +1,19 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: xvm-munin-host-config +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: XVM Munin config +# Description: +### END INIT INFO + +PACKAGE=xvm-munin-host-config +PARENTPACKAGE=munin-node +GEN_FILES=/etc/munin/munin-node.conf.xvm + +dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0 + +. /lib/init/config-init.sh +config_init "$1" diff --git a/debian/xvm-munin-host-config.install b/debian/xvm-munin-host-config.install new file mode 100644 index 0000000..f7790a8 --- /dev/null +++ b/debian/xvm-munin-host-config.install @@ -0,0 +1,3 @@ +common/* . +host/* . +debian/munin-node.conf.xvm.mako etc/munin diff --git a/debian/xvm-munin-host-config.postinst b/debian/xvm-munin-host-config.postinst new file mode 100755 index 0000000..5060710 --- /dev/null +++ b/debian/xvm-munin-host-config.postinst @@ -0,0 +1,55 @@ +#!/bin/sh +# postinst script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + # So munin can read the mail log + adduser munin adm + + # So munin can sudo to get to postfix queue info + cat >>/etc/sudoers <&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/xvm-munin-host-config.prerm b/debian/xvm-munin-host-config.prerm new file mode 100755 index 0000000..3306876 --- /dev/null +++ b/debian/xvm-munin-host-config.prerm @@ -0,0 +1,41 @@ +#!/bin/sh +# prerm script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + perl -i.bak -ne 's%^### (BEGIN|END) xvm-munin-config\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/xvm-munin-master-config.init b/debian/xvm-munin-master-config.init new file mode 100755 index 0000000..0b94ea4 --- /dev/null +++ b/debian/xvm-munin-master-config.init @@ -0,0 +1,19 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: xvm-munin-master-config +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: XVM Munin config +# Description: +### END INIT INFO + +PACKAGE=xvm-munin-master-config +PARENTPACKAGE=munin-node +GEN_FILES=/etc/munin/munin-node.conf.xvm + +dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0 + +. /lib/init/config-init.sh +config_init "$1" diff --git a/debian/xvm-munin-master-config.install b/debian/xvm-munin-master-config.install new file mode 100644 index 0000000..76012b2 --- /dev/null +++ b/debian/xvm-munin-master-config.install @@ -0,0 +1,3 @@ +common/* . +master/* . +debian/munin-node.conf.xvm.mako etc/munin diff --git a/debian/xvm-munin-master-config.postinst b/debian/xvm-munin-master-config.postinst new file mode 100755 index 0000000..721e584 --- /dev/null +++ b/debian/xvm-munin-master-config.postinst @@ -0,0 +1,64 @@ +#!/bin/sh +# postinst script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + # So munin can read the mail log + adduser munin adm + + # So munin can sudo to get to postfix queue info + cat >>/etc/sudoers <&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/xvm-munin-master-config.prerm b/debian/xvm-munin-master-config.prerm new file mode 100755 index 0000000..3306876 --- /dev/null +++ b/debian/xvm-munin-master-config.prerm @@ -0,0 +1,41 @@ +#!/bin/sh +# prerm script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + perl -i.bak -ne 's%^### (BEGIN|END) xvm-munin-config\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/xvm-munin-remote-config.init b/debian/xvm-munin-remote-config.init new file mode 100755 index 0000000..bc1c8d9 --- /dev/null +++ b/debian/xvm-munin-remote-config.init @@ -0,0 +1,41 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: xvm-munin-remote-config +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: XVM Munin config +# Description: +### END INIT INFO + +PACKAGE=xvm-munin-remote-config +PARENTPACKAGE=munin-node +GEN_FILES=/etc/munin/munin-node.conf.xvm + +dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0 + +. /lib/init/gen-files.sh +. /lib/init/std-init.sh + +do_start () { + gen_files + + mako-render /usr/share/xvm-munin-remote-config/loggrep_remctl.mako >/etc/munin/plugin-conf.d/loggrep_remctl + + for p in "${PARENTPACKAGE[@]}"; do + invoke-rc.d "$p" restart + done +} + +do_reload() { + do_start +} + +do_stop() { + for p in "${PARENTPACKAGE[@]}"; do + invoke-rc.d "$p" stop + done +} + +std_init "$1" diff --git a/debian/xvm-munin-remote-config.install b/debian/xvm-munin-remote-config.install new file mode 100644 index 0000000..4427faa --- /dev/null +++ b/debian/xvm-munin-remote-config.install @@ -0,0 +1,3 @@ +common/* . +remote/* . +debian/munin-node.conf.xvm.mako etc/munin diff --git a/debian/xvm-munin-remote-config.postinst b/debian/xvm-munin-remote-config.postinst new file mode 100755 index 0000000..e19832a --- /dev/null +++ b/debian/xvm-munin-remote-config.postinst @@ -0,0 +1,54 @@ +#!/bin/sh +# postinst script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + # So munin can read the mail log + adduser munin adm + + # So munin can sudo to get to postfix queue info + cat >>/etc/sudoers <&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/xvm-munin-remote-config.prerm b/debian/xvm-munin-remote-config.prerm new file mode 100755 index 0000000..3306876 --- /dev/null +++ b/debian/xvm-munin-remote-config.prerm @@ -0,0 +1,41 @@ +#!/bin/sh +# prerm script for #PACKAGE# +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + perl -i.bak -ne 's%^### (BEGIN|END) xvm-munin-config\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/host/etc/munin/plugin-conf.d/hddtemp_smartctl b/host/etc/munin/plugin-conf.d/hddtemp_smartctl new file mode 100644 index 0000000..3a64b0d --- /dev/null +++ b/host/etc/munin/plugin-conf.d/hddtemp_smartctl @@ -0,0 +1,4 @@ +[hddtemp_smartctl] +user root +env.drives sda sdb +command sudo -E %c diff --git a/host/etc/munin/plugin-conf.d/smart b/host/etc/munin/plugin-conf.d/smart new file mode 100644 index 0000000..5037c15 --- /dev/null +++ b/host/etc/munin/plugin-conf.d/smart @@ -0,0 +1,3 @@ +[smart_*] +user root +command sudo -E %c diff --git a/master/etc/munin/plugin-conf.d/postgres b/master/etc/munin/plugin-conf.d/postgres new file mode 100644 index 0000000..0b5ef17 --- /dev/null +++ b/master/etc/munin/plugin-conf.d/postgres @@ -0,0 +1,2 @@ +[postgres_*] +env.dbuser munin diff --git a/master/etc/munin/plugins/postgres_block_read_invirt b/master/etc/munin/plugins/postgres_block_read_invirt new file mode 120000 index 0000000..d5e769d --- /dev/null +++ b/master/etc/munin/plugins/postgres_block_read_invirt @@ -0,0 +1 @@ +/usr/share/xvm-munin-master-config/postgres_block_read_ \ No newline at end of file diff --git a/master/etc/munin/plugins/postgres_connections b/master/etc/munin/plugins/postgres_connections new file mode 120000 index 0000000..680632a --- /dev/null +++ b/master/etc/munin/plugins/postgres_connections @@ -0,0 +1 @@ +/usr/share/xvm-munin-master-config/postgres_connections \ No newline at end of file diff --git a/master/etc/munin/plugins/postgres_locks b/master/etc/munin/plugins/postgres_locks new file mode 120000 index 0000000..fce4611 --- /dev/null +++ b/master/etc/munin/plugins/postgres_locks @@ -0,0 +1 @@ +/usr/share/xvm-munin-master-config/postgres_locks \ No newline at end of file diff --git a/master/etc/munin/plugins/postgres_space_invirt b/master/etc/munin/plugins/postgres_space_invirt new file mode 120000 index 0000000..9fac8b1 --- /dev/null +++ b/master/etc/munin/plugins/postgres_space_invirt @@ -0,0 +1 @@ +/usr/share/xvm-munin-master-config/postgres_space_ \ No newline at end of file diff --git a/master/usr/share/xvm-munin-master-config/plugins/postgres_block_read_ b/master/usr/share/xvm-munin-master-config/plugins/postgres_block_read_ new file mode 100755 index 0000000..2733acb --- /dev/null +++ b/master/usr/share/xvm-munin-master-config/plugins/postgres_block_read_ @@ -0,0 +1,165 @@ +#!/usr/bin/perl -w +# -*- perl -*- + +# Plugin to monitor Postgresql memory usage; gives number of blocks +# read from disk and from memory, showing how much of the database is +# served from Postgresql's memory buffer. +# +# PLEASE NOTE: This plugin may not present the whole truth - the truth +# may actually be even better than this plugin will show you! That is +# because Postgresql statistics only considers memory block reads from +# its own allocated memory. When Postgresql reads from disk, it may +# actually still be read from memory, but from the _kernel_'s +# memory. Summarily, your database server may run even better than +# this plugin will indicate. See +# http://www.postgresql.org/docs/7.4/interactive/monitoring-stats.html +# for a (short) description. +# +# Copyright BjØrn Ruberg 2006 +# +# Licenced under GPL v2. +# +# Usage: +# +# Symlink into /etc/munin/plugins/ and add the monitored +# database to the filename. e.g.: +# +# ln -s /usr/share/munin/plugins/postgres_block_read_ \ +# /etc/munin/plugins/postgres_block_read_SomeDatabase +# This should, however, be given through autoconf and suggest. +# +# If required, give username, password and/or Postgresql server +# host through environment variables. +# +# You must also activate Postgresql statistics. See +# http://www.postgresql.org/docs/7.4/interactive/monitoring-stats.html +# for how to enable this. Specifically, the following lines must +# exist in your postgresql.conf: +# +# stats_start_collector = true +# stats_block_level = true +# +# +# Parameters: +# +# config (required) +# +# Config variables: +# +# dbhost - Which database server to use. Defaults to +# 'localhost'. +# dbport - Which port on the database server to connect to. +# Defaults to '5432'. +# dbuser - A Postgresql user account with read permission to +# the given database. Defaults to +# 'postgres'. Anyway, Munin must be told which user +# this plugin should be run as. +# dbpass - The corresponding password, if +# applicable. Default to undef. Remember that +# pg_hba.conf must be configured accordingly. +# +# Magic markers +#%# family=auto +#%# capabilities=autoconf suggest + +use strict; +use DBI; +use Data::Dumper; +use vars qw ( $debug $suggest $configure $dbh ); + +# Need these variables at an early stage to enable +# autoconf and suggest +my $dbhost = $ENV{'dbhost'} || ''; # Connect to localhost by default +my $dbport = $ENV{'dbport'} || ''; +my $dbuser = $ENV{'dbuser'} || 'postgres'; +my $dbpass = $ENV{'dbpass'} || ''; + +if (exists $ARGV[0]) { + if ($ARGV[0] eq 'autoconf') { + my $dbname = $ENV{'dbname'} || 'template1'; + # Check for DBD::Pg + if (! eval "require DBD::Pg;") { + print "no (DBD::Pg not found)"; + exit 1; + } + # Then we try to detect Postgres presence by connecting to + # 'template1'. + my $dsn = "dbi:Pg:dbname=template1"; + $dsn .= ";host=$dbhost" if $dbhost; + $dsn .= ";port=$dbport" if $dbport; + my $tempdbh = DBI->connect ($dsn, $dbuser, $dbpass); + if ($tempdbh) { + print "yes\n"; + exit 0; + } else { + print "no (Can't connect to given host, please check environment settings)\n"; + exit 1; + } + } elsif ($ARGV[0] eq 'debug') { + # Set debug flag + $debug = 1; + } elsif ($ARGV[0] eq 'config') { + # Set config flag + $configure = 1; + } elsif ($ARGV[0] eq 'suggest') { + # doesn't always work + my @datasources = DBI->data_sources ('Pg'); + foreach my $dsn (grep !/\=template\d$/, @datasources) { + (my $db = $dsn) =~ s/^.*=//; + print "$db\n"; + } + exit 0; + } +} + +# Must do this here, after checking for autoconf/suggest/etc, because the +# plugin must be able to run before it is linked to the databases. +my (undef, undef, undef, $dbname) = split (/_/, $0, 4); +die "No dbname configured (did you make the proper symlink?)" unless $dbname; + +my @datasources = DBI->data_sources ('Pg') + or die ("Can't read any possible data sources: $?"); + +my $dsn = "DBI:Pg:dbname=$dbname"; +$dsn .= ";host=$dbhost" if $dbhost; +$dsn .= ";port=$dbport" if $dbport; +print "#$dsn\n" if $debug; +my $dbh = DBI->connect ($dsn, $dbuser, $dbpass, {RaiseError =>1}); +unless($dbh) { + die("Database $dbname\@$dbhost (". $DBI::errstr .")\n"); +} + +if ($configure) { + print <prepare ($sql); + $sth->execute(); + if ($sth->rows > 0) { + printf ("# Rows: %d\n", $sth->rows) if $debug; + my ($disk, $mem) = $sth->fetchrow_array(); + print "from_disk.value $disk\n"; + print "from_memory.value $mem\n"; + } +} diff --git a/master/usr/share/xvm-munin-master-config/plugins/postgres_connections b/master/usr/share/xvm-munin-master-config/plugins/postgres_connections new file mode 100755 index 0000000..bff771e --- /dev/null +++ b/master/usr/share/xvm-munin-master-config/plugins/postgres_connections @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w +# -*- perl -*- +# + +use strict; +use DBI; + +my $dbhost = $ENV{'dbhost'} || ''; +my $dbport = $ENV{'dbport'} || ''; +my $dbname = $ENV{'dbname'} || 'template1'; +my $dbuser = $ENV{'dbuser'} || 'postgres'; + +my $Con = "DBI:Pg:dbname=$dbname"; +$Con .= ";host=$dbhost" if $dbhost; +$Con .= ";port=$dbport" if $dbport; +my $Dbh = DBI->connect ($Con, $dbuser,'',{RaiseError =>1}) || + die "Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; + +if ($ARGV[0] && $ARGV[0] eq 'config') { + my $sql_max = "SHOW max_connections;"; + my $sth_max = $Dbh->prepare($sql_max); + $sth_max->execute(); + my ($max_conn) = $sth_max->fetchrow(); + my $warning = int ($max_conn * 0.7); + my $critical = int ($max_conn * 0.8); + print <prepare($sql_curr); + $sth_curr->execute(); + my ($curr_conn) = $sth_curr->fetchrow(); + print "connections.value $curr_conn\n"; +} diff --git a/master/usr/share/xvm-munin-master-config/plugins/postgres_locks b/master/usr/share/xvm-munin-master-config/plugins/postgres_locks new file mode 100755 index 0000000..d5ce7a1 --- /dev/null +++ b/master/usr/share/xvm-munin-master-config/plugins/postgres_locks @@ -0,0 +1,77 @@ +#!/usr/bin/perl -w +# -*- perl -*- +# +# Show postgres lock statistics +# +# Parameters: +# +# config (required) +# +# Config variables: +# +# dbhost - Which database server to use. Defaults to +# 'localhost'. +# dbport - Which port on the database server to connect to. +# Defaults to '5432'. +# dbuser - A Postgresql user account with read permission to +# the given database. Defaults to +# 'postgres'. Anyway, Munin must be told which user +# this plugin should be run as. +# dbpass - The corresponding password, if +# applicable. Default to undef. Remember that +# pg_hba.conf must be configured accordingly. +# +# Magic markers +#%# family=auto +#%# capabilities=suggest + +use strict; +use DBI; + +# See postgress_block_read_ for docs + +my $dbhost = $ENV{'dbhost'} || ''; +my $dbport = $ENV{'dbport'} || ''; +my $dbname = $ENV{'dbname'} || 'template1'; +my $dbuser = $ENV{'dbuser'} || 'postgres'; + +if ($ARGV[0] && $ARGV[0] eq "config") { + print <connect ($Con, $dbuser, + '', + {RaiseError =>1}) || die "Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; + + my $sql="SELECT mode,COUNT(mode) FROM pg_locks GROUP BY mode ORDER BY mode;"; + my $sth = $Dbh->prepare ($sql); + $sth->execute (); + my $locks = 0; + my $exlocks = 0; + while (my ($mode, $count) = $sth->fetchrow ()) { + if ($mode =~ /exclusive/i) { + $exlocks = $exlocks + $count; + } + $locks = $locks+$count; + } + print "locks.value $locks\n"; + print "exlocks.value $exlocks\n"; +} diff --git a/master/usr/share/xvm-munin-master-config/plugins/postgres_space_ b/master/usr/share/xvm-munin-master-config/plugins/postgres_space_ new file mode 100755 index 0000000..257ad2b --- /dev/null +++ b/master/usr/share/xvm-munin-master-config/plugins/postgres_space_ @@ -0,0 +1,176 @@ +#!/usr/bin/perl -w +# -*- perl -*- + +# Written by Bjrn Ruberg (bjorn@linpro.no) 2006 +# Rewritten by Moses Moore 2006-04-08 moc.iazom@sesom +# Licenced under GPL + +# Magic markers +#%# family=auto +#%# capabilities=autoconf suggest + +use strict; +use DBI; +use vars qw ( $debug $suggest $configure $dbh ); + +# Package maintainers should provide an environment +# file for the /etc/munin/plugin-conf.d/ directory +# to override these values if necessary. +# NOTE: The plugin (also when auto configured) should +# be run by the postgresql user account. + +# Need these variables at an early stage to enable +# autoconf and suggest +my $dbhost = $ENV{'dbhost'} || ''; # Connect to localhost by default +my $dbport = $ENV{'dbport'} || ''; +my $dbuser = $ENV{'dbuser'} || 'postgres'; +my $dbpass = $ENV{'dbpass'} || ''; + +if (exists $ARGV[0]) { + if ($ARGV[0] eq 'autoconf') { + # Check for DBD::Pg + if (! eval "require DBD::Pg;") { + print "no (DBD::Pg not found)"; + exit 1; + } + # Then we try to detect Postgres presence by connecting to + # 'template1'. + my $dsn = "dbi:Pg:dbname=template1"; + $dsn .= ";host=$dbhost" if $dbhost; + $dsn .= ";port=$dbport" if $dbport; + my $tempdbh = DBI->connect ($dsn, $dbuser, $dbpass); + if ($tempdbh) { + print "yes\n"; + exit 0; + } else { + print "no (Can't connect to given host, please check environment settings)\n"; + exit 1; + } + } elsif ($ARGV[0] and $ARGV[0] eq 'debug') { + # Set config flag + $debug = 1; + } elsif ($ARGV[0] and $ARGV[0] eq 'config') { + # Set config flag + $configure = 1; + } elsif ($ARGV[0] eq 'suggest') { + # doesn't always work + my @datasources = DBI->data_sources ('Pg'); + foreach my $dsn (grep !/\=template\d$/, @datasources) { + (my $db = $dsn) =~ s/^.*=//; + print "$db\n"; + } + exit 0; + } +} + +# Must do this here, after checking for autoconf/suggest/etc, because the +# plugin must be able to run before it is linked to the databases. +my (undef, undef, $dbname) = split (/_/, $0, 3); +die "No dbname configured (did you make the proper symlink?)" unless $dbname; + +my @datasources = DBI->data_sources ('Pg') + or die ("Can't read any possible data sources: $?"); + +my $dsn = "DBI:Pg:dbname=$dbname"; +$dsn .= ";host=$dbhost" if $dbhost; +$dsn .= ";port=$dbport" if $dbport; +print "#$dsn\n" if $debug; +my $dbh = DBI->connect ($dsn, $dbuser, $dbpass, {RaiseError =>1}); +unless($dbh) { + die("Database $dbname\@$dbhost (". $DBI::errstr .")\n"); +} + +if ($configure) { + print <<_EOM; +graph_title Postgres database $dbname +graph_args -l 0 --base 1024 +graph_vlabel bytes +graph_category Postgresql +graph_info Size +size.label Database size (bytes) +size.info Database size +size.type GAUGE +size.draw AREA +indexsize.label Index size (bytes) +indexsize.info Index size +indexsize.type GAUGE +indexsize.draw STACK +metasize.label Meta database size (bytes) +metasize.info Meta database size +metasize.type GAUGE +metasize.draw STACK +metaindexsize.label Meta index size (bytes) +metaindexsize.info Meta index size +metaindexsize.type GAUGE +metaindexsize.draw STACK +_EOM +} else { + my $database_pages = 0; + my $database_indexes = 0; + my $metadatabase_pages = 0; + my $metadatabase_indexes = 0; + my @names = $dbh->tables; + + # Find relfilenode and relpages from the given table + my $q_ind = "SELECT relkind, relfilenode, relpages FROM pg_class + WHERE relname = ? + UNION + SELECT relkind, relfilenode, relpages FROM pg_class + WHERE relfilenode IN (SELECT indexrelid FROM pg_index + WHERE indrelid IN (SELECT relfilenode FROM pg_class + WHERE relname = ?))"; + my $sth = $dbh->prepare ($q_ind) or die $dbh->errstr; + + # Iterate over the tables in the database + foreach my $table (@names) { + my $meta = 1; + print "#TABLE: $table\n" if $debug; + my $table_pages = 0; + my $table_indexes = 0; + my $metatable_pages = 0; + my $metatable_indexes = 0; + # "public" tables are the user data + $meta = 0 if $table =~ /^public\./; + $table =~ s/^.*\.//; + + # Call the query with $table twice for each side of the UNION + $sth->execute ($table, $table) or die $dbh->errstr; + while (my ($relkind, $relfilenode, $relpages) = $sth->fetchrow_array) { + if ($relkind eq 'r') { + $table_pages += $relpages if $meta == 0; + $metatable_pages += $relpages if $meta == 1; + } elsif ($relkind eq 'i') { + $table_indexes += $relpages if $meta == 0; + $metatable_indexes += $relpages if $meta == 1; + } + # Define the query + my $q2 = "SELECT SUM(relpages) + FROM pg_class + WHERE relname IN (?, ?)"; + my $sth2 = $dbh->prepare ($q2); + $sth2->execute ("pg_toast_${relfilenode}", + "pg_toast_${relfilenode}_index"); + my $relpages = $sth2->fetchrow_array; + if ($relpages) { + if ($relkind eq 'r') { + $table_pages += $relpages if $meta == 0; + $metatable_pages += $relpages if $meta == 1; + } elsif ($relkind eq 'i') { + $table_indexes += $relpages if $meta == 0; + $metatable_indexes += $relpages if $meta == 1; + } + } + print "#\tR:$relfilenode\tP:$table_pages\tI:$table_indexes\n" if $debug; + } + $database_pages += $table_pages; + $database_indexes += $table_indexes; + $metadatabase_pages += $metatable_pages; + $metadatabase_indexes += $metatable_indexes; + } + $sth->finish; + $dbh->disconnect; + print "size\.value " . $database_pages * 8192 . "\n"; + print "indexsize\.value " . $database_indexes * 8192 . "\n"; + print "metasize\.value " . $metadatabase_pages * 8192 . "\n"; + print "metaindexsize\.value " . $metadatabase_indexes * 8192 . "\n"; +} diff --git a/remote/etc/munin/plugins/loggrep_remctl b/remote/etc/munin/plugins/loggrep_remctl new file mode 120000 index 0000000..c37d295 --- /dev/null +++ b/remote/etc/munin/plugins/loggrep_remctl @@ -0,0 +1 @@ +/usr/share/munin/plugins/loggrep \ No newline at end of file diff --git a/remote/usr/share/xvm-munin-remote-config/loggrep_remctl.mako b/remote/usr/share/xvm-munin-remote-config/loggrep_remctl.mako new file mode 100644 index 0000000..9e2b79d --- /dev/null +++ b/remote/usr/share/xvm-munin-remote-config/loggrep_remctl.mako @@ -0,0 +1,16 @@ +[loggrep_remctl] +user munin +command sudo -u munin -E %c + +env.title remctls +env.logfile /var/log/syslog + +% for n, r in enumerate(('listvms', 'vnccert', 'lvcreate', 'lvremove', 'lvrename', 'lvresize')): +env.regex_web_${n} \w{3} [ :0-9]{11} [._[:alnum:]-]+ remctld\[[0-9]+\]: COMMAND from .*.MIT.EDU: web ${r} +env.label_web_${n} web ${r} +% endfor + +% for n, r in enumerate(('help', 'create', 'install', 'list-host', 'listhost', 'list', 'vcpu-list', 'uptime', 'destroy', 'shutdown', 'reboot', 'list-long', 'vnctoken')): +env.regex_control_${n} \w{3} [ :0-9]{11} [._[:alnum:]-]+ remctld\[[0-9]+\]: COMMAND from .*.MIT.EDU: control \S+ ${r} +env.label_control_${n} control ${r} +% endfor -- 1.7.9.5