diff options
-rw-r--r-- | include/db.h | 2 | ||||
-rw-r--r-- | src/libs/zbxdbhigh/db.c | 69 |
2 files changed, 70 insertions, 1 deletions
diff --git a/include/db.h b/include/db.h index 3bde2bdd..559de8a8 100644 --- a/include/db.h +++ b/include/db.h @@ -504,7 +504,9 @@ zbx_uint64_t DBget_maxid(char *table, char *field); int DBget_function_result(char **result,char *functionid); void DBupdate_host_availability(zbx_uint64_t hostid,int available,int clock,char *error); +void DBproxy_update_host_availability(zbx_uint64_t hostid, int available, int clock); int DBupdate_item_status_to_notsupported(zbx_uint64_t itemid, const char *error); +int DBproxy_update_item_status_to_notsupported(zbx_uint64_t itemid); int DBadd_service_alarm(zbx_uint64_t serviceid,int status,int clock); int DBadd_alert(zbx_uint64_t actionid, zbx_uint64_t triggerid, zbx_uint64_t userid, zbx_uint64_t mediatypeid, char *sendto, char *subject, char *message); void DBupdate_triggers_status_after_restart(void); diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index ed284cfb..5187c68e 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -33,7 +33,6 @@ #include "log.h" #include "zlog.h" #include "common.h" -#include "actions.h" #include "events.h" #include "threads.h" #include "dbcache.h" @@ -938,6 +937,58 @@ void DBupdate_host_availability(zbx_uint64_t hostid,int available,int clock, cha return; } +void DBproxy_update_host_availability(zbx_uint64_t hostid, int available, int clock) +{ + DB_RESULT result; + DB_ROW row; + int disable_until; + + zabbix_log(LOG_LEVEL_DEBUG,"In DBproxy_update_host_availability()"); + + result = DBselect("select available,disable_until from hosts where hostid=" ZBX_FS_UI64, + hostid); + + if (NULL == (row = DBfetch(result))) { + zabbix_log(LOG_LEVEL_ERR, "Cannot select host with hostid [" ZBX_FS_UI64 "]", + hostid); + zabbix_syslog("Cannot select host with hostid [" ZBX_FS_UI64 "]", + hostid); + goto out; + } + + disable_until = atoi(row[1]); + + if (available == atoi(row[0])) { + zabbix_log(LOG_LEVEL_DEBUG, "Host already has availability [%d]", + available); + goto out; + } + + switch (available) { + case HOST_AVAILABLE_TRUE: + DBexecute("update hosts set available=%d,errors_from=0 where hostid=" ZBX_FS_UI64, + HOST_AVAILABLE_TRUE, + hostid); + break; + case HOST_AVAILABLE_FALSE: + DBexecute("update hosts set available=%d where hostid=" ZBX_FS_UI64, + HOST_AVAILABLE_FALSE, + hostid); + break; + default: + zabbix_log( LOG_LEVEL_ERR, "Unknown host availability [%d] for hostid [" ZBX_FS_UI64 "]", + available, + hostid); + } + +out: + DBfree_result(result); + + zabbix_log(LOG_LEVEL_DEBUG,"End of DBproxy_update_host_availability()"); + + return; +} + int DBupdate_item_status_to_notsupported(zbx_uint64_t itemid, const char *error) { char error_esc[MAX_STRING_LEN]; @@ -966,6 +1017,22 @@ int DBupdate_item_status_to_notsupported(zbx_uint64_t itemid, const char *error) return SUCCEED; } +int DBproxy_update_item_status_to_notsupported(zbx_uint64_t itemid) +{ + int now; + + zabbix_log(LOG_LEVEL_DEBUG,"In DBproxy_update_item_status_to_notsupported()"); + + now = time(NULL); + + DBexecute("update items set status=%d,nextcheck=%d where itemid=" ZBX_FS_UI64, + ITEM_STATUS_NOTSUPPORTED, + CONFIG_REFRESH_UNSUPPORTED+now, + itemid); + + return SUCCEED; +} + int DBadd_trend(zbx_uint64_t itemid, double value, int clock) { DB_RESULT result; |