SystemMonitoring FreeFields storing Carriage Return

Moderator: crythias

Post Reply
markdiss
Znuny newbie
Posts: 14
Joined: 05 Oct 2021, 17:15
Znuny Version: 6.4.2
Real Name: Mark Dissington

SystemMonitoring FreeFields storing Carriage Return

Post by markdiss »

Hi all,

We've been using Znuny (previously OTRS CE) with Nagios Core for years and have been successfully opening and closing tickets as the states in Nagios change. We've just realised that you can acknowledge and mute the alerts from Nagios when you lock a ticket in Znuny and we've been trying to get this working.

So far we're got a znuny user set up in Nagios with the correct rights and have fixed the email templates being sent from Nagios to Znuny so it sends the actually host name as Host instead of the Host Alias. However, it looks like when the Hostname and Service are parsed by Znunuy from the email sent by Nagios the FreeTextFields are being saved with a Carriage Return on the end of each "%0D". When we lock the ticket the command is triggered to Nagios but both the host and service in the generated command line have %0D appended to them, see example below:

"GET /nagios/cgi-bin/cmd.cgi?cmd_typ=34&cmd_mod=2&host=testhost%0D&service=testsrv%0D&sticky_ack=on&send_notification=on&persistent=on&com_data=2022102810000066&btnSubmit=Commit HTTP/1.1"

If we go into Misc -> Free Fields in the Znuny GUI and just click submit to save the fields, the trailing Carriage returns are stripped and a subsequent lock of the ticket succeeds in setting the acknowledgement in Nagios:

"GET /nagios/cgi-bin/cmd.cgi?cmd_typ=34&cmd_mod=2&host=testhost&service=testsrv&sticky_ack=on&send_notification=on&persistent=on&com_data=2022102810000066&btnSubmit=Commit HTTP/1.1"

Is there an easy way to fix this in the Nagios SystemMonitoring RegEx? Or does this require some fixes under the hood and a new plug-in release?

Thanks,
Mark.
root
Administrator
Posts: 3968
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: SystemMonitoring FreeFields storing Carriage Return

Post by root »

Hi,

Mark, can you share the template or better one of these notification emails which are parsed? Of course anonymized.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
markdiss
Znuny newbie
Posts: 14
Joined: 05 Oct 2021, 17:15
Znuny Version: 6.4.2
Real Name: Mark Dissington

Re: SystemMonitoring FreeFields storing Carriage Return

Post by markdiss »

***** Nagios *****

Notification Type: PROBLEM

Service: MGMT
Host: testserver
Host Alias: Dev C7 Test Server
Address: 111.222.333.444
State: CRITICAL

Date/Time: Fri Oct 28 17:10:41 BST 2022

Additional Info:

connect to address 111.222.333.444 and port 80: Connection refused
markdiss
Znuny newbie
Posts: 14
Joined: 05 Oct 2021, 17:15
Znuny Version: 6.4.2
Real Name: Mark Dissington

Re: SystemMonitoring FreeFields storing Carriage Return

Post by markdiss »

Forgot to say we're running Znuny 6.4.2 with ITSM and SystemMonitoring 6.4.2

PostMaster::PreFilterModule###1-SystemMonitoring are all defaults.

Host and Service RegExs below:
\s*Host:\s+(.*)\s*
\s*Service:\s+(.*)\s*

Running Nagios Core 4.4.8 with the below config for the notification commands in commands.cfg:

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\nHost Alias: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
markdiss
Znuny newbie
Posts: 14
Joined: 05 Oct 2021, 17:15
Znuny Version: 6.4.2
Real Name: Mark Dissington

Re: SystemMonitoring FreeFields storing Carriage Return

Post by markdiss »

Anyone have any thoughts? Or have acknowledgements to Nagios Core working?

Thanks,
Mark.
root
Administrator
Posts: 3968
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: SystemMonitoring FreeFields storing Carriage Return

Post by root »

Hi,

This should be solvable with the regex, use any of the online available regular expression sites like regexr or rubular.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Post Reply