5.8.1 breaks xml output

Issue #47 resolved
Former user created an issue

Hi,

I have this check:

check process squid with pidfile /var/run/squid.pid
    start program = "/sbin/service squid start"
    stop program = "/sbin/service squid stop"
    if failed host 172.16.66.1 port 3128 then restart
    group httpd

which produces faulty XML output in 5.8.1 (stripped down to the relevant part):

  <hostname>172.16.66.1</hostname>
  <portnumber>3128</portnumber>
  <request><![CDATA[<![CDATA[]]>]]></request>
  <protocol>DEFAULT</protocol>

compare to 5.8:

  <hostname>172.16.66.1</hostname>
  <portnumber>3128</portnumber>
  <request><![CDATA[]]></request>
  <protocol>DEFAULT</protocol>

this is the change that breaks xml output in 5.8.1:

diff -w -B -x .svn -Nrup monit-5.8/src/xml.c monit-5.8.1/src/xml.c
--- monit-5.8/src/xml.c
+++ monit-5.8.1/src/xml.c
@@ -255,7 +255,7 @@ static void status_service(Service_T S,
                                                           "<port>"
                                                           "<hostname>%s</hostname>"
                                                           "<portnumber>%d</portnumber>"
-                                                          "<request>%s</request>"
+                                                          "<request><![CDATA[%s]]></request>"
                                                           "<protocol>%s</protocol>"
                                                           "<type>%s</type>"
                                                           "<responsetime>%.3f</responsetime>"

Marked as "major" because it neither python nor perl are willing to parse the resulting xml.

Kind regards,

Philippe

Comments (8)

  1. Tildeslash repo owner

    I'm not able to reproduce this with the same conf. To get double CDATA in the string would mean that either p->request is wrapped in CDATA which it is not or that there is some interleaved write to the string buffer which seems unlikely. Could you do a make cleanall and try to rebuild Monit from scratch in case there are some old code linked in or you had your own changes in the code? If the problem remains, could you attach a simple monitrc conf that reproduces the problem?

  2. Former user Account Deleted reporter

    nevermind. I use the nagios plugin "check_monit" which failed after updating monit to 5.8.1. It seems that the script silently inserts an additional CDATA into the resulting xml:

    xml_hacks = (
        (re.compile(r"<request>(.*?)</request>",flags=re.MULTILINE), (r"<request><![CDATA[\1]]></request>")),
    )
    

    sorry (^_^);;

  3. Log in to comment