diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-01 13:45:53 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-01 13:45:53 +0000 |
| commit | cfac845b1a97348e527e36a0de4a651900fa696f (patch) | |
| tree | 985bfab14a575adb0bbea9af3344832a3acf5469 /src | |
| parent | 48ee2bcd6f859d9999dad252aadbfec9515309fb (diff) | |
- [DEV-98] added support of ZABBIX Proxy
git-svn-id: svn://svn.zabbix.com/trunk@5573 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
| -rw-r--r-- | src/libs/zbxdb/db.c | 25 | ||||
| -rw-r--r-- | src/libs/zbxdbhigh/db.c | 15 | ||||
| -rw-r--r-- | src/zabbix_server/trapper/trapper.c | 11 |
3 files changed, 24 insertions, 27 deletions
diff --git a/src/libs/zbxdb/db.c b/src/libs/zbxdb/db.c index a353c1ac..13dbb87b 100644 --- a/src/libs/zbxdb/db.c +++ b/src/libs/zbxdb/db.c @@ -73,6 +73,9 @@ void zbx_db_close(void) int zbx_db_connect(char *host, char *user, char *password, char *dbname, char *dbsocket, int port) { int ret = ZBX_DB_OK; +#ifdef HAVE_SQLITE3 + char *p, *path; +#endif /* HAVE_SQLITE3 */ /* zabbix_log(LOG_LEVEL_ERR, "[%s] [%s] [%s]\n",dbname, dbuser, dbpassword ); */ #ifdef HAVE_MYSQL @@ -196,8 +199,7 @@ int zbx_db_connect(char *host, char *user, char *password, char *dbname, char *d ret = sqlite3_open(dbname, &conn); /* check to see that the backend connection was successfully made */ - if(ret) - { + if (ret) { zabbix_log(LOG_LEVEL_ERR, "Can't open database [%s]: %s\n", dbname, sqlite3_errmsg(conn)); DBclose(); exit(FAIL); @@ -206,16 +208,19 @@ int zbx_db_connect(char *host, char *user, char *password, char *dbname, char *d /* Do not return SQLITE_BUSY immediately, wait for N ms */ sqlite3_busy_timeout(conn, 60*1000); -/* if(ZBX_MUTEX_ERROR == php_sem_get(&sqlite_access, dbname)) - { - zbx_error("Unable to create mutex for sqlite"); - exit(FAIL); - }*/ - sqlite_transaction_started = 0; - DBexecute("PRAGMA synchronous=OFF"); - DBexecute("PRAGMA temp_store=MEMORY"); + path = strdup(dbname); + if (NULL != (p = strrchr(path, '/'))) + *++p = '\0'; + else + *path = '\0'; + + DBexecute("PRAGMA synchronous = 0"); /* OFF */ + DBexecute("PRAGMA temp_store = 2"); /* MEMORY */ + DBexecute("PRAGMA temp_store_directory = '%s'", path); + + zbx_free(path); return ret; #endif diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index 84cf6e57..a58662fc 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -2007,11 +2007,6 @@ 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); -*/ DBexecute("insert into history_sync (clock,itemid,value) values (%d," ZBX_FS_UI64 "," ZBX_FS_DBL ")", clock, itemid, @@ -2024,11 +2019,6 @@ 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); -*/ DBexecute("insert into history_uint_sync (clock,itemid,value) values (%d," ZBX_FS_UI64 "," ZBX_FS_UI64 ")", clock, itemid, @@ -2045,11 +2035,6 @@ int DBproxy_add_history_str(zbx_uint64_t itemid, char *value, int clock) 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); -*/ DBexecute("insert into history_str_sync (clock,itemid,value) values (%d," ZBX_FS_UI64 ",'%s')", clock, itemid, diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c index 518245b2..ccaa6431 100644 --- a/src/zabbix_server/trapper/trapper.c +++ b/src/zabbix_server/trapper/trapper.c @@ -254,8 +254,15 @@ static int process_data(zbx_sock_t *sock, zbx_uint64_t proxy_hostid, time_t now, init_result(&agent); if( SUCCEED == set_result_type(&agent, item.value_type, value)) { - process_new_value(&item, &agent, now); - update_triggers(item.itemid); + switch (zbx_process) { + case ZBX_PROCESS_SERVER: + process_new_value(&item, &agent, now); + update_triggers(item.itemid); + break; + case ZBX_PROCESS_PROXY: + proxy_process_new_value(&item, &agent, now); + break; + } } else { zabbix_log( LOG_LEVEL_WARNING, "Type of received value [%s] is not suitable for [%s@%s]", value, |
