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é
diff -Naur nagios-3.0.2-original/xdata/xodtemplate.c 
nagios-3.0.2/xdata/xodtemplate.c
--- nagios-3.0.2-original/xdata/xodtemplate.c   2008-05-27 11:39:09.000000000 
-0400
+++ nagios-3.0.2/xdata/xodtemplate.c    2008-05-27 11:46:02.000000000 -0400
@@ -10248,7 +10248,7 @@
        /* add the contact groups */
        if(this_serviceescalation->contact_groups!=NULL){
 
-               
for(contact_group=strtok(this_serviceescalation->contact_groups,", 
");contact_group!=NULL;contact_group=strtok(NULL,", ")){
+               
for(contact_group=strtok(this_serviceescalation->contact_groups,",");contact_group!=NULL;contact_group=strtok(NULL,",")){
                        
new_contactgroupsmember=add_contactgroup_to_serviceescalation(new_serviceescalation,contact_group);
                        if(new_contactgroupsmember==NULL){
 #ifdef NSCORE
@@ -10262,7 +10262,7 @@
        /* add the contacts */
        if(this_serviceescalation->contacts!=NULL){
 
-               for(contact_name=strtok(this_serviceescalation->contacts,", 
");contact_name!=NULL;contact_name=strtok(NULL,", ")){
+               
for(contact_name=strtok(this_serviceescalation->contacts,",");contact_name!=NULL;contact_name=strtok(NULL,",")){
                        
new_contactsmember=add_contact_to_serviceescalation(new_serviceescalation,contact_name);
                        if(new_contactsmember==NULL){
 #ifdef NSCORE
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to