Email of multiline output

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Email of multiline output

Post by pbroste »

Hello @hbouma

I will test this further and follow up shortly.

Thanks,
Perry
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Email of multiline output

Post by pbroste »

Hello @hbouma

Imported and loaded up our test VM with your System Profile to test and verify the '$LONGSERVICEOUTPUT$' today.

Review on the configs and logs indicate that the '$LONGSERVICEOUTPUT$' is working on service checks that are specifically scripted to send "HTML" code to the '$LONGSERVICEOUTPUT$' variable.

For example, we see that the following results with '$LONGSERVICEOUTPUT$' from our test VM. We see that the service check failed to connect to my server on port 12489 and the additional line '$LONGSERVICEOUTPUT$'; "could not fetch information from server"
[service] => PROC-nrouter
[hoststate] => UP
[hoststateid] => 0
[servicestate] => CRITICAL
[servicestateid] => 2
[lastservicestate] => CRITICAL
[lastservicestateid] => 2
[servicestatetype] => HARD
[currentattempt] => 3
[maxattempts] => 3
[serviceeventid] => 141
[serviceproblemid] => 102
[serviceoutput] => connect to address 127.0.0.1 and port 12489: Connection refused
[longserviceoutput] => could not fetch information from server


I will also send via [PM] Private Message the attachment with the checks with output to '$LONGSERVICEOUTPUT$'.

This indicates that the '$LONGSERVICEOUTPUT$' is functioning as expected, but again it relies on the Service Check to output additional lines.

Thanks,
Perry
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Email of multiline output

Post by hbouma »

So, we do insert a new line into the output. When looking at the output in the GUI, it is shown in multiple lines.

Trying to figure out why the Nagios XI GUI would show new lines, but the same output in the email would only show \n instead of an actual new line?
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Email of multiline output

Post by pbroste »

Hello @hbouma

Would you please provide the service check and the screenshot on an example that you see to view what is going on?

Thanks,
Perry
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Email of multiline output

Post by hbouma »

Responded in PM as there are email addresses and server names in the response.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Email of multiline output

Post by pbroste »

Hello @hbouma

Thanks for sending over the additional information. I have spun-up a test environment and will continue to test and respond with results.

In testing we see that the eventman logs are giving us additional line information that we are looking for from the PowerShell script. This is the example that we:
An email notification will be sent...

Email Notification Data:

Array
(
[meta] => Array
(
[notification-type] => service
[contact] => nagiosadmin
[contactemail] => root@localhost
[type] => PROBLEM
[escalated] => 0
[author] =>
[comments] =>
[host] => 192.168.
[hostaddress] => 192.168.
[hostalias] => 192.168.
[hostdisplayname] => 192.168.
[service] => Plugin check_files.ps1
[hoststate] => UP
[hoststateid] => 0
[servicestate] => CRITICAL
[servicestateid] => 2
[lastservicestate] => CRITICAL
[lastservicestateid] => 2
[servicestatetype] => HARD
[currentattempt] => 1
[maxattempts] => 1
[serviceeventid] => 78
[serviceproblemid] => 40
[serviceoutput] => Files modified in the last 9999 minutes. Files are:
[longserviceoutput] => C:\temp\New Text Document (2) - Copy.txt\nC:\temp\New Text Document (2).txt\nC:\temp\New Text Document (3) - Copy.txt\nC:\temp\New Text Document (4) - Copy.txt\nC:\temp\New Text Document.txt\nC:\temp\stuff - Copy (2).txt\nC:\temp\stuff - Copy (3).txt\nC:\temp\stuff - Copy.txt\nC:\temp\stuff.txt\n\n\t
We know that the results of the PowerShell script are sending the additional information, now trying to figure out if there is any way to get $LONGSERVICEOUTPUT$ to recognize.

Will continue to test and follow up.

Thanks,
Perry
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Email of multiline output

Post by pbroste »

Hello @hbouma

Following up as I had time to dig into this more today. I was working with a colleague with test VM and found that we were missing a notification message line config.

On the web UI, if you head over to Admin > Notification Messages > [Email tab]
  • Under Alert Message:
  • Service Alert Message:
Add the line for the host message:
yourwordinghere: %longhostoutput%
And
yourwordinghere: %longserviceoutput%
[Update Settings:]

My example:
Image

Let me know how things look,
Perry
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Email of multiline output

Post by hbouma »

We have already done this to all users by setting up the Notification Management setting and deploying this out to users.

https://support.nagios.com/forum/postin ... 1#pr336722


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

%alertsummary%

Notification Type: %type%

Service: %service%
Host: %host%
Address: %hostaddress%
State: %servicestate%
Info:
"%serviceoutput%"
"%longserviceoutput%"
Date/Time: %datetime%

Rapid Respond: %responseurl%
Nagios URL: %xiserverurl%
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Email of multiline output

Post by pbroste »

Hello @hbouma

Let's add Eventhandler to the 'check_files' service check sent with a built-in Event notifier to verify '$LONGSERVICEOUTPUT$'. I want to verify before digging into the /usr/local/integrate/everbridge/onCallEvent.sh' notifier.

Configure > Core Configuration Manager > Commands
  • Update the notification commands to include:
  • [list]
  • \n$LONGSERVICEOUTPUT$
[/list]

Let us know how things look,
Perry
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Email of multiline output

Post by hbouma »

I am sending you a PM.
Locked