diff -rupN zb_org/src/libs/zbxdbcache/dbconfig.c zb_patched/src/libs/zbxdbcache/dbconfig.c --- zb_org/src/libs/zbxdbcache/dbconfig.c 2013-02-12 15:27:22.000000000 +0400 +++ zb_patched/src/libs/zbxdbcache/dbconfig.c 2013-02-18 14:31:24.000000000 +0400 @@ -4127,6 +4127,9 @@ int DCconfig_activate_host(DC_ITEM *item dc_host->jmx_available = HOST_AVAILABLE_TRUE; dc_host->jmx_disable_until = 0; break; + case ITEM_TYPE_INTERNAL: + dc_host->available = HOST_AVAILABLE_TRUE; + break; default: goto unlock; } @@ -4187,6 +4190,13 @@ int DCconfig_deactivate_host(DC_ITEM *it available = &dc_host->jmx_available; disable_until = &dc_host->jmx_disable_until; break; + case ITEM_TYPE_INTERNAL: + errors_from = &dc_host->errors_from; + /* set date to disable host for sure */ + *errors_from = 1; + available = &dc_host->available; + disable_until = &dc_host->disable_until; + break; default: goto unlock; } diff -rupN zb_org/src/libs/zbxdbhigh/proxy.c zb_patched/src/libs/zbxdbhigh/proxy.c --- zb_org/src/libs/zbxdbhigh/proxy.c 2013-02-12 15:27:22.000000000 +0400 +++ zb_patched/src/libs/zbxdbhigh/proxy.c 2013-02-18 14:31:32.000000000 +0400 @@ -1062,6 +1062,10 @@ void process_host_availability(struct zb char tmp[HOST_ERROR_LEN_MAX], *sql = NULL, *error_esc; size_t sql_alloc = 4 * ZBX_KIBIBYTE, sql_offset = 0, tmp_offset; int no_data; + DC_ITEM item; + zbx_timespec_t timespec; + int available = HOST_AVAILABLE_TRUE; + zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); @@ -1098,24 +1102,32 @@ void process_host_availability(struct zb { zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "available=%d,", atoi(tmp)); no_data = 0; + if (atoi(tmp) == HOST_AVAILABLE_FALSE) + available = HOST_AVAILABLE_FALSE; } if (SUCCEED == zbx_json_value_by_name(&jp_row, ZBX_PROTO_TAG_SNMP_AVAILABLE, tmp, sizeof(tmp))) { zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "snmp_available=%d,", atoi(tmp)); no_data = 0; + if (atoi(tmp) == HOST_AVAILABLE_FALSE) + available = HOST_AVAILABLE_FALSE; } if (SUCCEED == zbx_json_value_by_name(&jp_row, ZBX_PROTO_TAG_IPMI_AVAILABLE, tmp, sizeof(tmp))) { zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "ipmi_available=%d,", atoi(tmp)); no_data = 0; + if (atoi(tmp) == HOST_AVAILABLE_FALSE) + available = HOST_AVAILABLE_FALSE; } if (SUCCEED == zbx_json_value_by_name(&jp_row, ZBX_PROTO_TAG_JMX_AVAILABLE, tmp, sizeof(tmp))) { zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "jmx_available=%d,", atoi(tmp)); no_data = 0; + if (atoi(tmp) == HOST_AVAILABLE_FALSE) + available = HOST_AVAILABLE_FALSE; } if (SUCCEED == zbx_json_value_by_name(&jp_row, ZBX_PROTO_TAG_ERROR, tmp, sizeof(tmp))) @@ -1164,6 +1176,22 @@ void process_host_availability(struct zb continue; } + if (SUCCEED != DCget_host_by_hostid(&item.host, hostid)) { + zabbix_log(LOG_LEVEL_CRIT, "cannot get host with hostid: %d", hostid); + continue; + } + + item.type = ITEM_TYPE_INTERNAL; + zbx_timespec(×pec); + + if (available == HOST_AVAILABLE_FALSE) + if (SUCCEED != DCconfig_deactivate_host(&item, timespec.sec)) + zabbix_log(LOG_LEVEL_CRIT, "cannot deactivate host with hostid: %d", item.host.hostid); + + if (available == HOST_AVAILABLE_TRUE) + if (SUCCEED != DCconfig_activate_host(&item)) + zabbix_log(LOG_LEVEL_CRIT, "cannot activate host with hostid: %d", item.host.hostid); + sql_offset--; zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, " where hostid=" ZBX_FS_UI64 ";\n", hostid);