no web graphs; v0.8.6i/FreeBSD-6.1/apache-2.2.3/php-5.2.0

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
stanos
Posts: 1
Joined: Fri Dec 15, 2006 12:08 pm
Location: San Francisco, CA

no web graphs; v0.8.6i/FreeBSD-6.1/apache-2.2.3/php-5.2.0

Post by stanos »

No images are displayed from web interface.

Using the command string with rrdtool produces valid .png file.

Using wget to call graph_image.php produces invalid .png file. The file has
one extra character at the beginning.

% od -cx graph* | more
0000000 \n 211 P N G \r \n 032 \n \0 \0 \0 \r I H D
890a 4e50 0d47 1a0a 000a 0000 490d 4448

When webrowser (firefox 2.0) is forced to display only the output of
graph_image.php, it reports the graph data is invalid/corrupt.

% file graph.dat
graph.dat: data

Removing 1st byte from wget output file results in valid .png file.

% dd if=graph.dat of=graph.png bs=1 skip=1
33789+0 records in
33789+0 records out
33789 bytes transferred in 0.332567 secs (101601 bytes/sec)
% file graph.png
graph.png: PNG image data, 597 x 255, 8-bit/color RGBA, non-interlaced

The adjusted file graph.png is viewable using a webrowser (firefox 2.0).

Debbuging lib/rrd.php shows that the extra byte is not in
the image produced by the functions in this file.

graph_image.php is minimal and has no obvious place where it produces
an "\n" prior to outputing the data created by this script.

print rrdtool_function_graph($_GET["local_graph_id"], $_GET["rra_id"], $graph_data_array);

I found reports regarding older versions of PHP having a bug that placed
an extra byte at the end of HTTP headers, just before any data that follows
the headers. Has this bug returned, or is there something I have missed and
should be doing differently?

Since wget is able to pull an almost correct image file using graph_image.php,
the web interface is working to call the scripts and produce outout.

Any advice on how to proceed would be greatly appreciated.
Criggie
Posts: 16
Joined: Sat Jul 21, 2007 4:30 am
Location: Christchurch, New Zealand
Contact:

Re: no web graphs; v0.8.6i/FreeBSD-6.1/apache-2.2.3/php-5.2

Post by Criggie »

I'm having almost exactly the same problem four years later.

This is what I get after doing a wget on an url like this

Code: Select all

wget -c "http://localhost/cacti/graph_image.php?local_graph_id=37&rra_id=0&view_type=tree&graph_start=1287020120&graph_end=1287021920" -o bad.png

$ strings bad.png  | head -5 
\0\0\0
IHDR\0\0
\0\0\0
\0\0\0f
\0\0\0ItEXtSoftware\0RRDtool, Tobias Oetiker <tobi@oetike.ch>, http://tobi.oetiker.ch

$ file bad.png 
bad.png: PNG image data, 1212437084 x 811347971, 135-bit

$ ll bad.png 
-rw-r--r-- 1 criggie Users  22023 Oct 14 15:07 bad.png

$ od -a bad.png   | head
0000000  ht   P   N   G  cr  nl sub  nl   \   0   \   0   \   0  cr   I
0000020   H   D   R   \   0   \   0 etx bel   \   0   \   0   \   0   f
0000040  bs ack   \   0   \   0   \   0   f   -   p   t   \   0   \   0
0000060   \   0   I   t   E   X   t   S   o   f   t   w   a   r   e   \
0000100   0   R   R   D   t   o   o   l   ,  sp   T   o   b   i   a   s
0000120  sp   O   e   t   i   k   e   r  sp   <   t   o   b   i   @   o
0000140   e   t   i   k   e   .   c   h   >   ,  sp   h   t   t   p   :
0000160   /   /   t   o   b   i   .   o   e   t   i   k   e   r   .   c
0000200   h etx   \   \   a   `   \   0   \   0  sp   \   0   I   D   A
0000220   T   x soh   m  gs   { dle  gs   E   y   v   1 eot   e   !  bs

The rrds are all updating fine, and manually running a command like this

Code: Select all

/usr/bin/rrdtool graph - --imgformat=PNG --start=-86400 --end=-300 --title='testing for Criggie 3T - Ping Latency' --base=1000 --height=120 --width=800 --alt-autoscale-max --lower-limit=0 --vertical-label='milliseconds' --slope-mode --font TITLE:9: --font AXIS:8: --font LEGEND:8: --font UNIT:8: DEF:a="/var/www/html/cacti/rra/testhing_for_cf_3t_ping_1053.rrd":ping:AVERAGE AREA:a#FFF200FF:""  GPRINT:a:LAST:"Current\:%8.2lf %s"  GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  GPRINT:a:MAX:"Maximum\:%8.2lf %s"  > good.png
works fine and produces a good valid PNG file.

This good file is

Code: Select all

# strings good.png  | head -5 
IHDR
ItEXtSoftware
RRDtool, Tobias Oetiker <tobi@oetike.ch>, http://tobi.oetiker.ch
IDATx
B@ ,

# od -a good.png   | head
0000000  ht   P   N   G  cr  nl sub  nl nul nul nul  cr   I   H   D   R
0000020 nul nul etx bel nul nul nul   J  bs ack nul nul nul syn   C   5
0000040   9 nul nul nul   I   t   E   X   t   S   o   f   t   w   a   r
0000060   e nul   R   R   D   t   o   o   l   ,  sp   T   o   b   i   a
0000100   s  sp   O   e   t   i   k   e   r  sp   <   t   o   b   i   @
0000120   o   e   t   i   k   e   .   c   h   >   ,  sp   h   t   t   p
0000140   :   /   /   t   o   b   i   .   o   e   t   i   k   e   r   .
0000160   c   h etx   \   a   ` nul nul  sp nul   I   D   A   T   x soh
0000200   m  gs  ht   |  fs   U nak   o soh   h   # eot   e  ht   ( esc
0000220   ,   " eot  bs eot etx   H   "  vt   F   p   x   c  sp ack   A
The box is a modern IBM running centos 5.5, running cacti-0.8.7f and rrdtool-1.2.23-1.el5.rf
I have the exact same versions installed on other boxes perfectly.
Criggie
Posts: 16
Joined: Sat Jul 21, 2007 4:30 am
Location: Christchurch, New Zealand
Contact:

SOLVED no web graphs; v0.8.6i/FreeBSD-6.1/apache-2.2.3/php-5

Post by Criggie »

Well I hate it when searching a post and finding a dozen copies of the same posting, all with no answer.

So after almost a year, here's the answer that solved my problem.
In /etc/php.ini

Code: Select all

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off  


Not hard, but it was totally impossible to spot.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests