Notification: Problem with "(,)" in --longserviceoutput

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
questrad
Posts: 160
Joined: Wed Mar 21, 2012 3:08 pm
Location: Toronto
Contact:

Notification: Problem with "(,)" in --longserviceoutput

Post by questrad »

Hello,

I have noticed today that if service return in --longserviceoutput the message that include "(" or ")" the Nagios is complaining following:

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="Company-production-support" --contactemail="[email protected]" --type=PROBLEM --escalated="0" --author="" --comments="" --host="SQ5VPMSQLC005" --hostaddress="SQ5VPMSQL005.RESOURCES.company.com" --hostalias="SQ5VPMSQLC005_CLUSTER" --hostdisplayname="SQ5VPMSQLC005" --service="Cluster_Status" --hoststate=UP --hoststateid=0 --servicestate=WARNING --servicestateid=1 --lastservicestate=WARNING --lastservicestateid=1 --servicestatetype=HARD --currentattempt=2 --maxattempts=2 --serviceeventid=177000 --serviceproblemid=83035 --serviceoutput="WARNING - Resources are not on same nodes" --longserviceoutput="MSCluster_ResourceGroup.Name="SQL Server (DBSRV5)" on node MSCluster_Node.Name="SQ5VPMSQL005"\nMSCluster_ResourceGroup.Name="SQL Server (DBSRV6)" on node MSCluster_Node.Name="SQ5VPMSQL006"" --datetime="Wed Dec 24 00:08:14 EST 2014" --notificationrecipients="Company-production-support,Company-production-operations-windows,011772,Company-production-platform-dev-database-engineering,012076
-bash: syntax error near unexpected token `('

Code: Select all

[1419397694] wproc:   stderr line 01: /bin/sh: -c: line 0: syntax error near unexpected token `('
[1419397694] wproc:   stderr line 02: /bin/sh: -c: line 0: `/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="Company-production-support" --contactemail="[email protected]" --type=PROBLEM --escalated="0" --author="" --comments="" --host="SQ5VPMSQLC005" --hostaddress="SQ5VPMSQL005.RESOURCES.company.com" --hostalias="SQ5VPMSQLC005_CLUSTER" --hostdisplayname="SQ5VPMSQLC005" --service="Cluster_Status" --hoststate=UP --hoststateid=0 --servicestate=WARNING --servicestateid=1 --lastservicestate=WARNING --lastservicestateid=1 --servicestatetype=HARD --currentattempt=2 --maxattempts=2 --serviceeventid=177000 --serviceproblemid=83035 --serviceoutput="WARNING - Resources are not on same nodes" --longserviceoutput="MSCluster_ResourceGroup.Name="SQL Server (DBSRV5)" on node MSCluster_Node.Name="SQ5VPMSQL005"\nMSCluster_ResourceGroup.Name="SQL Server (DBSRV6)" on node MSCluster_Node.Name="SQ5VPMSQL006"" --datetime="Wed Dec 24 00:08:14 EST 2014" --notificationrecipients="Company-production-support,Company-production-operations-windows,011772,Company-production-platform-dev-database-engineering,012076"'

But if I change it to following it works fine:

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="Company-production-support" --contactemail="[email protected]" --type=PROBLEM --escalated="0" --author="" --comments="" --host="SQ5VPMSQLC005" --hostaddress="SQ5VPMSQL005.RESOURCES.company.com" --hostalias="SQ5VPMSQLC005_CLUSTER" --hostdisplayname="SQ5VPMSQLC005" --service="Cluster_Status" --hoststate=UP --hoststateid=0 --servicestate=WARNING --servicestateid=1 --lastservicestate=WARNING --lastservicestateid=1 --servicestatetype=HARD --currentattempt=2 --maxattempts=2 --serviceeventid=177000 --serviceproblemid=83035 --serviceoutput="WARNING - Resources are not on same nodes" --longserviceoutput="MSCluster_ResourceGroup.Name="SQL Server \(DBSRV5\)" on node MSCluster_Node.Name="SQ5VPMSQL005"\nMSCluster_ResourceGroup.Name="SQL Server \(DBSRV6\)" on node MSCluster_Node.Name="SQ5VPMSQL006"" --datetime="Wed Dec 24 00:08:14 EST 2014" --notificationrecipients="Company-production-support,Company-production-operations-windows,011772,Company-production-platform-dev-database-engineering,012076

Is some one has the same issue?

Best regards,
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by tgriep »

Using special characters in Nagios commands / scripts it is required to Escape them them with "\".
That is needed when the commands are passed to the shell with out errors.
Be sure to check out our Knowledgebase for helpful articles and solutions!
questrad
Posts: 160
Joined: Wed Mar 21, 2012 3:08 pm
Location: Toronto
Contact:

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by questrad »

But it comes from service check output, I cannot control it.

Looks like Nagios should control it, if in service long output it see special characters need to escaping.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by tgriep »

What plugin are you using for this check?

The standard plugins should return special characters escaped.

Also, if you have any special characters in the Service name and description, you might have to escape them also.
Be sure to check out our Knowledgebase for helpful articles and solutions!
questrad
Posts: 160
Joined: Wed Mar 21, 2012 3:08 pm
Location: Toronto
Contact:

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by questrad »

So, the issue is happening when the notification is going to send with using --longserviceoutput.

The service is working perfectly without any issue. The output of the service is normal standard output.
  • "MSCluster_ResourceGroup.Name="SQL Server (DBSRV5)" on node MSCluster_Node.Name="SQ5VPMSQL005"
    "MSCluster_ResourceGroup.Name="SQL Server (DBSRV6)" on node MSCluster_Node.Name="SQ5VPMSQL006"
So, this issue I have noticed when we have migrated from NagiosXI 2012 to NagiosXI 2014.
I don't think that any plugin does special character escaping in long output of the service.

In my opinion the escaping must be done on Nagios side when it sends the longserviceoutput to the "handle_nagioscore_notification.php" or it must be done in "handle_nagioscore_notification.php" script.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by scottwilkerson »

I believe you may have a valid condition here, I have posted the bug report for Nagios Core 4.+

Can you confirm which version of XI you are running?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by scottwilkerson »

We have a patch in the works and will be included in the next release (likely the beginning of next week), after some testing is complete. -SW
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by scottwilkerson »

This has been resolved in Nagios XI 2014R2.2, just released.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
questrad
Posts: 160
Joined: Wed Mar 21, 2012 3:08 pm
Location: Toronto
Contact:

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by questrad »

Thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Notification: Problem with "(,)" in --longserviceoutput

Post by lmiltchev »

I am locking this topic. If you have any more questions/issues, please, start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked