summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b695cf)
raw | patch | inline | side by side (parent: 8b695cf)
author | Florian Forster <octo@noris.net> | |
Tue, 8 Feb 2011 15:43:22 +0000 (16:43 +0100) | ||
committer | Florian Forster <octo@noris.net> | |
Tue, 8 Feb 2011 15:43:22 +0000 (16:43 +0100) |
Apparently the @INC variable is reset by mod_perl, which
causes later require()s to fail.
causes later require()s to fail.
contrib/collection3/bin/graph.cgi | patch | blob | history | |
contrib/collection3/bin/index.cgi | patch | blob | history | |
contrib/collection3/lib/Collectd/Graph/TypeLoader.pm | patch | blob | history |
index 40408fd5551e703cb81fd2bfb13bbe50cc474065..2b3f2fe18670509342ba019c78a46b2c69b71728 100755 (executable)
{
if ($ENV{'SCRIPT_FILENAME'} =~ m{^(/.+)/bin/[^/]+$})
{
- $BASE_DIR = $1;
- unshift (@INC, "$BASE_DIR/lib");
+ $::BASE_DIR = $1;
+ unshift (@::INC, "$::BASE_DIR/lib");
}
}
}
epoch_to_rfc1123 flush_files));
use Collectd::Graph::Type ();
-$::MODPERL = 1;
-
-my $have_init = 0;
-sub init
+sub base_dir
{
- if ($have_init)
+ if (defined $::BASE_DIR)
+ {
+ return ($::BASE_DIR);
+ }
+
+ if (!defined ($ENV{'SCRIPT_FILENAME'}))
{
return;
}
- #gc_read_config ("$RealBin/../etc/collection.conf");
- gc_read_config ("$BASE_DIR/etc/collection.conf");
+ if ($ENV{'SCRIPT_FILENAME'} =~ m{^(/.+)/bin/[^/]+$})
+ {
+ $::BASE_DIR = $1;
+ return ($::BASE_DIR);
+ }
- $have_init = 1;
+ return;
+}
+
+sub lib_dir
+{
+ my $base = base_dir ();
+
+ if ($base)
+ {
+ return "$base/lib";
+ }
+ else
+ {
+ return "../lib";
+ }
+}
+
+sub sysconf_dir
+{
+ my $base = base_dir ();
+
+ if ($base)
+ {
+ return "$base/etc";
+ }
+ else
+ {
+ return "../etc";
+ }
+}
+
+sub init
+{
+ my $lib_dir = lib_dir ();
+ my $sysconf_dir = sysconf_dir ();
+
+ if (!grep { $lib_dir eq $_ } (@::INC))
+ {
+ unshift (@::INC, $lib_dir);
+ }
+
+ gc_read_config ("$sysconf_dir/collection.conf");
}
sub main
my $OutputFormat = 'PNG';
my $ContentType = 'image/png';
+ init ();
+
if (param ('format'))
{
my $temp = param ('format') || '';
$ContentType = 'text/plain';
}
- init ();
-
if ($GraphWidth)
{
$GraphWidth =~ s/\D//g;
index 679c1eeade3a71da59c467ad365dc6ece2d8738d..027961fa43ac73de432e0e7435768852c423f37b 100755 (executable)
{
if ($ENV{'SCRIPT_FILENAME'} =~ m{^(/.+)/bin/[^/]+$})
{
- $BASE_DIR = $1;
- unshift (@INC, "$BASE_DIR/lib");
+ $::BASE_DIR = $1;
+ unshift (@::INC, "$::BASE_DIR/lib");
}
}
}
show_selection => \&action_show_selection
);
-my $have_init = 0;
-sub init
+sub base_dir
{
- if ($have_init)
+ if (defined $::BASE_DIR)
+ {
+ return ($::BASE_DIR);
+ }
+
+ if (!defined ($ENV{'SCRIPT_FILENAME'}))
{
return;
}
- print STDERR "INC = (" . join (', ', @INC) . ");\n";
+ if ($ENV{'SCRIPT_FILENAME'} =~ m{^(/.+)/bin/[^/]+$})
+ {
+ $::BASE_DIR = $1;
+ return ($::BASE_DIR);
+ }
+
+ return;
+}
+
+sub lib_dir
+{
+ my $base = base_dir ();
- gc_read_config ("$BASE_DIR/etc/collection.conf");
+ if ($base)
+ {
+ return "$base/lib";
+ }
+ else
+ {
+ return "../lib";
+ }
+}
+
+sub sysconf_dir
+{
+ my $base = base_dir ();
+
+ if ($base)
+ {
+ return "$base/etc";
+ }
+ else
+ {
+ return "../etc";
+ }
+}
+
+sub init
+{
+ my $lib_dir = lib_dir ();
+ my $sysconf_dir = sysconf_dir ();
+
+ if (!grep { $lib_dir eq $_ } (@::INC))
+ {
+ unshift (@::INC, $lib_dir);
+ }
- $have_init = 1;
+ gc_read_config ("$sysconf_dir/collection.conf");
}
sub main
$types->{$type} = tl_load_type ($file->{'type'});
if (!$types->{$type})
{
- cluck ("tl_load_type (" . $file->{'type'} . ") failed");
+ warn ("tl_load_type (" . $file->{'type'} . ") failed");
next;
}
}
diff --git a/contrib/collection3/lib/Collectd/Graph/TypeLoader.pm b/contrib/collection3/lib/Collectd/Graph/TypeLoader.pm
index 9078110b3bb3216b9706e9d1cb5246f0177f34ec..5a0b522b424270bd9f819023700a048762eece5e 100644 (file)
$obj = _create_object ($module);
if (!$obj)
{
- cluck ("Creating an $module object failed");
+ #cluck ("Creating an $module object failed");
+ warn ("Creating an $module object failed");
return;
}
}