#!/usr/bin/perl # # collectd - contrib/exec-munin.px # Copyright (C) 2007,2008 Florian Forster # # 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; only version 2 of the License is applicable. # # 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., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Authors: # Florian octo Forster # use strict; use warnings; =head1 NAME exec-munin.px =head1 DESCRIPTION This script allows you to use plugins that were written for Munin with collectd's C. Since the data models of Munin and collectd are quite different rewriting the plugins should be preferred over using this transition layer. Having more than one "data source" for one "data set" doesn't work with this script, for example. =cut use Sys::Hostname ('hostname'); use File::Basename ('basename'); use Config::General ('ParseConfig'); use Regexp::Common ('number'); our $ConfigFile = '/etc/exec-munin.conf'; our $TypeMap = {}; our $Scripts = []; our $Interval = defined ($ENV{'COLLECTD_INTERVAL'}) ? (0 + $ENV{'COLLECTD_INTERVAL'}) : 300; our $Hostname = defined ($ENV{'COLLECTD_HOSTNAME'}) ? $ENV{'COLLECTD_HOSTNAME'} : ''; main (); exit (0); # Configuration {{{ =head1 CONFIGURATION This script reads its configuration from F. The configuration is read using C which understands a Apache-like config syntax, so it's very similar to the F syntax, too. Here's a short sample config: AddType voltage-in in AddType voltage-out out Interval 300 Script /usr/lib/munin/plugins/nut The options have the following semantic (i.Ee. meaning): =over 4 =item B I I [I ...] collectd uses B to specify how data is structured. In Munin all data is structured the same way, so some way of telling collectd how to handle the data is needed. This option translates the so called "field names" of Munin to the "types" of collectd. If more than one field are of the same type, e.Eg. the C plugin above provides C and C which are both voltages, you can use a hyphen to add a "type instance" to the type. For a list of already defined "types" look at the F file in collectd's shared data directory, e.Eg. F. =item B I Sets the interval in which the plugins are executed. This doesn't need to match the interval setting of the collectd daemon. Usually, you want to execute the Munin plugins much less often, e.Eg. every 300 seconds versus every 10 seconds. =item B