Page 1 of 1

Re: [Nagios-devel] [Nagios-users] Bug in 3.0.2 with service

Posted: Tue May 27, 2008 8:49 am
by Guest
This is a multi-part message in MIME format.
--------------020705080501030406070507
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Andy,

Andy Shellam wrote:
>
> I'm more inclined to think that the service escalation is wrong in its
> behaviour, but then I could be wrong?
>

HostEscalation differs from ServiceEscalation as you can see in the
source code:

File: xdata/xodtemplate.c

For ServiceEscalation

Line: 10251 (for contactgroups)
for(contact_group=strtok(this_serviceescalation->contact_groups,",
");contact_group!=NULL;contact_group=strtok(NULL,", ")){

Line: 10265 (for contacts)
for(contact_name=strtok(this_serviceescalation->contacts,",
");contact_name!=NULL;contact_name=strtok(NULL,", ")){


For HostEscalation

Line: 10397 (for contactgroups)
for(contact_group=strtok(this_host->contact_groups,",");contact_group!=NULL;contact_group=strtok(NULL,",")){

Line: 10413 (for contacts)
for(contact_name=strtok(this_host->contacts,",");contact_name!=NULL;contact_name=strtok(NULL,",")){


The white-space is considered a field separator for "contact_groups" in
ServiceEscalation but not HostEscalation.

As an attachment is a patch which fixes this bug.

And for the records, somebody should cleanup the source code regarding
this field separator glitch. The white-space is considered a field
separator in a lot of places.

I'm not a C guru so I'm not sure if it's here on purpose or not and if
"fixing" it breaks backward-compatibility.

--
Mathie Gagné

--------------020705080501030406070507
Content-Type: text/plain;
name="contactgroups-with-white-spaces.patch"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="contactgroups-with-white-spaces.patch"

ZGlmZiAtTmF1ciBuYWdpb3MtMy4wLjItb3JpZ2luYWwveGRhdGEveG9kdGVtcGxhdGUuYyBu
YWdpb3MtMy4wLjIveGRhdGEveG9kdGVtcGxhdGUuYwotLS0gbmFnaW9zLTMuMC4yLW9yaWdp
bmFsL3hkYXRhL3hvZHRlbXBsYXRlLmMJMjAwOC0wNS0yNyAxMTozOTowOS4wMDAwMDAwMDAg
LTA0MDAKKysrIG5hZ2lvcy0z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bnRhY3RfbmFtZT1zdHJ0b2sodGhpc19zZXJ2aWNlZXNjYWxhdGlvbi0+
Y29udGFjdHMsIiwiKTtjb250YWN0X25hbWUhPU5VTEw7Y29udGFjdF9uYW1lPXN0cnRvayhO
VUxMLCIsIikpewogCQkJbmV3X2NvbnRhY3RzbWVtYmVyPWFkZF9jb250YWN0X3RvX3NlcnZp
Y2Vlc2NhbGF0aW9uKG5ld19zZXJ2aWNlZXNjYWxhdGlvbixjb250YWN0X25hbWUpOwogCQkJ
aWYobmV3X2NvbnRhY3RzbWVtYmVyPT1OVUxMKXsKICNpZmRlZiBOU0NPUkUK
--------------020705080501030406070507--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]