Page 1 of 1

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

Posted: Wed Dec 24, 2014 8:31 pm
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,

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

Posted: Fri Dec 26, 2014 10:52 am
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.

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

Posted: Fri Dec 26, 2014 11:51 am
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.

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

Posted: Fri Dec 26, 2014 12:12 pm
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.

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

Posted: Fri Dec 26, 2014 12:26 pm
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.

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

Posted: Fri Dec 26, 2014 12:31 pm
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?

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

Posted: Fri Dec 26, 2014 12:53 pm
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

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

Posted: Fri Dec 26, 2014 1:23 pm
by scottwilkerson
This has been resolved in Nagios XI 2014R2.2, just released.

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

Posted: Fri Dec 26, 2014 5:08 pm
by questrad
Thanks

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

Posted: Mon Dec 29, 2014 9:06 am
by lmiltchev
I am locking this topic. If you have any more questions/issues, please, start a new thread.