2015R2.1 Email link shows wrong time span in some cases

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
polarbear1
Posts: 73
Joined: Mon Apr 13, 2015 4:26 pm

2015R2.1 Email link shows wrong time span in some cases

Post by polarbear1 »

Bug Report Ahoy!

Using PHP Mail (using Postfix 2.6.6) on 2015R2.1.

The link to dashboard behaves really differently depending on the time interval specified in the "Edit an Alert" window for the Lookback Period and Check Interval box:

In the examples below the Lookback was 60 (s/m/h/d) and Check Interval was 30 (s/m/h/d).

Minutes is OK

Code: Select all

See the last 60m in the dashboard: 
http://nlsbox/nagioslogserver/index.php/alerts/show/LkMvdtHuT5yhgSZ8ODCNhA?s_to=2015-07-22T15:17:57Z&s_from=2015-07-22T14:17:57Z 
Seconds - The FROM is stuck in 1970.

Code: Select all

See the last 60s in the dashboard: 
http://nlsbox/nagioslogserver/index.php/alerts/show/LkMvdtHuT5yhgSZ8ODCNhA?s_to=2015-07-22T15:39:41Z&s_from=1970-01-01T00:00:00Z
No Units/Hours - Back to the Future! (The FROM is 30 hours in the future from TO today)
Also - The Text "See the last X in the dashboard" X = Lookback Period. But the time difference in the TO and FROM fields is actually the check interval in this case.

Code: Select all

See the last 60h in the dashboard: 
http://nlsbox/nagioslogserver/index.php/alerts/show/LkMvdtHuT5yhgSZ8ODCNhA?s_to=2015-07-22T15:16:46Z&s_from=2015-07-24T22:16:46Z 
Days - Also OK

Code: Select all

See the last 60d in the dashboard: 
http://nlsbox/nagioslogserver/index.php/alerts/show/LkMvdtHuT5yhgSZ8ODCNhA?s_to=2015-07-22T15:15:44Z&s_from=2015-05-23T15:15:44Z 
Also, the emails coming in the links are no longer clickable. There were no additional changes on our email system as far as I know, so I'm wondering if this is on you.

Side note - the help bubble for the Lookback and Check Interval boxes should indicate that HOURS is the default unit if no unit is specified. Also, the default unit should really probably be seconds.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by jolson »

The lookback period is certainly a bug, and I've reporting it to the developers as such. (NEW TASK ID 6086)
Also, the emails coming in the links are no longer clickable. There were no additional changes on our email system as far as I know, so I'm wondering if this is on you.
Mine are clickable links, I believe this might be on your side. Are you sure that nothing was altered on the mail server/client side of things?
Side note - the help bubble for the Lookback and Check Interval boxes should indicate that HOURS is the default unit if no unit is specified. Also, the default unit should really probably be seconds.
I will bring this up in the bug report.

Thanks for making us aware of this!
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by jolson »

polarbear1,

This bug has been squashed by our devs and tested by yours truly. Please unzip the attached file and place it in /var/www/html/nagioslogserver/application/models/alert.php, overwriting the existing alert.php file. Ensure that the permissions are correct.

Code: Select all

chmod 644 /var/www/html/nagioslogserver/application/models/alert.php
chown root.root /var/www/html/nagioslogserver/application/models/alert.php
After you replace the file, the time span issue should be resolved. Let me know if you notice any quirks. The default period has been changed to 'seconds'.

This file will be included by default in our next release. Thanks!
You do not have the required permissions to view the files attached to this post.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
polarbear1
Posts: 73
Joined: Mon Apr 13, 2015 4:26 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by polarbear1 »

Thanks for the quick turnaround - I can confirm that all time intervals <blank>/s/m/h/d are now working as expected, and that the default interval is now seconds.


As for the non-clickable links. Bit of a mixed bag. Looks like we're doing some updates to our Exchange right now, but links in all my other emails except NLS are coming in as clickable. Furthermore, I just copy-pasted the body of an NLS alert email into a pain text file on the NLS box and sent it using the mail command

Code: Select all

mail -v -s "test email" [email protected] < test_email.txt
and in that test, the link also comes through as clickable. Only as delivered straight from the NLS box does it come in as text.

The timing works too. Going through my alert email folder, the links stopped being clickable on July 15th, the release (and my install) date of 2015R2.0.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by jolson »

Let's see the output of your email.php file:

Code: Select all

head -n50  /var/www/html/nagioslogserver/system/libraries/Email.php
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
polarbear1
Posts: 73
Joined: Mon Apr 13, 2015 4:26 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by polarbear1 »

Code: Select all

[root@schpnag1 ~]# head -n50  /var/www/html/nagioslogserver/system/libraries/Email.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package             CodeIgniter
 * @author              ExpressionEngine Dev Team
 * @copyright   Copyright (c) 2008 - 2014, EllisLab, Inc.
 * @license             http://codeigniter.com/user_guide/license.html
 * @link                http://codeigniter.com
 * @since               Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * CodeIgniter Email Class
 *
 * Permits email to be sent using Mail, Sendmail, or SMTP.
 *
 * @package             CodeIgniter
 * @subpackage  Libraries
 * @category    Libraries
 * @author              ExpressionEngine Dev Team
 * @link                http://codeigniter.com/user_guide/libraries/email.html
 */
class CI_Email {

        var     $useragent              = "CodeIgniter";
        var     $mailpath               = "/usr/sbin/sendmail"; // Sendmail path
        var     $protocol               = "mail";       // mail/sendmail/smtp
        var     $smtp_host              = "";           // SMTP Server.  Example: mail.earthlink.net
        var     $smtp_user              = "";           // SMTP Username
        var     $smtp_pass              = "";           // SMTP Password
        var     $smtp_port              = "25";         // SMTP Port
        var     $smtp_timeout   = 5;            // SMTP Timeout in seconds
        var     $smtp_crypto    = "";           // SMTP Encryption. Can be null, tls or ssl.
        var     $wordwrap               = TRUE;         // TRUE/FALSE  Turns word-wrap on/off
        var     $wrapchars              = "76";         // Number of characters to wrap at.
        var     $mailtype               = "text";       // text/html  Defines email formatting
        var     $charset                = "utf-8";      // Default char set: iso-8859-1 or us-ascii
        var     $multipart              = "mixed";      // "mixed" (in the body) or "related" (separate)
        var $alt_message        = '';           // Alternative message for HTML emails
        var     $validate               = FALSE;        // TRUE/FALSE.  Enables email validation
        var     $priority               = "3";          // Default priority (1 - 5)
        var     $newline                = "\r\n";       // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
        var $crlf                       = "\n";         // The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
                                                                        // even on the receiving end think they need to muck with CRLFs, so using "\n", while
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by jolson »

This is just a hunch, but try changing

Code: Select all

var $crlf                       = "\n";      


to

Code: Select all

var $crlf                       = "\r\n";         
And sending another email. Does that help at all? That mail file is the identical to my machine, but it's my understanding that line breaks can be treated differently depending on the SMTP server in question - in your case an exchange server.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
polarbear1
Posts: 73
Joined: Mon Apr 13, 2015 4:26 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by polarbear1 »

Didn't work.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by jolson »

By default, Nagios Log Server does not send the alert emails using HTML - it's all in plain text, and link interpretation is left up to the email client in question. What this means is that the problem almost has to be on the end of Outlook or Exchange.

I would like to request a few .eml files from you - if you could get me the .eml file generated when you send yourself an alert mail using the mail binary, as well as the .eml file that results when Nagios Log Server is used relaying through your SMTP server, it could be very useful to compare those files. If you're using Outlook as a mail client, you could use the following guide to extract the .eml files: https://superuser.com/questions/75581/h ... th-outlook

What happens if you change Nagios Log Server to use PHP Mail instead of SMTP in the 'Administration -> Mail Settings' section of the Web GUI? Does the email arrive properly?

The fact that 'mail' works and 'SMTP' does not on your network says that this must be something to do with your exchange relay/outlook interpretation of the mail in question. Thanks polarbear1!
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
polarbear1
Posts: 73
Joined: Mon Apr 13, 2015 4:26 pm

Re: 2015R2.1 Email link shows wrong time span in some cases

Post by polarbear1 »

What happens if you change Nagios Log Server to use PHP Mail instead of SMTP in the 'Administration -> Mail Settings' section of the Web GUI? Does the email arrive properly?
As specified in OP - I am using PHP Mail, not SMTP.
Locked