From 284b50a1d07310c8c10f1c1f953d1e979762c476 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Fri, 12 Oct 2007 16:14:11 +0000 Subject: add the virtual module --- files/build_vserver | 32 ++++++++++++++++++++++ files/munin/xen_mem | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ files/munin/xen_vm | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100755 files/build_vserver create mode 100644 files/munin/xen_mem create mode 100644 files/munin/xen_vm (limited to 'files') diff --git a/files/build_vserver b/files/build_vserver new file mode 100755 index 0000000..bf4b949 --- /dev/null +++ b/files/build_vserver @@ -0,0 +1,32 @@ +#!/bin/bash + +NAME=$1 +DOMAIN=$2 + +# create basic vserver +vserver $NAME build -m debootstrap -- -d etch -m http://ftp.at.debian.org/debian + +# default settings +echo $NAME >/etc/vservers/$NAME/uts/nodename + +# copy in some some defaults +TARGET=/etc/vservers/$NAME/vdir/ + +cp /etc/apt/{preferences,sources.list} $TARGET/etc/apt/ + +# this is needed so puppet can find the puppetmaster and creates the right +# certificate +grep -v $NAME /etc/hosts > $TARGET/etc/hosts +echo "127.0.0.1 $NAME.$DOMAIN $NAME" >> $TARGET/etc/hosts +mkdir -p $TARGET/var/lib/puppet/modules/dbp +cp /var/lib/puppet/modules/dbp/puppet_current.deb $TARGET/var/lib/puppet/modules/dbp/ + +# Setup is complete, now do the post-install stuff +vserver $NAME start +vserver $NAME exec dselect update +# install a few packages needed for facter +vserver $NAME exec apt-get -y install lsb-release iproute +vserver $NAME exec dpkg --install var/lib/puppet/modules/dbp/puppet_current.deb +vserver $NAME exec apt-get -fy install + +echo "Please sign now: puppetca --sign $NAME.$DOMAIN" >&2 diff --git a/files/munin/xen_mem b/files/munin/xen_mem new file mode 100644 index 0000000..5e985a5 --- /dev/null +++ b/files/munin/xen_mem @@ -0,0 +1,77 @@ +#!/bin/sh +# +# Copyright (C) 2006 Rodolphe Quiedeville +# +# 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; version 2 dated June, +# 1991. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# Script to monitor affected memory by domain +# +# $Log$ +# Revision 1.0 2006/09/08 19:20:19 rodo +# Created by Rodolphe Quiedeville +# +# Need to be run as root, add the following lines ... +# +# [xen*] +# user root +# +# to /etc/munin/plugin-conf.d/munin-node +# +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) +# +# +# Magic markers (optional - used by munin-config and installation +# scripts): +# +#%# family=auto +#%# capabilities=autoconf + +XM="/usr/sbin/xm" + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Xen affected memory' + echo 'graph_args --base 1024 --upper-limit 1024 -l 0' + echo 'graph_vlabel Memory' + echo 'graph_category xen' + echo 'graph_total Total' + echo 'graph_info This graph shows affected memory for each domain.' + echo 'Domain_0.label Domain-0' + echo 'Domain_0.draw AREA' +$XM list | grep -v 'Mem' | grep -v 'Domain-0' | while read i; do + name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` + echo -n "$name.label " + echo $i | awk '{ print $1 }' + echo "$name.draw STACK" +done + + exit 0 +fi + +$XM list | grep -v 'Mem' | while read i; do + name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` + echo -n "$name.value " + echo $i | awk '{ print $3 * 1024 * 1024 }' +done diff --git a/files/munin/xen_vm b/files/munin/xen_vm new file mode 100644 index 0000000..a0dc0b7 --- /dev/null +++ b/files/munin/xen_vm @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Copyright (C) 2006 Rodolphe Quiedeville +# +# 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; version 2 dated June, +# 1991. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# Monitor number of vm running on a xen dom0. +# +# $Log$ +# Revision 1.0 2006/09/08 19:20:19 rodo +# Created by Rodolphe Quiedeville +# +# Need to be run as root, add the following lines ... +# +# [xen*] +# user root +# +# to /etc/munin/plugin-conf.d/munin-node +# +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) +# +# +# Magic markers (optional - used by munin-config and installation +# scripts): +# +#%# family=auto +#%# capabilities=autoconf + +XM="/usr/sbin/xm" + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Xen Virtual Machines' + echo 'graph_args --base 1000 -l 0' + echo 'graph_vlabel vm' + echo 'graph_category xen' + echo 'graph_info This graph shows how many virtual machines runs on dom0.' + echo 'domains.label vm' + exit 0 +fi + +domains=`$XM list | wc -l` + +echo -n "domains.value " +echo $(($domains-2)) -- cgit v1.2.3