diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-18 10:43:36 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-18 10:43:36 +0000 |
| commit | feb2c0310f6b67c8cd7a6f6839e598cd908486ca (patch) | |
| tree | 4735dc1f0072d5fa343a326901653a0c8cce2e48 /src | |
| parent | c72afce6e6b0b39177329359676f29d669867f24 (diff) | |
| download | zabbix-feb2c0310f6b67c8cd7a6f6839e598cd908486ca.tar.gz zabbix-feb2c0310f6b67c8cd7a6f6839e598cd908486ca.tar.xz zabbix-feb2c0310f6b67c8cd7a6f6839e598cd908486ca.zip | |
- [DEV-110] Proxy changes
git-svn-id: svn://svn.zabbix.com/trunk@5369 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
| -rw-r--r-- | src/libs/zbxdbhigh/db.c | 94 | ||||
| -rw-r--r-- | src/libs/zbxserver/functions.c | 10 | ||||
| -rw-r--r-- | src/zabbix_proxy/proxy.c | 16 |
3 files changed, 83 insertions, 37 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index 5187c68e..5dcb31a3 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -1300,31 +1300,32 @@ lbl_exit: #endif } - -int DBadd_history_log(zbx_uint64_t id, zbx_uint64_t itemid, char *value, int clock, int timestamp,char *source, int severity) +int DBadd_history_log(zbx_uint64_t id, zbx_uint64_t itemid, char *value, int clock, int timestamp, char *source, int severity) { - char value_esc[MAX_STRING_LEN]; - char source_esc[MAX_STRING_LEN]; + char value_esc[MAX_STRING_LEN]; + char source_esc[MAX_STRING_LEN]; - zabbix_log(LOG_LEVEL_DEBUG,"In add_history_log()"); + zabbix_log(LOG_LEVEL_DEBUG, "In add_history_log()"); DBescape_string(value,value_esc,MAX_STRING_LEN); DBescape_string(source,source_esc,MAX_STRING_LEN); + if(id == 0) id = DBget_maxid("history_log", "id"); - DBexecute("insert into history_log (id,clock,itemid,timestamp,value,source,severity) values (" ZBX_FS_UI64 ",%d," ZBX_FS_UI64 ",%d,'%s','%s',%d)", - id, - clock, - itemid, - timestamp, - value_esc, - source_esc, - severity); + + DBexecute("insert into history_log (id,clock,itemid,timestamp,value,source,severity)" + " values (" ZBX_FS_UI64 ",%d," ZBX_FS_UI64 ",%d,'%s','%s',%d)", + id, + clock, + itemid, + timestamp, + value_esc, + source_esc, + severity); return SUCCEED; } - int DBget_items_count(void) { int res; @@ -1835,7 +1836,7 @@ zbx_uint64_t DBget_maxid(char *tablename, char *fieldname) DB_ROW row; zbx_uint64_t ret1,ret2; zbx_uint64_t min, max; - int found = FAIL, dbres; + int found = FAIL, dbres, nodeid; const ZBX_TABLE *table; zabbix_log(LOG_LEVEL_DEBUG,"In DBget_maxid(%s,%s)", @@ -1843,18 +1844,19 @@ zbx_uint64_t DBget_maxid(char *tablename, char *fieldname) fieldname); table = DBget_table(tablename); + nodeid = CONFIG_NODEID >= 0 ? CONFIG_NODEID : 0; if (table->flags & ZBX_SYNC) { - min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)CONFIG_NODEID; - max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(99999999999); + min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)nodeid; + max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)nodeid+(zbx_uint64_t)__UINT64_C(99999999999); } else { - min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID; - max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(99999999999999); + min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid; + max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)nodeid+(zbx_uint64_t)__UINT64_C(99999999999999); } do { result = DBselect("select nextid from ids where nodeid=%d and table_name='%s' and field_name='%s'", - CONFIG_NODEID, + nodeid, tablename, fieldname); @@ -1879,7 +1881,7 @@ zbx_uint64_t DBget_maxid(char *tablename, char *fieldname) DBfree_result(result); dbres = DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values (%d,'%s','%s',"ZBX_FS_UI64")", - CONFIG_NODEID, + nodeid, tablename, fieldname, ret1); @@ -1887,13 +1889,13 @@ zbx_uint64_t DBget_maxid(char *tablename, char *fieldname) if (dbres < ZBX_DB_OK) { /* reshenie problemi nevidimosti novoj zapisi, sozdannoj v parallel'noj tranzakcii */ DBexecute("update ids set nextid=nextid+1 where nodeid=%d and table_name='%s' and field_name='%s'", - CONFIG_NODEID, + nodeid, tablename, fieldname); } DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values (%d,'%s','%s',"ZBX_FS_UI64")", - CONFIG_NODEID, + nodeid, tablename, fieldname, ret1); @@ -1904,19 +1906,19 @@ zbx_uint64_t DBget_maxid(char *tablename, char *fieldname) if((ret1 < min) || (ret1 >= max)) { DBexecute("delete from ids where nodeid=%d and table_name='%s' and field_name='%s'", - CONFIG_NODEID, + nodeid, tablename, fieldname); continue; } DBexecute("update ids set nextid=nextid+1 where nodeid=%d and table_name='%s' and field_name='%s'", - CONFIG_NODEID, + nodeid, tablename, fieldname); result = DBselect("select nextid from ids where nodeid=%d and table_name='%s' and field_name='%s'", - CONFIG_NODEID, + nodeid, tablename, fieldname); row = DBfetch(result); @@ -1976,3 +1978,43 @@ zbx_uint64_t DBget_maxid(char *tablename, char *fieldname) return ret;*/ } + +int DBproxy_add_history(zbx_uint64_t itemid, double value, int clock) +{ + zabbix_log(LOG_LEVEL_DEBUG, "In proxy_add_history()"); + + DBexecute("insert into history (clock,itemid,value) values (%d," ZBX_FS_UI64 "," ZBX_FS_DBL ")", + clock, + itemid, + value); + + return SUCCEED; +} + +int DBproxy_add_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock) +{ + zabbix_log(LOG_LEVEL_DEBUG, "In proxy_add_history_uint()"); + + DBexecute("insert into history_uint (clock,itemid,value) values (%d," ZBX_FS_UI64 "," ZBX_FS_UI64 ")", + clock, + itemid, + value); + + return SUCCEED; +} + +int DBproxy_add_history_str(zbx_uint64_t itemid, char *value, int clock) +{ + char value_esc[MAX_STRING_LEN]; + + zabbix_log(LOG_LEVEL_DEBUG, "In proxy_add_history_str()"); + + DBescape_string(value, value_esc, MAX_STRING_LEN); + + DBexecute("insert into history_str (clock,itemid,value) values (%d," ZBX_FS_UI64 ",'%s')", + clock, + itemid, + value_esc); + + return SUCCEED; +} diff --git a/src/libs/zbxserver/functions.c b/src/libs/zbxserver/functions.c index 77b06496..c3f5744c 100644 --- a/src/libs/zbxserver/functions.c +++ b/src/libs/zbxserver/functions.c @@ -629,27 +629,27 @@ static int proxy_add_history(DB_ITEM *item, AGENT_RESULT *value, int now) if(item->value_type==ITEM_VALUE_TYPE_UINT64) { if(GET_UI64_RESULT(value)) - DBadd_history_uint(item->itemid,value->ui64,now); + DBproxy_add_history_uint(item->itemid,value->ui64,now); } else if(item->value_type==ITEM_VALUE_TYPE_FLOAT) { if(GET_DBL_RESULT(value)) - DBadd_history(item->itemid,value->dbl,now); + DBproxy_add_history(item->itemid,value->dbl,now); } else if(item->value_type==ITEM_VALUE_TYPE_STR) { if(GET_STR_RESULT(value)) - DBadd_history_str(item->itemid,value->str,now); + DBproxy_add_history_str(item->itemid,value->str,now); } else if(item->value_type==ITEM_VALUE_TYPE_LOG) { if(GET_STR_RESULT(value)) - DBadd_history_log(0, item->itemid,value->str,now,item->timestamp,item->eventlog_source,item->eventlog_severity); + DBproxy_add_history_log(0, item->itemid,value->str,now,item->timestamp,item->eventlog_source,item->eventlog_severity); } else if(item->value_type==ITEM_VALUE_TYPE_TEXT) { if(GET_TEXT_RESULT(value)) - DBadd_history_text(item->itemid,value->text,now); + DBproxy_add_history_text(item->itemid,value->text,now); } else { diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c index 4025915e..bdccca72 100644 --- a/src/zabbix_proxy/proxy.c +++ b/src/zabbix_proxy/proxy.c @@ -447,10 +447,10 @@ int MAIN_ZABBIX_ENTRY(void) /* Do not close database. It is required for database cache */ /* DBclose();*/ - if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&node_sync_access, ZBX_MUTEX_NODE_SYNC)) { +/* if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&node_sync_access, ZBX_MUTEX_NODE_SYNC)) { zbx_error("Unable to create mutex for node syncs"); exit(FAIL); - } + }*/ threads = calloc(1+CONFIG_POLLER_FORKS+CONFIG_TRAPPERD_FORKS+CONFIG_PINGER_FORKS +CONFIG_HOUSEKEEPER_FORKS+CONFIG_UNREACHABLE_POLLER_FORKS @@ -517,13 +517,17 @@ int MAIN_ZABBIX_ENTRY(void) } else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS) { - main_pinger_loop(server_num, server_num - (CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS)); + zabbix_log(LOG_LEVEL_WARNING, "server #%d started [ICMP pinger]", + server_num); + + main_pinger_loop(ZBX_PROCESS_PROXY, server_num - (CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS)); } else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS - +CONFIG_HOUSEKEEPER_FORKS) + + CONFIG_HOUSEKEEPER_FORKS) { zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Housekeeper]", - server_num); + server_num); + main_housekeeper_loop(); } else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS + CONFIG_HOUSEKEEPER_FORKS @@ -610,7 +614,7 @@ void zbx_on_exit() free_database_cache(); } DBclose(); - zbx_mutex_destroy(&node_sync_access); +/* zbx_mutex_destroy(&node_sync_access);*/ zabbix_close_log(); #ifdef HAVE_SQLITE3 |
