Nectar showing wrong graph in email preview

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
avantat
Posts: 25
Joined: Fri Jun 20, 2014 2:29 pm

Nectar showing wrong graph in email preview

Post by avantat »

Hi,

I'm encountering a strange problem in nectar. I set up a report with 2 different items. When I preview the report everything looks good. In the log file I can see the correct graphs as well (debug level). When the email is sent, in the body of the email the first graph is repeated, no matter what other items I chose. When I click on the graph it links to the correct one.
I hope this picture explains it better:
nectar.jpg
nectar.jpg (61.64 KiB) Viewed 2153 times
If I set it to attach the graphs, they are correct.

I'm running PIA3.1, nectar 0.35a, cacti 0.8.8b. Windows install, using exchange as mail server (smtp)
Appreciate any help.
Yuffie
Posts: 1
Joined: Tue Jul 22, 2014 8:54 pm

Re: Nectar showing wrong graph in email preview

Post by Yuffie »

Hi Avantat,
I have the same problem, did you find a solution?
Thanks~
avantat
Posts: 25
Joined: Fri Jun 20, 2014 2:29 pm

Re: Nectar showing wrong graph in email preview

Post by avantat »

Unfortunately not. I works if I attach the pictures to the email vs inline, but I would like it better inline.
dvc
Posts: 18
Joined: Mon Apr 29, 2013 12:44 am

Re: Nectar showing wrong graph in email preview

Post by dvc »

avantat wrote:Hi,

I'm encountering a strange problem in nectar. I set up a report with 2 different items. When I preview the report everything looks good. In the log file I can see the correct graphs as well (debug level). When the email is sent, in the body of the email the first graph is repeated, no matter what other items I chose. When I click on the graph it links to the correct one.

If I set it to attach the graphs, they are correct.

I'm running PIA3.1, nectar 0.35a, cacti 0.8.8b. Windows install, using exchange as mail server (smtp)
Appreciate any help.
We had the same problem, seems to only affect Windows. The problem is in the <cacti_dir>plugins\settings\include\mailer.php file.
There is a function called content_id() which (on Windows) will return the same ID number as the previous invocation if it is called again too quickly. I didn't measure how quickly but unless separated by some hundredths of seconds it will return the same ID. The problem relates to how the PHP function microtime() operates on Windows. The ID numbers returned by that function are used by the mailer to tag the inline content so if they are the same, you will see the same graph repeated.

Around line 463 find the function:

Code: Select all

function content_id() {

    list($usec, $sec) = explode(" ", microtime());
    $usec = $usec * 10000000;

    return getmypid() . "_" . $sec . "_" . $usec . "@" . $this->Config["Hostname"];

}
and change it to:

Code: Select all

function content_id() {

    list($usec, $sec) = explode(" ", microtime());
    $usec = $usec * 10000000;
		
    $randVal = mt_rand(1000, 900000);

    return getmypid() . "_" . $sec . "_" . $usec . "_" . $randVal . "@" . $this->Config["Hostname"];

}
You can set the MIN/MAX parameters for mt_rand() to whatever you feel is adequate. The developers may implement a better fix in the future but for now that fixed it for us.
avantat
Posts: 25
Joined: Fri Jun 20, 2014 2:29 pm

Re: Nectar showing wrong graph in email preview

Post by avantat »

Thanks dvc, that solved the issue for us as well.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests