[rrd-users] corrupted PNG files coming out of cacti/apache

C. Falconer cfalconer at totalteam.co.nz
Mon Nov 22 03:50:45 CET 2010

Hi all.

I've had a problem for the past couple of months and its not obvious 
what's at fault.   I'm reasonably sure its not rrdtool though.

Problem:   Cacti shows no graphs.

If I get the rrdtool command line out of cacti's "graph debug" section, 
  and run that at the command line then I get the file at

RRDTool Command:
/usr/bin/rrdtool graph - --imgformat=PNG --start=-86400 --end=-300 
--title='testhing for CF 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: 
GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" 
GPRINT:a:MAX:"Maximum\:%8.2lf %s"

RRDTool Says:


So this works fine when pasted to a command line, and produces a valid 
PNG file.

When I do a wget on the file

wget -c 
-O cacti-bad.png

I get the file at
Which is an invalid PNG file

Now, the two output PNGs differ

PNG image data, 1212437084 x 811347971, 135-bit

PNG image data, 903 x 202, 8-bit/color RGBA, non-interlaced

$ ls -la *png
-rw-r--r-- 1 cfalconer Domain Users 22180 Nov 19 13:34 cacti-bad.png
-rw-r--r-- 1 cfalconer Domain Users 22860 Nov 19 13:35 cacti-good.png

I've put an   od -a  at
to show the differences.

Now if I replace "\0" with nul in that file, its better but still not right.

$ cat cacti-bad.png | sed "s/\\\0/\x00/g"  > cacti-sed.png
$ file cacti-sed.png
PNG image data, 903 x 230, 8-bit/color RGBA, non-interlaced

Therefore something is futzing with the data after it is generated by 

Other diagnostics:

I have duplicated the entire cacti install to another host which is 
similarly configured.  It works perfectly and shows the graphs fine.


Linux, Centos 5.5 running on an IBM x3250 in 32 bit mode

# uname -srmopi
Linux 2.6.18-194.8.1.el5.centos.plusPAE i686 i686 i386 GNU/Linux

# rpm -q rrdtool cacti php-gd httpd php

Firstly I do not think rrdtool is the cause.  I suspect its something to 
do with the way apache's httpd is getting the data back

I have access to other servers configured basically the same way, and 
they're all working fine.

Cacti is continuing to poll correctly in the background.

The problem seems to be rrdtool's output being fiddled before it hits 
the end-user's browser.

Any advice for fixing this would be appreciated.

Craig Falconer
   The Total Team - Secure Networks for Serious Business
   Office: 0800 888 326 / +643 974 9128
   Email: workorder at totalteam.co.nz
   Web: http://www.totalteam.co.nz/

More information about the rrd-users mailing list