#!/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 <octo at verplant.org>
+#
+
use strict;
use warnings;
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);
can use a hyphen to add a "type instance" to the type.
For a list of already defined "types" look at the F<types.db> file in
-collectd's library path, e.E<nbsp>g. F</usr/lib/collectd/>.
+collectd's shared data directory, e.E<nbsp>g. F</usr/share/collectd/>.
=item B<Interval> I<Seconds>
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: $!";
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);
}
}