diff -Naur nagios-1.2/base/nagios.c nagios-1.2-patched/base/nagios.c
--- nagios-1.2/base/nagios.c 2004-02-03 05:45:08.000000000 +0100
+++ nagios-1.2-patched/base/nagios.c 2005-08-07 19:47:19.000000000 +0200
@@ -133,6 +133,10 @@
char *macro_host_name=NULL;
char *macro_host_alias=NULL;
char *macro_host_address=NULL;
+/* beginn modification
+ to define secondary_address in host-definition */
+char *macro_host_secondary_address=NULL;
+/* end of modification */
char *macro_service_description=NULL;
char *macro_service_state=NULL;
char *macro_date_time[7]={NULL,NULL,NULL,NULL,NULL,NULL,NULL};
diff -Naur nagios-1.2/base/utils.c nagios-1.2-patched/base/utils.c
--- nagios-1.2/base/utils.c 2004-01-26 02:17:01.000000000 +0100
+++ nagios-1.2-patched/base/utils.c 2005-08-07 19:47:19.000000000 +0200
@@ -75,6 +75,10 @@
extern char *macro_host_name;
extern char *macro_host_alias;
extern char *macro_host_address;
+/* beginn modification
+ to define secondary_address in host-definition */
+extern char *macro_host_secondary_address;
+/* end of modification */
extern char *macro_service_description;
extern char *macro_service_state;
extern char *macro_date_time[7];
@@ -256,6 +260,11 @@
else if(!strcmp(temp_buffer,"HOSTADDRESS"))
strncat(output_buffer,(macro_host_address==NULL)?"":macro_host_address,buffer_length-strlen(output_buffer)-1);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ else if(!strcmp(temp_buffer,"SECONDARYHOSTADDRESS"))
+ strncat(output_buffer,(macro_host_secondary_address==NULL)?"":macro_host_secondary_address,buffer_length-strlen(output_buffer)-1);
+ /* end of modification */
else if(!strcmp(temp_buffer,"SERVICEDESC"))
strncat(output_buffer,(macro_service_description==NULL)?"":macro_service_description,buffer_length-strlen(output_buffer)-1);
@@ -522,6 +531,15 @@
if(macro_host_address!=NULL)
strcpy(macro_host_address,hst->address);
+ /* get secondary host address */
+ /* added by Thomas Jungbauer: 07.08.2005 */
+ if(macro_host_secondary_address!=NULL)
+ free(macro_host_secondary_address);
+ macro_host_secondary_address=(char *)malloc(strlen(hst->secondary_address)+1);
+ if(macro_host_secondary_address!=NULL)
+ strcpy(macro_host_secondary_address,hst->secondary_address);
+ /* end of modification */
+
/* get the host state */
if(macro_host_state!=NULL)
free(macro_host_state);
@@ -596,7 +614,11 @@
strip(macro_host_name);
strip(macro_host_alias);
+ /* beginn modification
+ to define secondary_address in host-definition */
strip(macro_host_address);
+ /* end of modification */
+ strip(macro_host_secondary_address);
strip(macro_host_state);
strip(macro_output);
strip(macro_current_host_attempt);
@@ -778,6 +800,13 @@
free(macro_host_address);
macro_host_address=NULL;
}
+ /* beginn modification
+ to define secondary_address in host-definition */
+ if(macro_host_secondary_address!=NULL){
+ free(macro_host_secondary_address);
+ macro_host_secondary_address=NULL;
+ }
+ /* end of modification */
if(macro_host_state!=NULL){
free(macro_host_state);
macro_host_state=NULL;
@@ -2714,6 +2743,10 @@
macro_host_name=NULL;
macro_host_alias=NULL;
macro_host_address=NULL;
+ /* beginn modification
+ to define secondary_address in host-definition */
+ macro_host_secondary_address=NULL;
+ /* end of modification */
macro_service_description=NULL;
macro_service_state=NULL;
macro_output=NULL;
diff -Naur nagios-1.2/cgi/config.c nagios-1.2-patched/cgi/config.c
--- nagios-1.2/cgi/config.c 2002-11-11 02:13:09.000000000 +0100
+++ nagios-1.2-patched/cgi/config.c 2005-08-07 19:47:25.000000000 +0200
@@ -419,7 +419,11 @@
printf("
\n");
printf("Host Name | ");
printf("Alias/Description | ");
- printf("Address | ");
+ printf("prim. Address | ");
+ /* beginn modification
+ to define secondary_address in host-definition */
+ printf("sec. Address | ");
+ /* end of modification */
printf("Parent Hosts | ");
printf("Notification Interval | ");
printf("Notification Options | ");
@@ -456,6 +460,10 @@
printf("%s | \n",bg_class,url_encode(temp_host->name),temp_host->name);
printf("%s | \n",bg_class,temp_host->alias);
printf("%s | \n",bg_class,temp_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ printf("%s | \n",bg_class,temp_host->secondary_address);
+ /* end of modification */
printf("",bg_class);
for(temp_hostsmember=temp_host->parent_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
diff -Naur nagios-1.2/cgi/extinfo.c nagios-1.2-patched/cgi/extinfo.c
--- nagios-1.2/cgi/extinfo.c 2004-01-21 06:12:34.000000000 +0100
+++ nagios-1.2-patched/cgi/extinfo.c 2005-08-07 19:47:25.000000000 +0200
@@ -270,7 +270,13 @@
if(display_type==DISPLAY_SERVICE_INFO || display_type==DISPLAY_HOST_INFO){
printf(" %s \n",temp_host->alias);
printf("(%s) \n",temp_host->name);
- printf("%s \n",temp_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ printf("primay: %s \n",temp_host->address);
+ if (temp_host->secondary_address != NULL) {
+ printf("secondary: %s \n",temp_host->secondary_address);
+ }
+ /* end of modification */
}
if(display_type==DISPLAY_HOSTGROUP_INFO){
printf("Hostgroup \n");
diff -Naur nagios-1.2/common/objects.c nagios-1.2-patched/common/objects.c
--- nagios-1.2/common/objects.c 2003-11-23 02:37:22.000000000 +0100
+++ nagios-1.2-patched/common/objects.c 2005-08-07 23:28:27.000000000 +0200
@@ -293,7 +293,10 @@
/* add a new host definition */
-host *add_host(char *name, char *alias, char *address, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notification_interval, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int stalk_up, int stalk_down, int stalk_unreachable, int process_perfdata, int failure_prediction_enabled, char *failure_prediction_options, int retain_status_information, int retain_nonstatus_information){
+/* beginn modification
+ to define secondary_address in host-definition
+ added char *secondary_address */
+host *add_host(char *name, char *alias, char *address, char *secondary_address, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notification_interval, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int stalk_up, int stalk_down, int stalk_unreachable, int process_perfdata, int failure_prediction_enabled, char *failure_prediction_options, int retain_status_information, int retain_nonstatus_information){
host *temp_host;
host *new_host;
host *last_host;
@@ -319,6 +322,10 @@
strip(name);
strip(alias);
strip(address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ strip(secondary_address);
+ /* end of modification */
strip(check_command);
strip(event_handler);
strip(notification_period);
@@ -516,7 +523,12 @@
return NULL;
}
new_host->address=strdup(address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ new_host->secondary_address=strdup(secondary_address);
+ /* end of modification */
if(new_host->address==NULL){
+
#ifdef NSCORE
snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not allocate memory for host '%s' address\n",name);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
@@ -527,6 +539,27 @@
free(new_host);
return NULL;
}
+ /* beginn modification
+ to define secondary_address in host-definition */
+ if(secondary_address!=NULL && strcmp(secondary_address,"")){
+ new_host->secondary_address=strdup(secondary_address);
+ if(new_host->secondary_address==NULL){
+#ifdef NSCORE
+ snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not allocate memory for host '%s' secondary address\n",name);
+ temp_buffer[sizeof(temp_buffer)-1]='\x0';
+ write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE);
+#endif
+ free(new_host->address);
+ free(new_host->alias);
+ free(new_host->name);
+ free(new_host);
+ return NULL;
+ }
+ }
+ else
+ new_host->secondary_address=NULL;
+ /* end of modification */
+
if(notification_period!=NULL && strcmp(notification_period,"")){
new_host->notification_period=strdup(notification_period);
if(new_host->notification_period==NULL){
@@ -536,6 +569,10 @@
write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE);
#endif
free(new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(new_host->secondary_address);
+ /* end of modification */
free(new_host->alias);
free(new_host->name);
free(new_host);
@@ -555,6 +592,10 @@
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(new_host->secondary_address);
+ /* end of modification */
free(new_host->alias);
free(new_host->name);
free(new_host);
@@ -576,6 +617,10 @@
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(new_host->secondary_address);
+ /* end of modification */
free(new_host->alias);
free(new_host->name);
free(new_host);
@@ -599,6 +644,10 @@
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(new_host->secondary_address);
+ /* end of modification */
free(new_host->alias);
free(new_host->name);
free(new_host);
@@ -676,6 +725,10 @@
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(new_host->secondary_address);
+ /* end of modification */
free(new_host->alias);
free(new_host->name);
free(new_host);
@@ -700,6 +753,10 @@
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(new_host->secondary_address);
+ /* end of modification */
free(new_host->alias);
free(new_host->name);
free(new_host->plugin_output);
@@ -737,7 +794,11 @@
#ifdef DEBUG1
printf("\tHost Name: %s\n",new_host->name);
printf("\tHost Alias: %s\n",new_host->alias);
- printf("\tHost Address: %s\n",new_host->address);
+ printf("\tHost Address: %s\n",new_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ printf("\tHost Address: %s\n",new_host->secondary_address);
+ /* end of modification */
printf("\tHost Check Command: %s\n",new_host->host_check_command);
printf("\tMax. Check Attempts: %d\n",new_host->max_attempts);
printf("\tHost Event Handler: %s\n",(new_host->event_handler==NULL)?"N/A":new_host->event_handler);
@@ -4018,6 +4079,11 @@
free(this_host->name);
free(this_host->alias);
free(this_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(this_host->secondary_address);
+ /* end of modification */
+
#ifdef NSCORE
free(this_host->plugin_output);
diff -Naur nagios-1.2/common/objects.h nagios-1.2-patched/common/objects.h
--- nagios-1.2/common/objects.h 2002-04-21 00:20:43.000000000 +0200
+++ nagios-1.2-patched/common/objects.h 2005-08-07 19:46:21.000000000 +0200
@@ -94,6 +94,10 @@
char *name;
char *alias;
char *address;
+ /* beginn modification
+ to define secondary_address in host-definition */
+ char *secondary_address;
+ /* end of modification */
hostsmember *parent_hosts;
char *host_check_command;
int max_attempts;
@@ -389,7 +393,10 @@
contact *add_contact(char *,char *,char *,char *,char *,char *,int,int,int,int,int,int,int); /* adds a contact definition */
commandsmember *add_service_notification_command_to_contact(contact *,char *); /* adds a service notification command to a contact definition */
commandsmember *add_host_notification_command_to_contact(contact *,char *); /* adds a host notification command to a contact definition */
-host *add_host(char *,char *,char *,int,int,int,int,int,char *,int,char *,int,char *,int,int,double,double,int,int,int,int,int,char *,int,int); /* adds a host definition */
+/* beginn modification
+ to define secondary_address in host-definition */
+host *add_host(char *,char *,char *,char *,int,int,int,int,int,char *,int,char *,int,char *,int,int,double,double,int,int,int,int,int,char *,int,int); /* adds a host definition */
+/* end of modification */
hostsmember *add_parent_host_to_host(host *,char *); /* adds a parent host to a host definition */
timeperiod *add_timeperiod(char *,char *); /* adds a timeperiod definition */
timerange *add_timerange_to_timeperiod(timeperiod *,int,unsigned long,unsigned long); /* adds a timerange to a timeperiod definition */
diff -Naur nagios-1.2/.cvsignore nagios-1.2-patched/.cvsignore
--- nagios-1.2/.cvsignore 2002-02-26 05:03:26.000000000 +0100
+++ nagios-1.2-patched/.cvsignore 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-pkg
-subst
-pkginfo
-Prototype
-nagios.SPARC.pkg.tar.gz
diff -Naur nagios-1.2/xdata/xoddefault.c nagios-1.2-patched/xdata/xoddefault.c
--- nagios-1.2/xdata/xoddefault.c 2002-05-24 03:57:41.000000000 +0200
+++ nagios-1.2-patched/xdata/xoddefault.c 2005-08-07 19:45:45.000000000 +0200
@@ -1258,7 +1258,11 @@
hostsmember *new_hostsmember;
char *temp_ptr;
char *alias;
- char *address;
+ char *address;
+ /* beginn modification
+ to define secondary_address in host-definition */
+ char *secondary_address;
+ /* end of modification */
char *check_command;
char *event_handler;
char *parent;
@@ -1299,6 +1303,13 @@
if(alias==NULL)
alias=name;
+ /* beginn modification
+ to define secondary_address in host-definition */
+ secondary_address=my_strtok(NULL,";");
+ if (secondary_address==NULL)
+ secondary_address=address;
+ /* end of modification */
+
/* grab the host address */
address=my_strtok(NULL,";");
if(address==NULL){
@@ -1315,7 +1326,7 @@
/* grab the host check command - no command means we won't check the host */
check_command=my_strtok(NULL,";");
-
+
/* get the max number of check attempts */
temp_ptr=my_strtok(NULL,";");
if(temp_ptr==NULL || !strcmp(temp_ptr,"")){
@@ -1436,6 +1447,10 @@
strip(name);
strip(alias);
strip(address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ strip(secondary_address);
+ /* end of modification */
strip(check_command);
strip(event_handler);
strip(notification_period);
diff -Naur nagios-1.2/xdata/xodtemplate.c nagios-1.2-patched/xdata/xodtemplate.c
--- nagios-1.2/xdata/xodtemplate.c 2003-11-23 02:37:22.000000000 +0100
+++ nagios-1.2-patched/xdata/xodtemplate.c 2005-08-07 19:46:15.000000000 +0200
@@ -926,6 +926,10 @@
new_host->host_name=NULL;
new_host->alias=NULL;
new_host->address=NULL;
+ /* beginn modification
+ to define secondary_address in host-definition */
+ new_host->secondary_address=NULL;
+ /* end of modification */
new_host->parents=NULL;
new_host->check_command=NULL;
new_host->event_handler=NULL;
@@ -2058,6 +2062,18 @@
return ERROR;
}
}
+/* beginn modification
+ to define secondary_address in host-definition */
+ else if(!strcmp(variable,"secondary_address")){
+ temp_host->secondary_address=strdup(value);
+ if(temp_host->secondary_address==NULL){
+#ifdef DEBUG1
+ printf("Error: Could not allocate memory for host secondary_address.\n");
+#endif
+ return ERROR;
+ }
+ }
+/* end of modification */
else if(!strcmp(variable,"parents")){
temp_host->parents=strdup(value);
if(temp_host->parents==NULL){
@@ -4618,6 +4634,11 @@
this_host->alias=strdup(template_host->alias);
if(this_host->address==NULL && template_host->address!=NULL)
this_host->address=strdup(template_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ if(this_host->secondary_address==NULL && template_host->secondary_address!=NULL)
+ this_host->secondary_address=strdup(template_host->secondary_address);
+ /* end of modification */
if(this_host->parents==NULL && template_host->parents!=NULL)
this_host->parents=strdup(template_host->parents);
if(this_host->check_command==NULL && template_host->check_command!=NULL)
@@ -5939,7 +5960,10 @@
return OK;
/* add the host definition */
- new_host=add_host(this_host->host_name,this_host->alias,(this_host->address==NULL)?this_host->host_name:this_host->address,this_host->max_check_attempts,this_host->notify_on_recovery,this_host->notify_on_down,this_host->notify_on_unreachable,this_host->notification_interval,this_host->notification_period,this_host->notifications_enabled,this_host->check_command,this_host->checks_enabled,this_host->event_handler,this_host->event_handler_enabled,this_host->flap_detection_enabled,this_host->low_flap_threshold,this_host->high_flap_threshold,this_host->stalk_on_up,this_host->stalk_on_down,this_host->stalk_on_unreachable,this_host->process_perf_data,this_host->failure_prediction_enabled,this_host->failure_prediction_options,this_host->retain_status_information,this_host->retain_nonstatus_information);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ new_host=add_host(this_host->host_name,this_host->alias,(this_host->address==NULL)?this_host->host_name:this_host->address,(this_host->secondary_address==NULL)?this_host->address:this_host->secondary_address,this_host->max_check_attempts,this_host->notify_on_recovery,this_host->notify_on_down,this_host->notify_on_unreachable,this_host->notification_interval,this_host->notification_period,this_host->notifications_enabled,this_host->check_command,this_host->checks_enabled,this_host->event_handler,this_host->event_handler_enabled,this_host->flap_detection_enabled,this_host->low_flap_threshold,this_host->high_flap_threshold,this_host->stalk_on_up,this_host->stalk_on_down,this_host->stalk_on_unreachable,this_host->process_perf_data,this_host->failure_prediction_enabled,this_host->failure_prediction_options,this_host->retain_status_information,this_host->retain_nonstatus_information);
+ /* end of modification */
/* return with an error if we couldn't add the host */
if(new_host==NULL){
@@ -6279,6 +6303,10 @@
free(this_host->host_name);
free(this_host->alias);
free(this_host->address);
+ /* beginn modification
+ to define secondary_address in host-definition */
+ free(this_host->secondary_address);
+ /* end of modification */
free(this_host->parents);
free(this_host->check_command);
free(this_host->event_handler);
diff -Naur nagios-1.2/xdata/xodtemplate.h nagios-1.2-patched/xdata/xodtemplate.h
--- nagios-1.2/xdata/xodtemplate.h 2002-08-20 04:43:19.000000000 +0200
+++ nagios-1.2-patched/xdata/xodtemplate.h 2005-08-07 19:45:47.000000000 +0200
@@ -144,6 +144,10 @@
char *host_name;
char *alias;
char *address;
+ /* beginn modification
+ to define secondary_address in host-definition */
+ char *secondary_address;
+ /* end of modification */
char *parents;
char *check_command;
int max_check_attempts;
|