diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/base/utils.c nagios-2.0rc1-hacked/base/utils.c
--- nagios-2.0rc1/base/utils.c 2005-12-23 20:31:36.000000000 +0100
+++ nagios-2.0rc1-hacked/base/utils.c 2006-01-10 12:30:18.000000000 +0100
@@ -731,10 +731,17 @@
/* get the host address */
if(macro_x[MACRO_HOSTADDRESS]!=NULL)
free(macro_x[MACRO_HOSTADDRESS]);
macro_x[MACRO_HOSTADDRESS]=strdup(hst->address);
+ /* begin modification to define sec. ipaddress */
+ /* get the host secondary address */
+ if(macro_x[MACRO_SECONDARYHOSTADDRESS]!=NULL)
+ free(macro_x[MACRO_SECONDARYHOSTADDRESS]);
+ macro_x[MACRO_SECONDARYHOSTADDRESS]=strdup(hst->secondary_address);
+ /* end of modification */
+
/* get the host state */
if(macro_x[MACRO_HOSTSTATE]!=NULL)
free(macro_x[MACRO_HOSTSTATE]);
macro_x[MACRO_HOSTSTATE]=(char *)malloc(MAX_STATE_LENGTH);
if(macro_x[MACRO_HOSTSTATE]!=NULL){
@@ -1219,10 +1226,15 @@
/* get the host address */
else if(!strcmp(macro,"HOSTADDRESS"))
macro_ondemand=strdup(hst->address);
+ /* begin modification to define sec. ipaddress */
+ else if(!strcmp(macro,"SECONDARYHOSTADDRESS"))
+ macro_ondemand=strdup(hst->secondary_address);
+ /* end of modification */
+
/* get the host state */
else if(!strcmp(macro,"HOSTSTATE")){
macro_ondemand=(char *)malloc(MAX_STATE_LENGTH);
if(macro_ondemand!=NULL){
if(hst->current_state==HOST_DOWN)
@@ -2291,10 +2303,13 @@
/* initialize each macro name */
add_macrox_name(MACRO_HOSTNAME,"HOSTNAME");
add_macrox_name(MACRO_HOSTALIAS,"HOSTALIAS");
add_macrox_name(MACRO_HOSTADDRESS,"HOSTADDRESS");
+ /* begin modification to define sec. ipaddress */
+ add_macrox_name(MACRO_SECONDARYHOSTADDRESS,"SECONDARYHOSTADDRESS");
+ /* end of modifications */
add_macrox_name(MACRO_SERVICEDESC,"SERVICEDESC");
add_macrox_name(MACRO_SERVICESTATE,"SERVICESTATE");
add_macrox_name(MACRO_SERVICESTATEID,"SERVICESTATEID");
add_macrox_name(MACRO_SERVICEATTEMPT,"SERVICEATTEMPT");
add_macrox_name(MACRO_LONGDATETIME,"LONGDATETIME");
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/cgi/config.c nagios-2.0rc1-hacked/cgi/config.c
--- nagios-2.0rc1/cgi/config.c 2005-11-16 09:49:35.000000000 +0100
+++ nagios-2.0rc1-hacked/cgi/config.c 2006-01-10 14:14:02.000000000 +0100
@@ -445,10 +445,13 @@
printf("
\n",bg_class);
printf("%s | \n",bg_class,url_encode(temp_host->name),temp_host->name);
printf("%s | \n",bg_class,temp_host->alias);
+ /* begin modification to define sec. ipaddress */
printf("%s | \n",bg_class,temp_host->address);
+ 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){
if(temp_hostsmember!=temp_host->parent_hosts)
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/cgi/extinfo.c nagios-2.0rc1-hacked/cgi/extinfo.c
--- nagios-2.0rc1/cgi/extinfo.c 2005-11-16 09:49:35.000000000 +0100
+++ nagios-2.0rc1-hacked/cgi/extinfo.c 2006-01-10 14:10:38.000000000 +0100
@@ -317,11 +317,14 @@
}
if(found==FALSE)
printf("No hostgroups");
printf(" \n");
- printf("%s \n",temp_host->address);
+ /* begin modification to define sec. ipaddress */
+ printf("primary:%s \n",temp_host->address);
+ printf("secondary:%s \n",temp_host->secondary_address);
+ /* end of modification */
}
if(display_type==DISPLAY_SERVICE_INFO){
printf("Service %s On Host \n",service_desc);
printf("%s \n",temp_host->alias);
printf(" \n",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_host->name),temp_host->name);
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/common/objects.c nagios-2.0rc1-hacked/common/objects.c
--- nagios-2.0rc1/common/objects.c 2005-12-27 19:55:10.000000000 +0100
+++ nagios-2.0rc1-hacked/common/objects.c 2006-01-10 14:39:03.000000000 +0100
@@ -922,15 +922,17 @@
#endif
return new_timerange;
}
-
+/* begin modification to define sec. ipaddress */
+/* added char *secondary_address
/* add a new host definition */
-host *add_host(char *name, char *alias, char *address, char *check_period, int check_interval, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notify_flapping, int notification_interval, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, int accept_passive_checks, 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 check_freshness, int freshness_threshold, int retain_status_information, int retain_nonstatus_information, int obsess_over_host){
+host *add_host(char *name, char *alias, char *address, char *secondary_address, char *check_period, int check_interval, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notify_flapping, int notification_interval, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, int accept_passive_checks, 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 check_freshness, int freshness_threshold, int retain_status_information, int retain_nonstatus_information, int obsess_over_host){
host *temp_host;
host *new_host;
+/* end of modification */
#ifdef NSCORE
char temp_buffer[MAX_INPUT_BUFFER];
int x;
#endif
@@ -949,10 +951,13 @@
}
strip(name);
strip(alias);
strip(address);
+ /* begin modification to define sec. ipaddress */
+ strip(secondary_address);
+ /* end of modification */
strip(check_command);
strip(event_handler);
strip(notification_period);
if(!strcmp(name,"") || !strcmp(alias,"") || !strcmp(address,"")){
@@ -1207,19 +1212,43 @@
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
+
+ /* begin modification to define sec. ipaddress */
+ if (secondary_address==NULL) {
+ new_host->secondary_address=NULL;
+ } else {
+ 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->alias);
+ free(new_host->address);
+ free(new_host->name);
+ free(new_host);
+ return NULL;
+ }
+ }
+ /* end of modification */
+
if(check_period!=NULL && strcmp(check_period,"")){
new_host->check_period=strdup(check_period);
if(new_host->check_period==NULL){
#ifdef NSCORE
snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not allocate memory for host '%s' check period\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);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1234,10 +1263,13 @@
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE);
#endif
free(new_host->check_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1254,10 +1286,13 @@
#endif
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->check_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1276,10 +1311,13 @@
free(new_host->host_check_command);
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->check_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1300,10 +1338,13 @@
free(new_host->host_check_command);
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->check_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1398,10 +1439,13 @@
if(new_host->host_check_command!=NULL)
free(new_host->host_check_command);
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1422,10 +1466,13 @@
if(new_host->host_check_command!=NULL)
free(new_host->host_check_command);
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host->plugin_output);
free(new_host);
return NULL;
@@ -1456,10 +1503,13 @@
if(new_host->host_check_command!=NULL)
free(new_host->host_check_command);
if(new_host->notification_period!=NULL)
free(new_host->notification_period);
free(new_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(new_host->secondary_address);
+ /* end of modifications */
free(new_host->alias);
free(new_host->name);
free(new_host);
return NULL;
}
@@ -1482,10 +1532,13 @@
#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);
+ /* begin modification to define sec. ipaddress */
+ printf("\tSecondary Address: %s\n",new_host->secondary_address);
+ /* end of modifications */
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);
printf("\tNotify On Down: %s\n",(new_host->notify_on_down==1)?"yes":"no");
printf("\tNotify On Unreachable: %s\n",(new_host->notify_on_unreachable==1)?"yes":"no");
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/include/nagios.h.in nagios-2.0rc1-hacked/include/nagios.h.in
--- nagios-2.0rc1/include/nagios.h.in 2005-12-23 20:31:36.000000000 +0100
+++ nagios-2.0rc1-hacked/include/nagios.h.in 2006-01-10 16:27:36.753484792 +0100
@@ -47,11 +47,12 @@
#define MAX_STATEID_LENGTH 2
#define MAX_PERCENTCHANGE_LENGTH 8
#define MACRO_ENV_VAR_PREFIX "NAGIOS_"
-#define MACRO_X_COUNT 99 /* size of macro_x[] array */
+/* change count to 100 because we defined a new macro SECONDARYHOSTADDRESS */
+#define MACRO_X_COUNT 100 /* size of macro_x[] array */
#define MACRO_HOSTNAME 0
#define MACRO_HOSTALIAS 1
#define MACRO_HOSTADDRESS 2
#define MACRO_SERVICEDESC 3
@@ -148,10 +149,12 @@
#define MACRO_TOTALSERVICEPROBLEMS 94
#define MACRO_TOTALSERVICEPROBLEMSUNHANDLED 95
#define MACRO_PROCESSSTARTTIME 96
#define MACRO_HOSTCHECKTYPE 97
#define MACRO_SERVICECHECKTYPE 98
+#define MACRO_SECONDARYHOSTADDRESS 99 /* modification to define sec. ipaddress */
+
#define DEFAULT_LOG_LEVEL 1 /* log all events to main log file */
#define DEFAULT_USE_SYSLOG 1 /* log events to syslog? 1=yes, 0=no */
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/include/objects.h nagios-2.0rc1-hacked/include/objects.h
--- nagios-2.0rc1/include/objects.h 2005-12-27 19:55:10.000000000 +0100
+++ nagios-2.0rc1-hacked/include/objects.h 2006-01-10 12:59:57.000000000 +0100
@@ -127,10 +127,13 @@
/* HOST structure */
typedef struct host_struct{
char *name;
char *alias;
char *address;
+ /* begin modification to define sec. ipaddress */
+ char *secondary_address;
+ /* end of modification */
hostsmember *parent_hosts;
char *host_check_command;
int check_interval;
int max_attempts;
char *event_handler;
@@ -530,11 +533,14 @@
/**** Object Creation Functions ****/
contact *add_contact(char *,char *,char *,char *,char **,char *,char *,int,int,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 *,char *,int,int,int,int,int,int,int,char *,int,char *,int,int,char *,int,int,double,double,int,int,int,int,int,char *,int,int,int,int,int); /* adds a host definition */
+/* begin modification to define sec. ipaddress */
+/* added char * for method declaration */
+host *add_host(char *,char *,char *,char *,char *,int,int,int,int,int,int,int,char *,int,char *,int,int,char *,int,int,double,double,int,int,int,int,int,char *,int,int,int,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 */
contactgroupsmember *add_contactgroup_to_host(host *,char *); /* adds a contactgroup 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 */
hostgroup *add_hostgroup(char *,char *); /* adds a hostgroup definition */
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/xdata/xodtemplate.c nagios-2.0rc1-hacked/xdata/xodtemplate.c
--- nagios-2.0rc1/xdata/xodtemplate.c 2005-12-23 21:20:00.000000000 +0100
+++ nagios-2.0rc1-hacked/xdata/xodtemplate.c 2006-01-10 13:52:50.000000000 +0100
@@ -1205,10 +1205,13 @@
new_host->template=NULL;
new_host->name=NULL;
new_host->host_name=NULL;
new_host->alias=NULL;
new_host->address=NULL;
+ /* begin modification to define sec. ipaddress */
+ new_host->secondary_address=NULL;
+ /* end of modification */
new_host->parents=NULL;
new_host->hostgroups=NULL;
new_host->check_command=NULL;
new_host->check_period=NULL;
new_host->event_handler=NULL;
@@ -2650,10 +2653,21 @@
printf("Error: Could not allocate memory for host address.\n");
#endif
return ERROR;
}
}
+ /* begin modification to define sec. ipaddress */
+ 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){
#ifdef DEBUG1
printf("Error: Could not allocate memory for host parents.\n");
@@ -5957,10 +5971,14 @@
this_host->host_name=strdup(template_host->host_name);
if(this_host->alias==NULL && template_host->alias!=NULL)
this_host->alias=strdup(template_host->alias);
if(this_host->address==NULL && template_host->address!=NULL)
this_host->address=strdup(template_host->address);
+ /* begin modification to define sec. ipaddress */
+ 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->hostgroups==NULL && template_host->hostgroups!=NULL)
this_host->hostgroups=strdup(template_host->hostgroups);
if(this_host->check_command==NULL && template_host->check_command!=NULL)
@@ -8023,13 +8041,15 @@
if(this_host->alias==NULL && this_host->host_name!=NULL)
this_host->alias=strdup(this_host->host_name);
if(this_host->address==NULL && this_host->host_name!=NULL)
this_host->address=strdup(this_host->host_name);
+ /* begin modification to define sec. ipaddress */
+ /* added (this_host->secondary_address==NULL)?this_host->address:this_host->secondary_address, */
/* 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->check_period,this_host->check_interval,this_host->max_check_attempts,this_host->notify_on_recovery,this_host->notify_on_down,this_host->notify_on_unreachable,this_host->notify_on_flapping,this_host->notification_interval,this_host->notification_period,this_host->notifications_enabled,this_host->check_command,this_host->active_checks_enabled,this_host->passive_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->check_freshness,this_host->freshness_threshold,this_host->retain_status_information,this_host->retain_nonstatus_information,this_host->obsess_over_host);
-
+ 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->check_period,this_host->check_interval,this_host->max_check_attempts,this_host->notify_on_recovery,this_host->notify_on_down,this_host->notify_on_unreachable,this_host->notify_on_flapping,this_host->notification_interval,this_host->notification_period,this_host->notifications_enabled,this_host->check_command,this_host->active_checks_enabled,this_host->passive_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->check_freshness,this_host->freshness_threshold,this_host->retain_status_information,this_host->retain_nonstatus_information,this_host->obsess_over_host);
+ /* end of modification */
#ifdef TEST_DEBUG
printf("HOST: %s, MAXATTEMPTS: %d, NOTINVERVAL: %d \n",this_host->host_name,this_host->max_check_attempts,this_host->notification_interval);
#endif
/* return with an error if we couldn't add the host */
@@ -9432,10 +9452,14 @@
fprintf(fp,"\thost_name\t%s\n",temp_host->host_name);
if(temp_host->alias)
fprintf(fp,"\talias\t%s\n",temp_host->alias);
if(temp_host->address)
fprintf(fp,"\taddress\t%s\n",temp_host->address);
+ /* begin modification to define sec. ipaddress */
+ if(temp_host->secondary_address)
+ fprintf(fp,"\tsecondary_address\t%s\n",temp_host->secondary_address);
+ /* end of modification */
if(temp_host->parents)
fprintf(fp,"\tparents\t%s\n",temp_host->parents);
if(temp_host->check_period)
fprintf(fp,"\tcheck_period\t%s\n",temp_host->check_period);
if(temp_host->check_command)
@@ -9943,10 +9967,13 @@
free(this_host->template);
free(this_host->name);
free(this_host->host_name);
free(this_host->alias);
free(this_host->address);
+ /* begin modification to define sec. ipaddress */
+ free(this_host->secondary_address);
+ /* end of modification */
free(this_host->parents);
free(this_host->hostgroups);
free(this_host->check_command);
free(this_host->check_period);
free(this_host->event_handler);
diff -x .cvsignore -Nr --unified=5 nagios-2.0rc1/xdata/xodtemplate.h nagios-2.0rc1-hacked/xdata/xodtemplate.h
--- nagios-2.0rc1/xdata/xodtemplate.h 2005-11-16 09:49:35.000000000 +0100
+++ nagios-2.0rc1-hacked/xdata/xodtemplate.h 2006-01-10 13:54:28.000000000 +0100
@@ -149,10 +149,13 @@
int _start_line;
char *host_name;
char *alias;
char *address;
+ /* begin modification to define sec. ipaddress */
+ char *secondary_address;
+ /* end of modification */
char *parents;
char *hostgroups;
char *check_command;
char *check_period;
int check_interval;
|