[rrd-users] Re: stdout with mod_perl and rrdtool

Philip Molter philip at datafoundry.net
Fri Sep 8 16:14:08 MEST 2000

On Fri, Sep 08, 2000 at 03:42:23PM +0300, Osmo Paananen wrote:
: Hi!
: I'm using rrdtool as perl shared module with mod_perl.
: It seems that if I supply "-" as the name of the output graph name
: the data won't end up to the socket returned by apache.
: If I run the perl script as CGI then all works fine.
: If I run apache with -X flag, I get the PNG I wanted to
: the window where I started the server.
: I'm not fully aware whose problem this is.  Should I blame apache, mod_perl
: or rrdtool?

Blame both mod_perl and rrdtool.  Don't blame Apache.  It's an
innocent bystander.  My details may be a bit sketchy, but the gist
of it is this:

mod_perl reopens STDOUT on an anonymous file descriptor (if you
look at a truss of a mod_perl-httpd process, you'll notice that
what's being sent to your web browser is usually on fd 6, 7, etc.).
The perl rrd functions use the rrd c functions/libraries to do
their work, and it appears they're printing directly to fd 1, which
as we all know, is what STDOUT /should/ be.

There's two fixes.  One, remap file descriptor 1 to mod_perl's
STDOUT fd in your perl script (more trouble, IMO).  Two, print the
image to a temporary file, open it, print it, close it, unlink it
(less trouble, IMO).  We use the second option in the office and
it works quite well.

* Philip Molter
* DataFoundry.net
* http://www.datafoundry.net/
* philip at datafoundry.net

Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-users mailing list