Email Response Command - missing hash data

This board serves as an open discussion and support collaboration point for Nagios XI. NOTE: Nagios XI customers should use the Customer Support forum to obtain expedited support.

Re: Email Response Command - missing hash data

Postby MediaworksNZ » Sun Aug 04, 2019 4:27 pm

I can now confirm that this does not work either by adding characters in front of the action commands in the examples section.
Really hope this is something easily added by a simple code patch?

Thanks for your help, it is much appreciated.


Code: Select all
***** Nagios XI Alert *****

%alertsummary%

Notification Type: %type%
Host: %host%
State: %hoststate%
Address: %hostaddress%
Info: %hostoutput%
Date/Time: %datetime%

Respond: %responseurl%
Nagios URL: %xiserverurl%

******************************
*****  Email Response example1:  *****
******************************
*****  ack or acknowledge (choose one)  *****
*****  I'm looking into this right now (Optional Comments for acknowledgement)  *****

******************************
*****  Email Response example2:  *****
******************************
*****  down or downtime (choose one)  *****
*****  9:40 – 10:40 / now - 11:30 (two examples: specify time range)  *****
*****  Someone knocked the plug out!  *****

******************************
*****  Email Response example3:  *****
******************************
*****  delay (Delay the next time Nagios XI sends notifications for the object)  *****
*****  5 hour (Must be specified)  *****

In Case of Error:
*******************************************************************************************************************************************************
If the system cannot read a response email you will receive an email back with an error message. Otherwise, it will pass the command onto the subsystem.
*******************************************************************************************************************************************************
MediaworksNZ
 
Posts: 29
Joined: Tue Aug 05, 2014 5:22 pm

Re: Email Response Command - missing hash data

Postby ssax » Mon Aug 05, 2019 3:31 pm

Here's what should be in the message:

Code: Select all
    $text .= _("To reply, keep the following data in your response email.")."\n\n";
    $text .= "##".$encoded."##";


Those two ## in the start and end of the message should are where it's detecting the hash data like so:

Code: Select all
            // 2. Verify that the email object hash exists and the host/service exists
            $start = strpos($email['body'], '##');
            $end = strpos($email['body'], '##', $start + 2);
            if ($start !== false && $end !== false) {
                // DO STUFF
            } else {
                echo "Error - Could not find a valid hash in the email sent\n";
                $error = true;
            }


So when it's failing it's saying it can't find the start ## OR end ## from the replied message, I'm currently trying to replicate that.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4239
Joined: Wed Feb 11, 2015 12:54 pm

Re: Email Response Command - missing hash data

Postby jacek » Wed Aug 14, 2019 6:25 am

Hi,

I'm also running into problems with this feature.
I allow myself to dump on the bottom of this message the reply I sent to nagios.

I get Response Error, and in the logs it only says that it couldn't find a host object in the hash provided.
So I modified the "/usr/local/nagiosxi/html/includes/components/xicore/xicore.inc.php" file to echo the $hash value to the logs, so I can see what it gets via tailing the cleaner.log file.

Now the funny part, it gets the following, note the additional "=" and new line:
Code: Select all
Running callbacks:
Error - Could not find a host object in the hash provided
NDYyZWJmMDMwMGMyZjczOGlvd2JzcTBYbHdTY1k0ZnRiNUI0eHZpaFB6NFVsbzVTNHJHM3cwW=
itsMXM9
Processed 1 incoming emails


Now it goes even weirder, I somehow managed to sent one mail where the hash has been correctly interpreted (only 5 lines, ack, comment and hash separated with a blank line), but I don't know why. (the command got dumped, but I presume that this was because of the extra empty lines, anyway, wouldn't bother - the hash is the issue right now)
I tried copying the hash into a fresh mail and it will get interpreted wrong again.
Kinda out of ideas here....

If I need to make a separate thread out of this then let me know :)

My mail sent to nagios:
Code: Select all
ack

test


From: Nagios <Nagios@company.com>
Sent: Wednesday, August 14, 2019 12:25 PM
To: me <me@company.com>
Subject: PROBLEM Host Alert - HOST is DOWN

---- Respond above this line ----

***** Nagios XI Alert *****

Nagios has detected a problem with this host.

Notification Type: PROBLEM
Host: HOST
State: DOWN
Address: 1.2.3.4
Info: CRITICAL - 1.2.3.4: Host unreachable @ 1.2.3.5. rta nan, lost 100%
Date/Time: 2019-08-14 10:24:46

Respond: https://NAGIOS.COMPANY.com/nagiosxi/rr.php?oid=1558&token=e5153f57f8ab61a2fc1819da20086c1a1592d583
Nagios URL: https://NAGIOS.COMPANY.com/nagiosxi/

-----

To reply, keep the following data in your response email.

##NDYyZWJmMDMwMGMyZjczOGlvd2JzcTBYbHdTY1k0ZnRiNUI0eHZpaFB6NFVsbzVTNHJHM3cwWitsMXM9##
jacek
 
Posts: 224
Joined: Wed Sep 09, 2015 5:49 am

Re: Email Response Command - missing hash data

Postby jomann » Thu Aug 15, 2019 9:25 am

Hello,

It looks like it's not stripping all the parts of the hash that it should in order for it to properly process the string. What I think will fix the hashing issue is by adjusting line 559 in the xicore.inc.php file from:

Code: Select all
$hash = trim(str_replace('> ', '', substr($email['body'], $start + 2, $end - $start - 2)));


to this new one:

Code: Select all
$hash = trim(str_replace(array('> ', '>', '=', "\n", "\t", "\r"), '', substr($email['body'], $start + 2, $end - $start - 2)));


This should account for things that should not be in the hash that get added by the email clients. I've tested this locally to make sure that the hash is readable but would like to see if it resolves your problem. If it does fix this issue, it'll be in 5.6.6 also.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
jomann
Development Lead
 
Posts: 593
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: Email Response Command - missing hash data

Postby jacek » Mon Aug 19, 2019 2:51 am

Looks like this worked for me!
Thanks a lot! :)

BTW - I have ACK mails disabled for all my users, but answering with ACK is generating an ACK email to all contacts of that host.
Is this something that I can change somewhere? The mail says that this has been ack by Nagios Administrator.

jomann wrote:
Code: Select all
$hash = trim(str_replace(array('> ', '>', '=', "\n", "\t", "\r"), '', substr($email['body'], $start + 2, $end - $start - 2)));


This should account for things that should not be in the hash that get added by the email clients. I've tested this locally to make sure that the hash is readable but would like to see if it resolves your problem. If it does fix this issue, it'll be in 5.6.6 also.
jacek
 
Posts: 224
Joined: Wed Sep 09, 2015 5:49 am

Re: Email Response Command - missing hash data

Postby scottwilkerson » Tue Aug 20, 2019 1:57 pm

Are you just seeing it in the Notifications report or are they actually receiving the email?

I ask because the user-defined settings in the "Notification Preferences" act as a filter, and Nagios Core still sent the notification to the XI notification handler, but the user-defined setting suppress that. This is why it would still show in the report.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Email Response Command - missing hash data

Postby jacek » Thu Aug 22, 2019 7:42 am

I think actually this was an issue caused by myself (notification preferences).
I am already on the 5.6.6 version - will test things again and if issues found - will let know :)
jacek
 
Posts: 224
Joined: Wed Sep 09, 2015 5:49 am

Re: Email Response Command - missing hash data

Postby scottwilkerson » Thu Aug 22, 2019 7:47 am

jacek wrote:I think actually this was an issue caused by myself (notification preferences).
I am already on the 5.6.6 version - will test things again and if issues found - will let know :)

sounds good!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Previous

Return to Nagios XI

Who is online

Users browsing this forum: mmusilms and 11 guests