OK, please don't laugh. I inherited this, and the modern nagios host I have built are CentOS 7 with 4.1.1 on them.
We are running 3.5.0 on the older generation. We have ~10 nagios hosts due to inherited architecture, and only one is exhibiting this behavior.
Note that all testing and snippets above are from one box. It isn't that some Nagios instances work and others do not. From one box some services work and some do not.
Code: Select all
diff -ru nagios/base/commands.c nagios-new/base/commands.c
--- nagios/base/commands.c 2011-07-26 00:16:12.000000000 +0000
+++ nagios-new/base/commands.c 2013-06-09 18:35:54.000000000 +0000
@@ -2078,6 +2078,10 @@
real_host_name = temp_host->name;
break;
}
+ if(!strcmp(host_name, temp_host->address6)) {
+ real_host_name = temp_host->name;
+ break;
+ }
}
}
@@ -2219,6 +2223,10 @@
real_host_name = temp_host->name;
break;
}
+ if(!strcmp(host_name, temp_host->address6)) {
+ real_host_name = temp_host->name;
+ break;
+ }
}
}
diff -ru nagios/cgi/config.c nagios-new/cgi/config.c
--- nagios/cgi/config.c 2013-02-27 01:37:32.000000000 +0000
+++ nagios-new/cgi/config.c 2013-06-09 18:35:54.000000000 +0000
@@ -485,6 +485,7 @@
printf("<TH CLASS='data'>Host Name</TH>");
printf("<TH CLASS='data'>Alias/Description</TH>");
printf("<TH CLASS='data'>Address</TH>");
+ printf("<TH CLASS='data'>Address6</TH>");
printf("<TH CLASS='data'>Parent Hosts</TH>");
printf("<TH CLASS='data'>Max. Check Attempts</TH>");
printf("<TH CLASS='data'>Check Interval</TH>\n");
@@ -544,6 +545,7 @@
url_encode(temp_host->name), CONFIG_CGI, url_encode(temp_host->name), html_encode(temp_host->name, FALSE));
printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_host->alias, FALSE));
printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_host->address, FALSE));
+ printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_host->address6, FALSE));
printf("<TD CLASS='%s'>", bg_class);
for(temp_hostsmember = temp_host->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
diff -ru nagios/cgi/extinfo.c nagios-new/cgi/extinfo.c
--- nagios/cgi/extinfo.c 2011-08-17 07:36:27.000000000 +0000
+++ nagios-new/cgi/extinfo.c 2013-06-09 18:35:54.000000000 +0000
@@ -247,6 +247,9 @@
printf("function nagios_get_host_address()\n{\n");
printf("return \"%s\";\n", temp_host->address);
printf("}\n");
+ printf("function nagios_get_host_address6()\n{\n");
+ printf("return \"%s\";\n", temp_host->address6);
+ printf("}\n");
if(temp_service != NULL) {
printf("function nagios_get_service_description()\n{\n");
printf("return \"%s\";\n", temp_service->description);
@@ -351,7 +354,7 @@
if(found == FALSE)
printf("No hostgroups");
printf("</DIV><BR>\n");
- printf("<DIV CLASS='data'>%s</DIV>\n", temp_host->address);
+ printf("<DIV CLASS='data'>%s, %s</DIV>\n", temp_host->address, temp_host->address6);
}
if(display_type == DISPLAY_SERVICE_INFO) {
printf("<DIV CLASS='data'>Service</DIV><DIV CLASS='dataTitle'>%s</DIV><DIV CLASS='data'>On Host</DIV>\n", service_desc);
@@ -371,7 +374,7 @@
printf("No servicegroups.");
printf("</DIV><BR>\n");
- printf("<DIV CLASS='data'>%s</DIV>\n", temp_host->address);
+ printf("<DIV CLASS='data'>%s, %s</DIV>\n", temp_host->address, temp_host->address6);
}
if(display_type == DISPLAY_HOSTGROUP_INFO) {
printf("<DIV CLASS='data'>Hostgroup</DIV>\n");
diff -ru nagios/cgi/status.c nagios-new/cgi/status.c
--- nagios/cgi/status.c 2013-03-09 21:46:35.000000000 +0000
+++ nagios-new/cgi/status.c 2013-06-09 18:53:24.000000000 +0000
@@ -285,6 +285,11 @@
host_name = strdup(temp_host->name);
break;
}
+ if(!strcmp(host_name,temp_host->address6)){
+ free(host_name);
+ host_name=strdup(temp_host->name);
+ break;
+ }
}
if(temp_host == NULL) {
for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
@@ -1707,7 +1712,7 @@
printf("<td align='left'>\n");
printf("<table border=0 cellpadding=0 cellspacing=0>\n");
printf("<tr>\n");
- printf("<td align=left valign=center class='status%s'><a href='%s?type=%d&host=%s' title='%s'>%s</a></td>\n", host_status_bg_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_status->host_name), temp_host->address, temp_status->host_name);
+ printf("<td align=left valign=center class='status%s'><a href='%s?type=%d&host=%s' title='%s %s'>%s</a></td>\n", host_status_bg_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_status->host_name), temp_host->address, temp_host->address6, temp_status->host_name);
printf("</tr>\n");
printf("</table>\n");
printf("</td>\n");
@@ -2240,7 +2245,7 @@
printf("<td align='left'>\n");
printf("<table border=0 cellpadding=0 cellspacing=0>\n");
printf("<tr>\n");
- printf("<td align=left valign=center class='status%s'><a href='%s?type=%d&host=%s' title='%s'>%s</a> </td>\n", status_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_status->host_name), temp_host->address, temp_status->host_name);
+ printf("<td align=left valign=center class='status%s'><a href='%s?type=%d&host=%s' title='%s %s'>%s</a> </td>\n", status_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_status->host_name), temp_host->address, temp_host->address6, temp_status->host_name);
printf("</tr>\n");
printf("</table>\n");
printf("</td>\n");
@@ -3678,7 +3683,7 @@
printf("<table border=0 WIDTH=100%% cellpadding=0 cellspacing=0>\n");
printf("<tr class='status%s'>\n", status_bg_class);
- printf("<td class='status%s'><a href='%s?host=%s&style=detail' title='%s'>%s</a></td>\n", status_bg_class, STATUS_CGI, url_encode(hststatus->host_name), temp_host->address, hststatus->host_name);
+ printf("<td class='status%s'><a href='%s?host=%s&style=detail' title='%s %s'>%s</a></td>\n", status_bg_class, STATUS_CGI, url_encode(hststatus->host_name), temp_host->address, temp_host->address6, hststatus->host_name);
if(temp_host->icon_image != NULL) {
printf("<td class='status%s' WIDTH=5></td>\n", status_bg_class);
diff -ru nagios/cgi/statusmap.c nagios-new/cgi/statusmap.c
--- nagios/cgi/statusmap.c 2011-08-17 07:36:27.000000000 +0000
+++ nagios-new/cgi/statusmap.c 2013-06-09 18:35:54.000000000 +0000
@@ -1955,6 +1955,7 @@
printf("<tr><td class=\\\"popupText\\\">Name:</td><td class=\\\"popupText\\\"><b>%s</b></td></tr>", escape_string(hst->name));
printf("<tr><td class=\\\"popupText\\\">Alias:</td><td class=\\\"popupText\\\"><b>%s</b></td></tr>", escape_string(hst->alias));
printf("<tr><td class=\\\"popupText\\\">Address:</td><td class=\\\"popupText\\\"><b>%s</b></td></tr>", html_encode(hst->address, TRUE));
+ printf("<tr><td class=\\\"popupText\\\">Address6:</td><td class=\\\"popupText\\\"><b>%s</b></td></tr>", html_encode(hst->address6, TRUE));
printf("<tr><td class=\\\"popupText\\\">State:</td><td class=\\\"popupText\\\"><b>");
/* get the status of the host (pending, up, down, or unreachable) */
diff -ru nagios/common/macros.c nagios-new/common/macros.c
--- nagios/common/macros.c 2013-03-09 21:46:35.000000000 +0000
+++ nagios-new/common/macros.c 2013-06-09 18:42:33.000000000 +0000
@@ -679,6 +679,7 @@
case MACRO_HOSTNAME:
case MACRO_HOSTALIAS:
case MACRO_HOSTADDRESS:
+ case MACRO_HOSTADDRESS6:
case MACRO_LASTHOSTCHECK:
case MACRO_LASTHOSTSTATECHANGE:
case MACRO_HOSTOUTPUT:
@@ -1616,6 +1617,9 @@
case MACRO_HOSTADDRESS:
*output = (char *)strdup(temp_host->address);
break;
+ case MACRO_HOSTADDRESS6:
+ *output = (char *)strdup(temp_host->address6);
+ break;
#ifdef NSCORE
case MACRO_HOSTSTATE:
if(temp_host->current_state == HOST_DOWN)
@@ -2616,6 +2620,7 @@
add_macrox_name(HOSTNAME);
add_macrox_name(HOSTALIAS);
add_macrox_name(HOSTADDRESS);
+ add_macrox_name(HOSTADDRESS6);
add_macrox_name(SERVICEDESC);
add_macrox_name(SERVICESTATE);
add_macrox_name(SERVICESTATEID);
@@ -2988,6 +2993,7 @@
my_free(mac->x[MACRO_HOSTDISPLAYNAME]);
my_free(mac->x[MACRO_HOSTALIAS]);
my_free(mac->x[MACRO_HOSTADDRESS]);
+ my_free(mac->x[MACRO_HOSTADDRESS6]);
my_free(mac->x[MACRO_HOSTOUTPUT]);
my_free(mac->x[MACRO_LONGHOSTOUTPUT]);
my_free(mac->x[MACRO_HOSTPERFDATA]);
diff -ru nagios/common/objects.c nagios-new/common/objects.c
--- nagios/common/objects.c 2011-08-24 12:15:21.000000000 +0000
+++ nagios-new/common/objects.c 2013-06-09 18:35:54.000000000 +0000
@@ -593,7 +593,7 @@
/* add a new host definition */
-host *add_host(char *name, char *display_name, char *alias, char *address, char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notify_flapping, int notify_downtime, double notification_interval, double first_notification_delay, 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 flap_detection_on_up, int flap_detection_on_down, int flap_detection_on_unreachable, int stalk_on_up, int stalk_on_down, int stalk_on_unreachable, int process_perfdata, int failure_prediction_enabled, char *failure_prediction_options, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, char *vrml_image, char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int should_be_drawn, int retain_status_information, int retain_nonstatus_information, int obsess_over_host) {
+host *add_host(char *name, char *display_name, char *alias, char *address, char *address6, char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notify_flapping, int notify_downtime, double notification_interval, double first_notification_delay, 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 flap_detection_on_up, int flap_detection_on_down, int flap_detection_on_unreachable, int stalk_on_up, int stalk_on_down, int stalk_on_unreachable, int process_perfdata, int failure_prediction_enabled, char *failure_prediction_options, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, char *vrml_image, char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int should_be_drawn, int retain_status_information, int retain_nonstatus_information, int obsess_over_host) {
host *new_host = NULL;
int result = OK;
#ifdef NSCORE
@@ -641,6 +641,8 @@
result = ERROR;
if((new_host->address = (char *)strdup(address)) == NULL)
result = ERROR;
+ if((new_host->address6 = (char *)strdup(address6)) == NULL)
+ result = ERROR;
if(check_period) {
if((new_host->check_period = (char *)strdup(check_period)) == NULL)
result = ERROR;
@@ -819,6 +821,7 @@
my_free(new_host->notification_period);
my_free(new_host->check_period);
my_free(new_host->address);
+ my_free(new_host->address6);
my_free(new_host->alias);
my_free(new_host->display_name);
my_free(new_host->name);
@@ -3266,6 +3269,7 @@
my_free(this_host->display_name);
my_free(this_host->alias);
my_free(this_host->address);
+ my_free(this_host->address6);
#ifdef NSCORE
my_free(this_host->plugin_output);
my_free(this_host->long_plugin_output);
diff -ru nagios/include/macros.h nagios-new/include/macros.h
--- nagios/include/macros.h 2012-11-12 18:27:43.000000000 +0000
+++ nagios-new/include/macros.h 2013-06-09 18:35:54.000000000 +0000
@@ -40,7 +40,7 @@
#define MAX_USER_MACROS 256 /* maximum number of $USERx$ macros */
-#define MACRO_X_COUNT 153 /* size of macro_x[] array */
+#define MACRO_X_COUNT 154 /* size of macro_x[] array */
NAGIOS_BEGIN_DECL
@@ -216,6 +216,7 @@
#define MACRO_LASTHOSTSTATEID 150
#define MACRO_LASTSERVICESTATE 151
#define MACRO_LASTSERVICESTATEID 152
+#define MACRO_HOSTADDRESS6 153
diff -ru nagios/include/objects.h nagios-new/include/objects.h
--- nagios/include/objects.h 2012-11-12 18:27:43.000000000 +0000
+++ nagios-new/include/objects.h 2013-06-09 18:46:29.000000000 +0000
@@ -266,6 +266,7 @@
char *display_name;
char *alias;
char *address;
+ char *address6;
hostsmember *parent_hosts;
hostsmember *child_hosts;
servicesmember *services;
@@ -634,7 +635,7 @@
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 */
customvariablesmember *add_custom_variable_to_contact(contact *, char *, char *); /* adds a custom variable to a service definition */
-host *add_host(char *, char *, char *, char *, char *, int, double, double, int, int, int, int, int, int, double, double, char *, int, char *, int, int, char *, int, int, double, double, int, int, int, int, int, int, int, int, char *, int, int, char *, char *, char *, char *, char *, char *, char *, int, int, int, double, double, double, int, int, int, int, int); /* adds a host definition */
+host *add_host(char *, char *, char *, char *, char *, char *, int, double, double, int, int, int, int, int, int, double, double, char *, int, char *, int, int, char *, int, int, double, double, int, int, int, int, int, int, int, int, char *, int, int, char *, char *, char *, char *, char *, char *, char *, int, int, int, double, double, double, int, int, int, int, int); /* adds a host definition */
hostsmember *add_parent_host_to_host(host *, char *); /* adds a parent host to a host definition */
hostsmember *add_child_link_to_host(host *, host *); /* adds a child host to a host definition */
contactgroupsmember *add_contactgroup_to_host(host *, char *); /* adds a contactgroup to a host definition */
diff -ru nagios/t-tap/test_checks.c nagios-new/t-tap/test_checks.c
--- nagios/t-tap/test_checks.c 2011-07-26 00:16:12.000000000 +0000
+++ nagios-new/t-tap/test_checks.c 2013-06-09 18:35:54.000000000 +0000
@@ -102,6 +102,7 @@
host1 = (host *)calloc(1, sizeof(host));
host1->name = strdup("Host1");
host1->address = strdup("127.0.0.1");
+ host1->address6 = strdup("::1");
host1->retry_interval = 1;
host1->check_interval = 5;
host1->check_options = 0;
diff -ru nagios/t-tap/test_events.c nagios-new/t-tap/test_events.c
--- nagios/t-tap/test_events.c 2011-07-26 00:16:12.000000000 +0000
+++ nagios-new/t-tap/test_events.c 2013-06-09 18:35:54.000000000 +0000
@@ -231,6 +231,7 @@
host1 = (host *)malloc(sizeof(host));
host1->name = strdup("Host1");
host1->address = strdup("127.0.0.1");
+ host1->address6 = strdup("::1");
host1->retry_interval = 1;
host1->check_interval = 5;
host1->check_options = 0;
diff -ru nagios/xdata/xodtemplate.c nagios-new/xdata/xodtemplate.c
--- nagios/xdata/xodtemplate.c 2013-03-09 21:46:35.000000000 +0000
+++ nagios-new/xdata/xodtemplate.c 2013-06-09 18:35:54.000000000 +0000
@@ -2369,6 +2369,10 @@
if((temp_host->address = (char *)strdup(value)) == NULL)
result = ERROR;
}
+ else if(!strcmp(variable, "address6")) {
+ if((temp_host->address6 = (char *)strdup(value)) == NULL)
+ result = ERROR;
+ }
else if(!strcmp(variable, "parents")) {
if(strcmp(value, XODTEMPLATE_NULL)) {
if((temp_host->parents = (char *)strdup(value)) == NULL)
@@ -6703,6 +6707,8 @@
this_host->alias = (char *)strdup(template_host->alias);
if(this_host->address == NULL && template_host->address != NULL)
this_host->address = (char *)strdup(template_host->address);
+ if(this_host->address6 == NULL && template_host->address6 != NULL)
+ this_host->address6 = (char *)strdup(template_host->address6);
xodtemplate_get_inherited_string(&template_host->have_parents, &template_host->parents, &this_host->have_parents, &this_host->parents);
xodtemplate_get_inherited_string(&template_host->have_host_groups, &template_host->host_groups, &this_host->have_host_groups, &this_host->host_groups);
@@ -8976,9 +8982,11 @@
this_host->alias = (char *)strdup(this_host->host_name);
if(this_host->address == NULL && this_host->host_name != NULL)
this_host->address = (char *)strdup(this_host->host_name);
+ if(this_host->address6 == NULL && this_host->host_name != NULL)
+ this_host->address6 = (char *)strdup(this_host->host_name);
/* add the host definition */
- new_host = add_host(this_host->host_name, this_host->display_name, this_host->alias, (this_host->address == NULL) ? this_host->host_name : this_host->address, this_host->check_period, this_host->initial_state, this_host->check_interval, this_host->retry_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->notify_on_downtime, this_host->notification_interval, this_host->first_notification_delay, 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->flap_detection_on_up, this_host->flap_detection_on_down, this_host->flap_detection_on_unreachable, 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->notes, this_host->notes_url, this_host->action_url, this_host->icon_image, this_host->icon_image_alt, this_host->vrml_image, this_host->statusmap_image, this_host->x_2d, this_host->y_2d, this_host->have_2d_coords, this_host->x_3d, this_host->y_3d, this_host->z_3d, this_host->have_3d_coords, TRUE, 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->display_name, this_host->alias, (this_host->address == NULL) ? this_host->host_name : this_host->address, (this_host->address6 == NULL) ? this_host->host_name : this_host->address6, this_host->check_period, this_host->initial_state, this_host->check_interval, this_host->retry_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->notify_on_downtime, this_host->notification_interval, this_host->first_notification_delay, 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->flap_detection_on_up, this_host->flap_detection_on_down, this_host->flap_detection_on_unreachable, 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->notes, this_host->notes_url, this_host->action_url, this_host->icon_image, this_host->icon_image_alt, this_host->vrml_image, this_host->statusmap_image, this_host->x_2d, this_host->y_2d, this_host->have_2d_coords, this_host->x_3d, this_host->y_3d, this_host->z_3d, this_host->have_3d_coords, TRUE, this_host->retain_status_information, this_host->retain_nonstatus_information, this_host->obsess_over_host);
/* return with an error if we couldn't add the host */
@@ -10370,6 +10378,8 @@
fprintf(fp, "\talias\t%s\n", temp_host->alias);
if(temp_host->address)
fprintf(fp, "\taddress\t%s\n", temp_host->address);
+ if(temp_host->address6)
+ fprintf(fp, "\taddress6\t%s\n", temp_host->address6);
if(temp_host->parents)
fprintf(fp, "\tparents\t%s\n", temp_host->parents);
if(temp_host->check_period)
@@ -11574,6 +11584,7 @@
my_free(this_host->alias);
my_free(this_host->display_name);
my_free(this_host->address);
+ my_free(this_host->address6);
my_free(this_host->parents);
my_free(this_host->host_groups);
my_free(this_host->check_command);
diff -ru nagios/xdata/xodtemplate.h nagios-new/xdata/xodtemplate.h
--- nagios/xdata/xodtemplate.h 2011-07-26 00:16:12.000000000 +0000
+++ nagios-new/xdata/xodtemplate.h 2013-06-09 18:35:54.000000000 +0000
@@ -229,6 +229,7 @@
char *display_name;
char *alias;
char *address;
+ char *address6;
char *parents;
char *host_groups;
char *check_command;