[arch-commits] Commit in (9 files)

Dan McGee dan at archlinux.org
Sat Oct 10 19:36:14 UTC 2009


    Date: Saturday, October 10, 2009 @ 15:36:14
  Author: dan
Revision: 54494

Add new munin-node package

Added:
  munin-node/
  munin-node/repos/
  munin-node/trunk/
  munin-node/trunk/Makefile.config
  munin-node/trunk/PKGBUILD
  munin-node/trunk/iostat_partition
  munin-node/trunk/logrotate.munin-node
  munin-node/trunk/munin-node.init
  munin-node/trunk/munin-node.install

----------------------+
 Makefile.config      |  102 ++++++++++++++++++++++++++++++++++
 PKGBUILD             |   41 +++++++++++++
 iostat_partition     |  147 +++++++++++++++++++++++++++++++++++++++++++++++++
 logrotate.munin-node |    4 +
 munin-node.init      |   38 ++++++++++++
 munin-node.install   |   11 +++
 6 files changed, 343 insertions(+)

Added: munin-node/trunk/Makefile.config
===================================================================
--- munin-node/trunk/Makefile.config	                        (rev 0)
+++ munin-node/trunk/Makefile.config	2009-10-10 19:36:14 UTC (rev 54494)
@@ -0,0 +1,102 @@
+# This file specifies where Munin will look for things after you've
+# run 'make' in the source directory.  Modify it to suit your needs.
+
+# DESTDIR is empty during building, and optionally set to point to
+# a shadow tree during make install.
+
+#
+# the base of the Munin installation.
+# 
+PREFIX     = $(DESTDIR)
+
+# Where Munin keeps its configurations (server.conf, client.conf, ++)
+CONFDIR    = $(DESTDIR)/etc/munin
+
+# Server only - where to put munin-cron
+BINDIR     = $(PREFIX)/usr/bin
+
+# Client only - where to put munin-node, munin-node-configure, and munin-run
+SBINDIR    = $(PREFIX)/usr/sbin
+
+# Where to put text and html documentation
+DOCDIR     = $(PREFIX)/usr/share/doc/munin
+
+# Where to put man pages
+MANDIR     = $(PREFIX)/usr/share/man
+
+# Where to put internal binaries and plugin repository
+LIBDIR     = $(PREFIX)/usr/lib/munin
+
+# Server only - Output directory
+HTMLDIR    = $(PREFIX)/srv/http/munin
+CGIDIR     = $(HTMLDIR)/cgi
+
+# Client only - Where to put RRD files and other internal data
+DBDIR      = $(DESTDIR)/var/lib/munin
+
+# Client only - Where plugins should put their states. Must be writable by
+# group "munin", and should be preserved between reboots
+PLUGSTATE  = $(DBDIR)/plugin-state
+
+# Where Munin should place its logs.
+LOGDIR     = $(DESTDIR)/var/log/munin
+
+# Location of PID files and other statefiles. On the server, must be
+# writable by the user "munin".
+STATEDIR   = $(DESTDIR)/var/run/munin
+
+# The perl interpreter to use
+PERL       = /usr/bin/perl
+
+# The python interpreter to use (used by some plugins)
+PYTHON     = /usr/bin/env python
+
+# A modern (posix) shell.  We're not looking for arrays, but $() and
+# other modern stuff is expected.  On a posix-system the expression
+# below will find the right shell.  Most Unixes released the last 10
+# years are POSIX compliant enough for this to work (he said bravely).
+# 
+# On Linux /bin/sh, SunOS/Solaris /usr/xpg4/bin/sh or /bin/ksh
+# In general: bash or ksh will work
+#
+GOODSH     = $(shell PATH=`getconf PATH` sh -c 'type sh | sed "s/.* //"')
+
+# Path of bash for bash specific plugins
+BASH       = /bin/bash
+
+# Server only - Where to install the perl libraries
+PERLLIB    = $(DESTDIR)$(shell $(PERL) -V:sitelib | cut -d"'" -f2)
+
+# Client only - Install plugins for this architecture
+OSTYPE     = $(shell uname | tr '[A-Z]' '[a-z]')
+
+# How to figure out the hostname. (Only used in default configuration
+# files)
+HOSTNAME   = `hostname`
+
+# What is the safest way to create a tempfile.
+# Default is to figure it out by testing various methods.
+# Replace this with a known platform-specific method
+MKTEMP     = $(shell ./test-mktemp)
+
+# Munin version number.
+VERSION    = $(shell cat RELEASE)
+
+# User to run munin as
+USER       = munin
+GROUP      = munin
+
+# Default user to run the plugins as
+PLUGINUSER = nobody
+
+# Which command to use to check if the USER and GROUP to run Munin as, exists.
+GETENT = /bin/true
+CHECKUSER  = /bin/true 
+CHECKGROUP = /bin/true
+
+CHOWN      = true
+CHMOD      = chmod
+CHGRP      = true
+# Check whether setruid functionality can be used
+HASSETR = $(shell perl -e 'use Config; my @vars=("d_setruid", "d_setreuid", "d_setresuid"); foreach my $$var (@vars) { if ($$Config{$$var} eq "define") { print "1\n"; exit 0; } } print "0\n"; exit 0;' )
+

Added: munin-node/trunk/PKGBUILD
===================================================================
--- munin-node/trunk/PKGBUILD	                        (rev 0)
+++ munin-node/trunk/PKGBUILD	2009-10-10 19:36:14 UTC (rev 54494)
@@ -0,0 +1,41 @@
+# Maintainer: Dan McGee <dan at archlinux.org>
+# Contributor: Roberto Alsina <ralsina at kde.org>
+pkgname=munin-node
+pkgver=1.2.6
+pkgrel=14
+pkgdesc="A distributed monitoring/graphing agent"
+arch=('i686' 'x86_64')
+url="http://munin.projects.linpro.no/"
+license=("GPL")
+depends=('perl>=5.10.1' 'perl<5.10.2' 'perl-net-server')
+backup=(etc/munin/munin-node.conf)
+install=munin-node.install
+source=(http://downloads.sourceforge.net/sourceforge/munin/munin_$pkgver.tar.gz
+        Makefile.config munin-node.init munin-node.install logrotate.munin-node iostat_partition)
+
+build() {
+	cd $srcdir/munin-$pkgver
+	cp $srcdir/Makefile.config $srcdir/munin-$pkgver || exit 1
+	make PREFIX='' || exit 1
+}
+
+package() {
+	cd $srcdir/munin-$pkgver
+	# stupid makefile installs a program as '/usr/sbin/sbin' if I don't do this
+	mkdir -p $pkgdir/usr/sbin/
+	make DESTDIR=$pkgdir install-node install-node-plugins || exit 1
+	install -m755 $srcdir/iostat_partition $pkgdir/usr/lib/munin/plugins/
+
+	sed -i "s|\$ENV{'MUNIN_HOSTNAME'}.*|\$ENV{'MUNIN_HOSTNAME'} = \`hostname\`;|g" $pkgdir/usr/sbin/munin-node
+	sed -i "s|\$ENV{'MUNIN_HOSTNAME'}.*|\$ENV{'MUNIN_HOSTNAME'} = \`hostname\`;|g" $pkgdir/usr/sbin/munin-run
+
+	install -D -m755 $srcdir/munin-node.init $pkgdir/etc/rc.d/munin-node
+	install -D -m644 $srcdir/logrotate.munin-node $pkgdir/etc/logrotate.d/munin-node
+}
+
+md5sums=('45f84d58f80642ce914f147232f0d396'
+         '5f9b83e0c876821cf2b20012f7cb63f0'
+         '9551a2f7c0f0364fd1b7dd010675e47a'
+         '5cb638b6905340e1e01d51ad850d4115'
+         'cdf139f2b6ae36852113f3411caa6e99'
+         '12289ab5d062449eaa14376f927f5d26')

Added: munin-node/trunk/iostat_partition
===================================================================
--- munin-node/trunk/iostat_partition	                        (rev 0)
+++ munin-node/trunk/iostat_partition	2009-10-10 19:36:14 UTC (rev 54494)
@@ -0,0 +1,147 @@
+#!/usr/bin/perl -w
+#
+# Plugin for watching io-bound traffic (in blocks) on disks.
+# Customized from standard 'iostat' plugin by operating on
+# partitions rather than block devices.
+#
+# Parameters:
+#
+# 	config   (required)
+# 	autoconf (optional - used by lrrd-config)
+#
+# plugin-conf.d/*:
+#
+# 	partitions	-- List partitions to monitor. E.g. "sda1 sda2".
+#
+# Magic markers (optional - used by lrrd-config and some installation
+# scripts):
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+use strict;
+use warnings;
+
+my $detailed_present = 0;
+if (system("grep -q '' /proc/diskstats > /dev/null 2>&1") == 0
+	|| system("grep -q 'rio rmerge rsect ruse wio wmerge wsect wuse running use aveq' /proc/partitions") == 0)
+{
+	$detailed_present = 1;
+}
+
+if ( $ARGV[0] and $ARGV[0] eq "autoconf")
+{
+	if ($detailed_present eq 1)
+	{
+		print "yes\n";
+		exit 0;
+	}
+	print "no\n";
+	exit 1;
+}
+
+my %devs;
+
+&fetch_detailed;
+
+if ( $ARGV[0] and $ARGV[0] eq "config")
+{
+
+	print "graph_title IOstat\n";
+	print "graph_args --base 1024 -l 0\n";
+	print "graph_vlabel blocks per \${graph_period} read (-) / written (+)\n";
+	print "graph_category disk\n";
+	print "graph_total Total\n" if (keys (%devs) > 1);
+	print "graph_info This graph shows the I/O to and from partitions.\n";
+	print "graph_order";
+	foreach my $key (sort by_dev keys %devs)
+	{
+		print " ", $key, "_read ", $key, "_write ";
+	}
+	print "\n";
+	foreach my $key (sort by_dev keys %devs)
+	{
+		print $key . "_read.label $devs{$key}->{name}\n";
+		print $key . "_read.type DERIVE\n";
+		print $key . "_read.max 900000\n";
+		print $key . "_read.min 0\n";
+		print $key . "_read.graph no\n";
+		print $key . "_write.label $devs{$key}->{name}\n";
+		print $key . "_write.info I/O on device $devs{$key}->{name}\n";
+		print $key . "_write.type DERIVE\n";
+		print $key . "_write.max 900000\n";
+		print $key . "_write.min 0\n";
+		print $key . "_write.negative " . $key . "_read\n";
+	}
+	exit 0;
+}
+
+foreach my $key (sort by_dev keys %devs)
+{
+	print $key, "_read.value ", $devs{$key}->{rsect}, "\n";
+	print $key, "_write.value ", $devs{$key}->{wsect}, "\n";
+}
+
+sub by_dev {
+	return $a cmp $b;
+}
+
+my %maj_count;
+sub get_disk_count()
+{
+	my @disk_count;
+	my $major = $_[0];
+	$maj_count{$major} = 0 unless exists($maj_count{$major});
+	$disk_count[0] = $maj_count{$major}++;
+	die "Could not find disk_count for major: $major" unless (exists($disk_count[0]));
+	return $disk_count[0];
+}
+
+sub fetch_detailed()
+{
+	if (open(DETAILED, "/proc/diskstats") or open(DETAILED, "/proc/partitions"))
+	{
+		my %partitions = ();
+		if (exists $ENV{partitions}) {
+			$ENV{partitions} =~ s/["']//g;
+			%partitions = map {$_ => 1} split(' ', $ENV{partitions});
+		}
+		while (<DETAILED>)
+		{
+			if (/^\s+(\d+)\s+\d+\s*\d*\s+([[:alpha:][:digit:]\/]+)\s+(.*)/)
+			{
+				my @fields = split(/\s+/, $3);
+				my $tmpnam = $2;
+				my $major  = $1;
+				next unless exists $partitions{$tmpnam};
+				if ($tmpnam =~ /\d+$/ ) {
+					next unless $tmpnam =~ /(hd|sd|xvd)[[:alpha:]]\d+$/
+				}
+				next unless grep { $_ } @fields;
+
+				$tmpnam =~ s/\/[[:alpha:]]+(\d+)/\/$1/g;
+				$tmpnam =~ s/^([^\/]+)\//$1/;
+				$tmpnam =~ s/\/disc$//;
+
+				$devs{"dev".$major."_".&get_disk_count($major)} =
+				{
+					major => $major,
+					name => $tmpnam,
+					rio => $fields[0],
+					rmerge => $fields[1],
+					rsect => $fields[2],
+					ruse => $fields[3],
+					wio => $fields[4],
+					wmerge => $fields[5],
+					wsect => $fields[6],
+					wuse => $fields[7],
+					running => $fields[8],
+					use => $fields[9],
+					aveq => $fields[10]
+				};
+			}
+		}
+		close (DETAILED);
+	}
+}
+# vim:syntax=perl


Property changes on: munin-node/trunk/iostat_partition
___________________________________________________________________
Added: svn:executable
   + *

Added: munin-node/trunk/logrotate.munin-node
===================================================================
--- munin-node/trunk/logrotate.munin-node	                        (rev 0)
+++ munin-node/trunk/logrotate.munin-node	2009-10-10 19:36:14 UTC (rev 54494)
@@ -0,0 +1,4 @@
+/var/log/munin/munin-node.log {
+   copytruncate
+   missingok
+}

Added: munin-node/trunk/munin-node.init
===================================================================
--- munin-node/trunk/munin-node.init	                        (rev 0)
+++ munin-node/trunk/munin-node.init	2009-10-10 19:36:14 UTC (rev 54494)
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID=`pidof -o %PPID /usr/sbin/munin-node`
+
+case "$1" in
+  start)
+    stat_busy "Starting munin-node"
+    /usr/sbin/munin-node >/dev/null
+    stat_done
+    ;;
+  stop)
+    stat_busy "Stopping munin-node"
+    if [ ! -z "$PID" ]; then
+      kill $PID &> /dev/null
+      if [ $? -gt 0 ]; then
+        stat_fail
+        exit 1
+      else
+        rm -f /var/run/munin/munin-node.pid &>/dev/null
+        stat_done
+      fi
+    else
+      stat_fail
+      exit 1
+    fi
+    ;;
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+  *)
+    echo "usage: $0 {start|stop|restart}"
+    ;;
+esac


Property changes on: munin-node/trunk/munin-node.init
___________________________________________________________________
Added: svn:executable
   + *

Added: munin-node/trunk/munin-node.install
===================================================================
--- munin-node/trunk/munin-node.install	                        (rev 0)
+++ munin-node/trunk/munin-node.install	2009-10-10 19:36:14 UTC (rev 54494)
@@ -0,0 +1,11 @@
+post_install () {
+  # Check user/group munin exists
+  getent group munin >/dev/null || groupadd munin
+  getent passwd munin >/dev/null || useradd -c "Munin system monitor" -g munin -s /bin/false -d /var/lib/munin munin
+  # Fix permissions
+  chown munin.munin -R /var/log/munin /var/lib/munin /var/run/munin
+  # Do basic configuration
+  echo "==> Configuring default plugins for this system"
+  /usr/sbin/munin-node-configure --shell | sh
+  echo "==> To use the SNMP plugins you will need perl-net-snmp"
+}




More information about the arch-commits mailing list