diff --git a/contrib/collection3/lib/Collectd/Graph/TypeLoader.pm b/contrib/collection3/lib/Collectd/Graph/TypeLoader.pm
index 6223eaa0cf663407cd1139d4dfefb1137524455a..a9e85f57e43444fcc93efbfeec912b3a59bf8c9e 100644 (file)
=cut
=cut
-# Copyright (C) 2008 Florian octo Forster <octo at verplant.org>
+# Copyright (C) 2008,2009 Florian octo Forster <octo at verplant.org>
#
# 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
#
# 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
use Carp (qw(cluck confess));
use Exporter ();
use Config::General ('ParseConfig');
use Carp (qw(cluck confess));
use Exporter ();
use Config::General ('ParseConfig');
+use Collectd::Graph::Config ('gc_get_config');
use Collectd::Graph::Type ();
@Collectd::Graph::TypeLoader::ISA = ('Exporter');
use Collectd::Graph::Type ();
@Collectd::Graph::TypeLoader::ISA = ('Exporter');
-@Collectd::Graph::TypeLoader::EXPORT_OK = ('tl_read_config', 'tl_load_type');
-
-our $Configuration = undef;
+@Collectd::Graph::TypeLoader::EXPORT_OK = ('tl_load_type');
our @ArrayMembers = (qw(data_sources rrd_opts custom_order));
our @ArrayMembers = (qw(data_sources rrd_opts custom_order));
-our @ScalarMembers = (qw(rrd_title rrd_format rrd_vertical scale));
+our @ScalarMembers = (qw(rrd_title rrd_format rrd_vertical scale ignore_unknown));
our @DSMappedMembers = (qw(ds_names rrd_colors));
our %MemberToConfigMap =
our @DSMappedMembers = (qw(ds_names rrd_colors));
our %MemberToConfigMap =
rrd_vertical => 'rrdverticallabel',
rrd_colors => 'color',
scale => 'scale', # GenericIO only
rrd_vertical => 'rrdverticallabel',
rrd_colors => 'color',
scale => 'scale', # GenericIO only
- custom_order => 'order' # GenericStacked only
+ custom_order => 'order', # GenericStacked only
+ ignore_unknown => 'ignoreunknown' # GenericStacked only
);
return (1);
);
return (1);
-=head1 EXPORTED FUNCTIONS
-
-=over 4
-
-=item B<tl_read_config> (I<$file>)
-
-Reads the configuration from the file located at I<$file>.
-
-=cut
-
-sub tl_read_config
-{
- my $file = shift;
- my %conf;
-
- if ($Configuration)
- {
- return (1);
- }
-
- %conf = ParseConfig (-ConfigFile => $file,
- -LowerCaseNames => 1,
- -UseApacheInclude => 1,
- -IncludeDirectories => 1,
- ($Config::General::VERSION >= 2.38) ? (-IncludeAgain => 0) : (),
- -MergeDuplicateBlocks => 1,
- -CComments => 0);
- if (!%conf)
- {
- return;
- }
-
- $Configuration = \%conf;
- return (1);
-} # tl_read_config
-
sub _create_object
{
my $module = shift;
my $obj;
sub _create_object
{
my $module = shift;
my $obj;
- local $SIG{__WARN__} = sub {};
- local $SIG{__DIE__} = sub {};
+ local $SIG{__WARN__} = sub { print STDERR "WARNING: " . join (', ', @_) . "\n"; };
+ local $SIG{__DIE__} = sub { print STDERR "FATAL: " . join (', ', @_) . "\n"; };
eval <<PERL;
require $module;
eval <<PERL;
require $module;
if ($module)
{
if ($module)
{
- print STDERR "\$module = $module;\n";
$obj = _create_object ($module);
if (!$obj)
{
$obj = _create_object ($module);
if (!$obj)
{
$obj->{$member} ||= {};
$obj->{$member}{$ds} = $val;
$obj->{$member} ||= {};
$obj->{$member}{$ds} = $val;
-
- print STDERR "\$obj->{$member}{$ds} = $val;\n";
} # for (@val_list)
} # }}} for (@DSMappedMembers)
} # for (@val_list)
} # }}} for (@DSMappedMembers)
return ($obj);
} # _load_module_generic
return ($obj);
} # _load_module_generic
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
=item B<tl_load_type> (I<$type>)
Does whatever is necessary to get an object with which to graph RRD files of
=item B<tl_load_type> (I<$type>)
Does whatever is necessary to get an object with which to graph RRD files of
sub tl_load_type
{
my $type = shift;
sub tl_load_type
{
my $type = shift;
+ my $conf = gc_get_config ();
- if (defined $Configuration->{'type'}{$type})
+ if (defined ($conf) && defined ($conf->{'type'}{$type}))
{
{
- return (_load_module_from_config ($Configuration->{'type'}{$type}));
+ return (_load_module_from_config ($conf->{'type'}{$type}));
}
else
{
}
else
{