Nectar - Events Issues (times and dates)

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

noje
Posts: 4
Joined: Fri Apr 23, 2010 5:59 am

Post by noje »

That's the point, format has always been set to day, month, year.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Ok, I did not have a problem right now. But it's time to re-investigate
R.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I've still not found the issue. But the attached tgz will help logging.

Unpack as usual.
Then, please save ./plugins/settings/include/mailer.php.
Copy ./plugins/nectar/0.8.7g/mailer.php to ./plugins/settings/include/mailer.php

Goto Settings -> Misc and set NECTAR logging level to at least MEDIUM. Now, you'll find NECTAR messages in log/cacti.log. It will log each call to the internal datetime function and more. Please provide those lines after a new try

R.

Unfortunately, I had to fix two errors that dropped in due excessive copying between different directories on my laptop.
Please drop old code and replace by the new
Attachments
nectar-v0.28b6.tgz
UPDATED CODE

untar as usual
copy 0.8.7g/mailer.php to plugins/settings/include/mailer.php
(61.56 KiB) Downloaded 3127 times
noje
Posts: 4
Joined: Fri Apr 23, 2010 5:59 am

Post by noje »

Thanks R,
At the moment I cannot introduce any changes in the Cacti server as it is production environment in my company. I will try as soon as possible and i'll let you know the results.
TAM
Posts: 2
Joined: Wed Jan 19, 2011 6:29 pm

Re: Nectar - Events Issues (times and dates)

Post by TAM »

I see the same issue, every time I make a change to anything on the page and save, the mailtime reverts to the current date/time.

Anyone else still having this issue?

Just installed Nectar yesterday 0.30 (replaced mailer.php file)
Cacti Version - 0.8.7g
Plugin Architecture - 2.8
Poller Type - Cactid v
Troy
TAM
Posts: 2
Joined: Wed Jan 19, 2011 6:29 pm

Re: Nectar - Events Issues (times and dates)

Post by TAM »

I changed my users Graph Date Display Format from "Month Name, Day, Year" to "Month Number, Day, Year" and that appears to have corrected the issue.
User avatar
Selenius
Posts: 27
Joined: Mon Jun 29, 2009 5:21 am

Re: Nectar - Events Issues (times and dates)

Post by Selenius »

Hello!

Regardless of the graphs' settings, plugin only takes format "Month Number/Day/Year".
If you use any other format for input in a "Next Timestamp for sending Mail Report", it doesn't work.

P. S. My version is 0.30.
ProfAnthrax
Posts: 4
Joined: Wed May 16, 2012 3:38 am

Re: Nectar - Events Issues (times and dates)

Post by ProfAnthrax »

Has this been resolved at all?
I'm seeing the same problem (Next timestamp changes to current system date and time) and need to know how to resolve.


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

Re: Nectar - Events Issues (times and dates)

Post by gandalf »

Please provide you exact time format and the settings of the related nectar report. I'll (hopefully) try to reproduce the issue, then
R.
pabloc
Posts: 2
Joined: Wed Feb 27, 2013 1:36 pm
Location: Buenos Aires, Argentina
Contact:

Re: Nectar - Events Issues (times and dates)

Post by pabloc »

Dear Sirs,

(First of all, it's my first time I post something to the forum - I really like Cacti/plugins a lot).

I was doing some research (try & error + analizing code) because I had the some problem. Just to give my 2 cent's:
  • - I faced the same problem with Non-US date/time formats. (In Argentina, we use 'dd-mm-yyyy hh:mm:ss'). Common date separators: slash char '/', dash char '-'.
    - The problem (I think so) has relationship with PHP's strtotime behaviour: http://php.net/manual/en/function.strtotime.php.
Proof of concept:

Code: Select all

<?php

$it_doesnt_work_mailtime="27/02/2013 09:00:00";
$it_works_mailtime="02/27/2013 09:00:00";
$it_works2_mailtime="27-02-2013 09:00:00";

print "This string do not work: ".$it_doesnt_work_mailtime."\n";
$timestamp=strtotime($it_doesnt_work_mailtime);
if ($timestamp=="") { $timestamp="empty"; };
print "timestamp: $timestamp\n";
print "\n";

$timestamp=strtotime($it_works_mailtime);
if ($timestamp=="") { $timestamp="empty"; };
print "This string works: ".$it_works_mailtime."\n";
print "timestamp: $timestamp\n";

$timestamp=strtotime($it_works_mailtime);
if ($timestamp=="") { $timestamp="empty"; };
print "This string works too: ".$it_works2_mailtime."\n";
print "timestamp: $timestamp\n";

?>
Look inside the following paragraph, the 'note' (taken from http://php.net/manual/en/function.strtotime.php)
Note:

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.
Yes, you're right. 'strtotime' function doesn't work as expected.

There is no easy way for the function 'strtotime' to avoid 'guessing' the right format (Personally, I think it's better to use ISO 8601 format, at least for internal uses).
You can get rid of this problem with some new features from php >= 5.3.0. Also you can get rid of this problem by using some 'C' alike functions for php (but they don't work with MS Windows)


Here it goes a patch for this date/time format issue which tries to avoid those known problems: (Hope it helps - Tested on Cacti 0.8.8a + Nectar plugin v0.35a)
nectar-v0.35a_sanitize_datetime_strings.patch.gz
Patch for php's strtotime issue.
(1.32 KiB) Downloaded 2951 times
Download and apply with:

gzip -dc nectar-v0.35a_sanitize_datetime_strings.patch.gz | patch -p0

Note: I'm running Cacti v0.8.8a + Spine v0.8.8 + plugins (including Nectar v0.35a) on a FreeBSD 8.3p4 box at work.

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

Re: Nectar - Events Issues (times and dates)

Post by gandalf »

I will consider this on the next update cycle. But I will have to test as well
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests