[rrd-users] Re: Outputting a PNG directly from Perl + RRDs.pm

Tobias Oetiker oetiker at ee.ethz.ch
Fri Jan 14 07:29:13 MET 2000


Yesterday you sent me mail regarding [rrd-users] Outputting a PNG directly...:

*> Hi,
*> 
*> I'm having trouble getting a perl program (using the RRDs module) to output 
*> a PNG directly.   What I would like to be able to do is create a CGI script 
*> (running under mod_perl) that will spit out "Content-type: image/png" 
*> followed by a graph.  I'm going to eventually call it like this within HTML:
*> 
*> 	<IMG SRC="/mp-bin/graphgen?host=utah.citysearch.com">
*> 
*> and it would spit out a graph for the "host".
*> 
*> The problem is, I can't seem to make the perl module spit out an image 
*> directly.  It seems to want to write it to a file instead.  I tried using 
*> "-" as a filename but it didn't spit out anything.  Any ideas?
*> 
*> Here's what I have so far:
*> 
*> package SLUG::Slime;
*> # File: SLUG/Slime.pm
*> 
*> use strict;
*> use Apache;
*> use Apache::Constants qw( :common :response );
*> 
*> # The Shared RRDtool module
*> use RRDs;
*> 
*> sub handler {
*>          # get request object
*>          my $r = shift;
*>          my $RRD_FILES = "/opt/slug/rrd_files";
*>          $r->content_type('image/png');
*>          my ($graphret,$xsize,$ysize) = RRDs::graph "-", "--title",
*>          'SFOCA Real Server Sessions', '--vertical-label', 'SESSIONS',
*>          '--start', '-65000',
*>          "DEF:ireland=${RRD_FILES}/sfoca27i-sessions.rrd:sfoca27i:AVERAGE",
*>          "DEF:nantucket=${RRD_FILES}/sfoca27n-sessions.rrd:sfoca27n:AVERAGE",
*>          "LINE2:ireland#215e21:ireland",
*>          "LINE2:nantucket#ff0000:nantucket";
*>          return OK;

the image will be returned to stdout ... I just verified with 1.0.10 ... go
into the examples directory and edit the bigtops.pl file ... change the name
in the RRDs::graph line to read "-" ... your problem lies elsewhere I guess.

cheers
tobi
-- 
 ______    __   _
/_  __/_  / /  (_) Oetiker, Timelord & SysMgr @ EE-Dept ETH-Zurich
 / // _ \/ _ \/ / TEL: +41(0)1-6325286  FAX:...1517  ICQ: 10419518 
/_/ \.__/_.__/_/ oetiker at ee.ethz.ch http://ee-staff.ethz.ch/~oetiker

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



More information about the rrd-users mailing list