[mrtg] Re: mrtg-rrd and mod_perl configuration

Jim Mozley jim.mozley at exponential-e.com
Thu Feb 26 17:20:25 MET 2004


Corey Smith wrote:

> BTW: I'm using mrtg-rrd 0.5.  Latest version is probably very similar...
> 
> Create a directory under the site_perl library path and copy the script
> there Ex.
> 
> /usr/local/lib/perl5/site_perl/5.8.0/ModPerl/mrtg-rrd.pm
> 

<snip>

> 
> Make an entry in your httpd.conf like:
> 
>     PerlModule ModPerl::mrtg-rrd
>     <Location /mrtg-rrd/>
>         SetHandler perl-script
>         PerlHandler ModPerl::mrtg-rrd
>         PerlSendHeader On
>     </Location>
> 
> In your html refer to the CGI like:
> 
>   <a href="/mrtg-rrd/TARGET.html">
>     <IMG VSPACE=10 WIDTH=500 HEIGHT=135 ALIGN=TOP
>      SRC="/mrtg-rrd/TARGET-day.png" ALT="day">
>   </a>

If my understanding is correct then the approach above is to turn the 
CGI script into a perl handler and create some html for each target.

I didn't want to do this; my understanding was that the cgi would read 
the mrtg config file and present a series of targets (with a summary 
graph) that one can connect to.

What I'd imagined was to have something like:

<Directory "/opt/mrtg/cgi-bin/">
         SetHandler perl-script
         PerlHandler Apache::Registry
         #PerlSendHeader On
         AllowOverride AuthConfig
         Options +ExecCGI
         Order allow,deny
         Allow from all
</Directory>

And make an alteration in the CGI to allow it to work under mod_perl.

If I use the suggest configuration for a CGI I get the following errors 
in Apache's error log:

mrtg-rrd.cgi: Variable "$percent_h" will not stay shared at 
/opt/mrtg/cgi-bin/mrtg-rrd.cgi line 400.

mrtg-rrd.cgi: Prototype mismatch: sub 
apache::ROOTmanagement_2eexponential_2de_2enet::mrtg::cgi_2dbin::mrtg_2drrd_2ecgi::handler 
($)vs none at /opt/mrtg/cgi-bin/mrtg-rrd.cgi line 1068.

mrtg-rrd.cgi: Subroutine handler redefined at 
/opt/mrtg/cgi-bin/mrtg-rrd.cgi line 1.

null: Deep recursion on subroutine 
"Apache::ROOTmanagement_2eexponential_2de_2enet::mrtg::cgi_2dbin::mrtg_2drrd_2ecgi::handler" 
at /opt/mrtg/cgi-bin/mrtg-rrd.cgi line 1064.

I assume I have to change:

use CGI;
my $q = new CGI;

# thttpd fix up by Akihiro Sagawa
if ($q->server_software() =~ m|^thttpd/|) {
	my $path = $q->path_info();
	$path .= '/' if ($q->script_name=~ m|/$|);
	$q->path_info($path);
}

handler($q);


To something that mod_perl will accept, the mrtg-rrd faq suggests "just
create the $q object with the path_info() method, and then call a 
handler($q) subroutine". Its this bit that I think I need, but don't 
know enough about mod_perl.

Jim Mozley

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list