Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


[HOWTO] JPEG support in Cacti & Thold using ImageMagick

 
Post new topic   Reply to topic    Cacti Forum Index -> Informational/HOWTO's
Author Message
kschlegelmilch



Joined: 03 May 2006
Posts: 3

PostPosted: Tue Jul 24, 2007 4:55 pm    Post subject: [HOWTO] JPEG support in Cacti & Thold using ImageMagick Reply with quote

My cellphone only supports JPG, so in order to get the image sent as JPG I downloaded ImageMagick (http://www.imagemagick.org/script/index.php) and then modified the thold-functions.php and modified the following lines (line numbers might be off a bit, but you'll get close enough). I've also attached the modified file. Make sure you backup your old file before using this one.

The tmpdir can be anywhere but must pretty much have rw-rw-rw- for it to work. At first I tried the /tmp, but it didn't work.

line 91:

$file_array = array(0 => array('local_graph_id' => $graph_id, 'rra_id' => 0, 'file' => "$httpurl/graph_image.php?local_graph_id=$graph_id&rra_id=0&graph_height=100&graph_width=250",'mimetype'=>'image/jpg','filename'=>"$graph_id"));

line 785:

$graph_data_array = array("output_flag" => RRDTOOL_OUTPUT_STDOUT, "graph_height" => 100, "graph_width" => 250);

line 788:

// adding jpg support
$tmpdir = "/usr/local/apache2/htdocs/cacti/plugins/thold/tmp/";
$pngfile = $tmpdir.$val['filename'].".png";
$jpgfile = $tmpdir.$val['filename'].".jpg";
$handle = fopen($pngfile,'w+');
fwrite($handle, $data);
fclose($handle);
$command = "/usr/local/bin/convert ".$pngfile." ".$jpgfile;
exec($command);
$jhandle = fopen($jpgfile,'r');
$jdata = fread($jhandle, filesize($jpgfile));
fclose($jhandle);
$cid = md5(uniqid(time()));
$mail->AddStringEmbedAttachment($jdata, $val['filename'].'.jpg', $cid, 'base64', $val['mimetype']); // optional name
// adding jpg support



thold-functions.zip
 Description:
Updated thold-functions.php

Download
 Filename:  thold-functions.zip
 Filesize:  8.77 KB
 Downloaded:  111 Time(s)



Last edited by kschlegelmilch on Wed Jul 25, 2007 10:59 am; edited 4 times in total
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5453
Location: Wisconsin, USA

PostPosted: Tue Jul 24, 2007 5:08 pm    Post subject: Reply with quote

Strange, what cell phone is this?
Back to top
kschlegelmilch



Joined: 03 May 2006
Posts: 3

PostPosted: Tue Jul 24, 2007 5:23 pm    Post subject: Reply with quote

rony wrote:
Strange, what cell phone is this?

Samsung Trace

I would get the link, but no PNG image.

This would also help the Lotus Notes people too. I guess email in Lotus Notes doesn't support inline PNG images either.
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5453
Location: Wisconsin, USA

PostPosted: Wed Jul 25, 2007 8:48 am    Post subject: Reply with quote

Lotus Notes doesn't support png at all.

I find this interesting and may add this to the mailer class I wrote for the PIA.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Informational/HOWTO's All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group