[mrtg] Re: mrtg-rrd and mod_perl configuration

Corey Smith csmith at bonddesk.com
Mon Feb 23 16:57:44 MET 2004


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

Apply this diff or make the changes by hand:

<DIFF>
*** mrtg-rrd.cgi        Mon Feb 25 10:09:09 2002
--- mrtg-rrd.pm Mon Feb 23 10:55:47 2004
***************
*** 1,4 ****
- #!/usr/bin/perl -w
  #
  # $Id: mrtg-rrd.cgi,v 1.17 2002/02/25 15:09:04 kas Exp $
  #
--- 1,3 ----
***************
*** 25,32 ****
--- 24,36 ----
   
  use strict;
   
+ package ModPerl::mrtgrrd;
+
+ use Apache::Constants qw(:common);
+
  use POSIX qw(strftime);
  use Time::Local;
+ use CGI;
   
  # Location of RRDs.pm, if it is not in @INC
  use lib '/usr/lib/perl5/5.00503/i386-linux';
***************
*** 35,49 ****
  use vars qw(@config_files @all_config_files %targets $config_time
        %directories $version);
   
- # EDIT THIS to reflect all your MRTG config files
- BEGIN { @config_files = qw(/home/fadmin/mrtg/cfg/mrtg.cfg
-       /www/html/auth/kas/mrtg.cfg); }
-
  $version = '0.5';
   
! sub handler ($)
! {
!       my ($q) = @_;
   
        try_read_config($q->url());
   
--- 39,52 ----
  use vars qw(@config_files @all_config_files %targets $config_time
        %directories $version);
   
  $version = '0.5';
   
! sub handler {
!       my $q = new CGI;
!
!       # EDIT THIS to reflect all your MRTG config files
!       @config_files = qw(
!       );
   
        try_read_config($q->url());
   
***************
*** 56,62 ****
                } else {
                        print "Location: ", $q->url(-path_info=>1),
"/\n\n";
                }
!               return;
        }
   
        my ($dir, $stat, $ext) = ($q->path_info() =~
--- 59,65 ----
                } else {
                        print "Location: ", $q->url(-path_info=>1),
"/\n\n";
                }
!               return OK; # We must return a status to mod_perl
        }
   
        my ($dir, $stat, $ext) = ($q->path_info() =~
***************
*** 97,102 ****
--- 100,108 ----
        }
        $ENV{TZ} = $oldtz
                if defined $oldtz;
+
+       return OK; # We must return a status to mod_perl
+
  }
   
  sub do_html($)
***************
*** 917,944 ****
        print "Content-Type: text/plain\n\nError: ", join(' ', @_),
"\n";
        exit 0;
  }
-
- #--BEGIN CGI--
- #For CGI, use this:
-
- use CGI;
- my $q = new CGI;
-
- handler($q);
-
- #--END CGI--
- #--BEGIN FCGI--
- # For FastCGI, uncomment this and comment out the above:
- #-# use FCGI;
- #-# use CGI;
- #-#
- #-# my $req = FCGI::Request();
- #-#
- #-# while ($req->Accept >= 0) {
- #-#   my $q = new CGI;
- #-#   handler($q);
- #-# }
- #--END FCGI--
   
  1;
   
--- 923,928 ----
</DIFF>

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>

Good luck.

Corey Smith

On Mon, 2004-02-23 at 10:05, Jim Mozley wrote:
> I'm trying to use mrtg-rrd with mod_perl, but I'm stuck on configuring 
> the script.


--
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