X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=contrib%2Fexec-munin.px;h=5309cc660705a298dc2d5fd669c4ab415e2094c9;hp=246095649657ac66f050c2f5de2e14a8d398875b;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=bec5a6dda77c05eae27e5aeecdf601e573090cc5 diff --git a/contrib/exec-munin.px b/contrib/exec-munin.px index 24609564..5309cc66 100755 --- a/contrib/exec-munin.px +++ b/contrib/exec-munin.px @@ -1,5 +1,26 @@ #!/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; @@ -25,17 +46,17 @@ use Regexp::Common ('number'); our $ConfigFile = '/etc/exec-munin.conf'; our $TypeMap = {}; our $Scripts = []; -our $Interval = 300; +our $Interval = defined ($ENV{'COLLECTD_INTERVAL'}) ? (0 + $ENV{'COLLECTD_INTERVAL'}) : 300; +our $Hostname = defined ($ENV{'COLLECTD_HOSTNAME'}) ? $ENV{'COLLECTD_HOSTNAME'} : ''; main (); exit (0); -# Configuration -# {{{ +# Configuration {{{ =head1 CONFIGURATION -This script reads it's configuration from F. The +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. @@ -60,7 +81,7 @@ 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 library path, e.Eg. F. +collectd's shared data directory, e.Eg. F. =item B I @@ -169,7 +190,7 @@ sub execute_script my $pinst; my $time = time (); my $script = shift; - my $host = hostname () || 'localhost'; + my $host = $Hostname || hostname () || 'localhost'; if (!open ($fh, '-|', $script)) { print STDERR "Cannot execute $script: $!"; @@ -186,8 +207,11 @@ sub execute_script my $field = $1; my $value = $2; my $type = (defined ($TypeMap->{$field})) ? $TypeMap->{$field} : $field; + my $ident = "$host/munin-$pinst/$type"; + + $ident =~ s/"/\\"/g; - print "$host/munin-$pinst/$type interval=$Interval $time:$value\n"; + print qq(PUTVAL "$ident" interval=$Interval $time:$value\n); } }