[rrd-users] Re: RRDs::graph and mod_perl

Todd Caine todd_caine at eli.net
Wed Aug 2 02:03:21 MEST 2000


Check this out:

I just installed Perl 5.6 with sfio (safe and fast I/O) instead of stdio.
The was no difference in the way the script was handled.
I did see something interesting in the output of truss though: (edited from
brevity)

#  A socket is created using file descriptor #3
getsockname(3, 0xFFBEF860, 0xFFBEF874, 1)       = 0
setsockopt(3, 6, 1, 0xFFBEF7C4, 4, 1)           = 0
alarm(300)                                      = 0

#  Here is the HTTP GET request on the socket using fd #3
read(3, " G E T   / p e r l / i m".., 4096)     = 362

#  Now the script that was requested gets opened on file descriptor #4
stat64("/usr/local/mod_perl/image_out.cgi", 0x003AECD8) = 0
open64("/usr/local/mod_perl/image_out.cgi", O_RDONLY) = 4
fstat64(4, 0xFFBED058)                          = 0
ioctl(4, TCGETA, 0xFFBECFE4)                    Err#25 ENOTTY
read(4, " # ! / u s r / l o c a l".., 8192)     = 3815
read(4, 0x007E400C, 8192)                       = 0
llseek(4, 0, SEEK_CUR)                          = 3815
close(4)                                        = 0

#  Apache sends the status code 200 indicating success
write(3, " H T T P / 1 . 1   2 0 0".., 186)     = 186

#  The RRD file gets opened on file descriptor #4
open("/usr/local/router/data/some_router/srp000.rrd", O_RDONLY) = 4
read(4, " R R D\0 0 0 0 1\0\0\0\0".., 8192)     = 8192
llseek(4, 0, SEEK_CUR)                          = 8192
lseek(4, 8428, SEEK_SET)                        = 8428
read(4, "7FFFFFFFFFFFFFFF7FFFFFFF".., 8192)     = 8192
lseek(4, 2796, SEEK_SET)                        = 2796
read(4, "7FFFFFFFFFFFFFFF7FFFFFFF".., 8192)     = 8192
llseek(4, 0xFFFFFFFFFFFFF600, SEEK_CUR)         = 8428
close(4)                                        = 0

#  Now the interesting part;  Instead of writing the image to the socket (file
descriptor #4)
#  it writes to stdout or file descriptor #1
ioctl(1, TCGETA, 0xFFBEE4EC)                    = 0
write(1, " G I F 8 7 aB7021001B3\0".., 1024)    = 1024
write(1, "\f rD2 j /CE zF3EE ?188A".., 441)     = 441

#  Apache writes to the access_log
write(19, " 10.0.0.1".., 148)    = 148

#  Now the child process blocks on accept waiting for another request
accept(16, 0xFFBEF850, 0xFFBEF874, 1) (sleeping...)

Well now with all that said, I still don't know why it is not printing to the
socket or file descriptor #4.
I looked through rrd_graph.c and noticed that it seems to be writing to
'stdout' for files named '-'.
Although for some reason I think apache is sending this to a tty.  When I
started apache as a standalone
server process using:

httpd -X

then used truss to trace the output using:

truss -p <pid of httpd -X> >/tmp/output 2>&1

I reloaded the web page that should have generated the image, but instead I
received the raw data on my
terminal that started up httpd.  Any ideas of where to go from here?

Cheers,
Todd



Philip Molter wrote:

> On Tue, Aug 01, 2000 at 11:56:52PM +0200, Tobias Oetiker wrote:
> :
> : Today you sent me mail regarding [rrd-users] RRDs::graph and mod_perl:
> :
> : *>
> : *> I'm using RRDs with mod_perl on a Solaris 8 box with
> : *> Apache/mod_perl and perl 5.6.0.  The call to RRDs::graph is made
> : *> with various arguments to print to a file on STDOUT.  RRDs reports
> : *> no error, but no graph information is sent to STDOUT.  This process
> : *> works fine without mod_perl.  I've attached the part of a truss
> : *> output where the problem appears to be occurring.  Any ideas?  I
> : *> know I could output to a temporary file, print the contents of the
> : *> temporary file, and then unlink the file (how Bronc does it), but
> : *> that's extremely inefficient.
> :
> : with out seeing the relevant script his is difficult to judge, but
> : you may want to take a look at the example scripts to see how to
> : get data back from the RRDs::graph function
>
> Well, I can give you a quick synopsis, which should adequately
> explain what's going on, if maybe that will help.  I think, though,
> from a previous post, it's an issue with how mod_perl handles system
> calls and printing to stdout.
>
> The script is something like:
>
>   #!perl
>
>   print "Content-Type: image/png\n\n";
>   # graph to stdout, not to a file .. stdout in our web script would
>   # go to the browser, of course
>   RRDs::graph( '-', '-aPNG', @otherargs );
>   exit 0;
>
> And then the web page would do something like
>
>   <img src="/cgi-bin/rrdimage.pl" alt="">
>
> Under normal CGI, this works fine, but under mod_perl the browser
> gets no information and no error.  mod_perl is probably trapping
> the stdout output because of the way that the module tries to write
> to stdout.  The real question is, is that something that can be
> rewritten so as not to require a recompile of perl with sfio?  I'm
> not real keen on the idea of printing to a temp file, opening the
> temp file, printing the temp file to the web browser, closing the
> temp file and finally deleting the temp file.
>
> : *> -----TRUSS OUTPUT-----
> : *> # Printing out debug before the graph call begins
> : *> 10909:  write(2, " -\n - a P N G\n - h   1".., 1140)    = 1140
> : *> 10909:  write(2, "\n", 1)                               = 1
> : *> 10909:  time()                                          = 965141926
> : *> 10909:  time()                                          = 965141926
> : *> 10909:  time()                                          = 965141926
> : *> 10909:  open("CPU-cpu.rrd", O_RDONLY)  = 6
> : *> 10909:  fstat64(6, 0xFFBEE220)                          = 0
> : *> 10909:  ioctl(6, TCGETA, 0xFFBEE1AC)                    Err#25 ENOTTY
> : *> 10909:  read(6, " R R D\0 0 0 0 1\0\0\0\0".., 8192)     = 8192
> : *> 10909:  llseek(6, 0, SEEK_CUR)                          = 8192
> : *> 10909:  lseek(6, 3569352, SEEK_SET)                     = 3569352
> : *> 10909:  lseek(6, 196296, SEEK_SET)                      = 196296
> : *> 10909:  read(6, " @ %A6AE9A06 0F8 @  87BB".., 8192)     = 8192
> : *> 10909:  read(6, " @11BE z v\b E ` @10FC m".., 8192)     = 8192
> : *> 10909:  llseek(6, 0xFFFFFFFFFFFFE420, SEEK_CUR)         = 205544
> : *> 10909:  close(6)                                        = 0
> : *> 10909:  brk(0x0060B000)                                 = 0
> : *> 10909:  brk(0x00625800)                                 = 0
> : *> 10909:  ioctl(1, TCGETA, 0xFFBEDFDC)                    Err#6 ENXIO
> : *> 10909:  fstat64(1, 0xFFBEE050)                          = 0
> : *> 10909:  brk(0x00641000)                                 = 0
> : *> 10909:  brk(0x0065D800)                                 = 0
> : *> 10909:  write(2, " g r a p h :   W e   p r".., 31)      = 31
> : *> 10909:  write(2, "\n", 1)                               = 1
> : *> # Printing out debug after the graph call finishes
>
> * Philip Molter
> * Data Foundry International
> * 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

--
--------------------------------------------------------------

 <!-- Todd Caine - tcaine at eli.net
  Software Engineer
  Electric Lightwave, Inc.
  4400 NE 77th Avenue
  Vancouver, WA 98662
  Direct Dial: (360) 816-4344  //-->

--------------------------------------------------------------



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