SVG graphs?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
phila
Posts: 20
Joined: Fri Mar 07, 2008 3:47 pm

SVG graphs?

Post by phila »

Anybody have SVG graph format working?
I enabled it under graph template, and try to view the graph page, but all the graphs are not being displayed at all.
I`m using Firefox 2.0.0.12, Cacti 0.8.7b and rrdtool 1.2.23

Thanks,
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Is firefox able to display SVG by default?
Reinhard
phila
Posts: 20
Joined: Fri Mar 07, 2008 3:47 pm

Post by phila »

At least according to this:
http://www.mozilla.org/projects/svg/
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

I just tried this too (didn't even know the option was there!) and I get missing images. However, if I take the image URL from the HTML source and go to that in my browser, I get:

Code: Select all

The image “http://wotsit.thingy.com/cacti/graph_image.php?action=view&local_graph_id=45&rra_id=1” cannot be displayed, because it contains errors.
and if I look at the source of that, then it's a sensible-looking SVG document. If I take that document, paste it into a file, and then open it, I get a blank Cacti graph.

I guess the SVG is bad, but the validator is down, and svg2png (from Cairo) core dumps on the file.
Attachments
svg-borked.png
svg-borked.png (14.55 KiB) Viewed 9923 times
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
phila
Posts: 20
Joined: Fri Mar 07, 2008 3:47 pm

Post by phila »

Bump, anybody seen this working?
The interest here is to move the graph rendering CPU load from Cacti server to the client, as I understand this creating an SVG is less CPU intensive then PNG.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Seems this would be an issue with RRDTool.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

phila wrote:Bump, anybody seen this working?
The interest here is to move the graph rendering CPU load from Cacti server to the client, as I understand this creating an SVG is less CPU intensive then PNG.
I doubt it'd make *that* much difference - rrdtool still has to do all the I/O to get the data in the first place.

(completely untested assumption though - run 1000 graphs off with a shell script and time(1), and see what happens, I guess :-) )
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
phila
Posts: 20
Joined: Fri Mar 07, 2008 3:47 pm

Post by phila »

It looks like that the MIME Content-type on the SVG images is hard-coded to image/png in graph_image.php, when it should be image/svg-xml. If I change the graph type to SVG and change the MIME type, it works.
Only now there is a matter of Firefox crashing.

Probably not a bad idea to have the MIME type follow the graph type, my PHP skills are not that good, maybe somebody will submit a patch.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Now, that is a bug, please submit a bug about the Mime type miss match.

http://www.cacti.net/bugs.php
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
phila
Posts: 20
Joined: Fri Mar 07, 2008 3:47 pm

Post by phila »

Done. BugID #0001209
pickle
Posts: 1
Joined: Wed Jan 18, 2012 5:37 pm

Re: SVG graphs?

Post by pickle »

I hate to necro-post, but this is the first entry in Google when searching for this topic, so I figure this is the best place to post my patch.

It would seem that Cacti 0.8.8 does have this patched, but the patch was committed in 2008 and we still don't have this fixed. Fortunately I'm versed enough in PHP to make my own, simple patch.

This patch will only work in PHP 5.3+, as it uses the FileInfo extension. Rather than simply dumping the graph image data to the screen, the data is stored in a variable, which is then read by the FileInfo extension, and the MIME type gets discovered. The newly discovered MIME type is then sent to the browser instead of the default image/png

The file to edit is graph_image.php.

About 1/3 the way down (line 42), comment out the header line. It should look like:

Code: Select all

#header("Content-type: image/png");
This will stop graph_image.php from acting like all graphs are PNG files.

Then, at the bottom, comment out the print line. It should look like:

Code: Select all

#print @rrdtool_function_graph($_GET["local_graph_id"], (array_key_exists("rra_id", $_GET) ? $_GET["rra_id"] : null), $graph_data_array);
Add this below the newly commented out "print" line:

Code: Select all

/* Get the graph data */
$output = @rrdtool_function_graph($_GET["local_graph_id"], (array_key_exists("rra_id", $_GET) ? $_GET["rra_id"] : null), $graph_data_array);  
 
/* Determine the format */
$finfo = new finfo(FILEINFO_MIME);
list($mime,$charset) = explode(';',$finfo->buffer($output));         
        
/* Output the appropriate header */
header('Content-type: '.$mime);        

echo $output;
Hopefully this helps someone.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: SVG graphs?

Post by BSOD2600 »

pickle:
Please create a bug for this feature request and reference this post. http://www.cacti.net/bugs.php
dzm
Posts: 12
Joined: Thu May 20, 2010 6:44 pm

Re: SVG graphs?

Post by dzm »

pickle wrote:I hate to necro-post, but this is the first entry in Google when searching for this topic, so I figure this is the best place to post my patch.

It would seem that Cacti 0.8.8 does have this patched, but the patch was committed in 2008 and we still don't have this fixed. Fortunately I'm versed enough in PHP to make my own, simple patch. [...]

Hopefully this helps someone.
Thank you for this. Saved me much time trying to figure out why png graphs worked fine but svg graphs puked.
begemoti
Posts: 15
Joined: Tue Apr 03, 2007 6:05 am
Location: Gudauri, Georgia

Re: SVG graphs?

Post by begemoti »

pickle wrote:I hate to necro-post, but this is the first entry in Google when searching for this topic, so I figure this is the best place to post my patch.

It would seem that Cacti 0.8.8 does have this patched, but the patch was committed in 2008 and we still don't have this fixed. Fortunately I'm versed enough in PHP to make my own, simple patch.

This patch will only work in PHP 5.3+, as it uses the FileInfo extension. Rather than simply dumping the graph image data to the screen, the data is stored in a variable, which is then read by the FileInfo extension, and the MIME type gets discovered. The newly discovered MIME type is then sent to the browser instead of the default image/png

The file to edit is graph_image.php.

About 1/3 the way down (line 42), comment out the header line. It should look like:

Code: Select all

#header("Content-type: image/png");
This will stop graph_image.php from acting like all graphs are PNG files.

Then, at the bottom, comment out the print line. It should look like:

Code: Select all

#print @rrdtool_function_graph($_GET["local_graph_id"], (array_key_exists("rra_id", $_GET) ? $_GET["rra_id"] : null), $graph_data_array);
Add this below the newly commented out "print" line:

Code: Select all

/* Get the graph data */
$output = @rrdtool_function_graph($_GET["local_graph_id"], (array_key_exists("rra_id", $_GET) ? $_GET["rra_id"] : null), $graph_data_array);  
 
/* Determine the format */
$finfo = new finfo(FILEINFO_MIME);
list($mime,$charset) = explode(';',$finfo->buffer($output));         
        
/* Output the appropriate header */
header('Content-type: '.$mime);        

echo $output;
Hopefully this helps someone.
It works on 0.8.8h
Thank you very much
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: SVG graphs?

Post by Osiris »

Cacti 1.0 is very happy with SVG.
Before history, there was a paradise, now dust.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests