summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-04-10 13:36:21 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-04-10 13:36:21 +0000
commitcd58120468d324ee96922fc156f9e6ca651addb1 (patch)
tree4893ba3887eb2b0a18ab48fb15584dbc7f39f1b9
parent5324c016a35d893a4e76951d1a45546b5a5ddaf3 (diff)
downloadzabbix-cd58120468d324ee96922fc156f9e6ca651addb1.tar.gz
zabbix-cd58120468d324ee96922fc156f9e6ca651addb1.tar.xz
zabbix-cd58120468d324ee96922fc156f9e6ca651addb1.zip
- [DEV-141] improved performance of ZABBIX Proxy module
git-svn-id: svn://svn.zabbix.com/trunk@5609 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog1
-rw-r--r--include/db.h12
-rw-r--r--src/libs/zbxserver/functions.c10
-rw-r--r--src/zabbix_proxy/datasender/datasender.c44
-rw-r--r--src/zabbix_proxy/housekeeper/housekeeper.c6
5 files changed, 20 insertions, 53 deletions
diff --git a/ChangeLog b/ChangeLog
index 1da3e753..a582521b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes for 1.5.1:
+ - [DEV-141] improved performance of ZABBIX Proxy module (Sasha)
- [DEV-140] added support of zabbix[proxy,<proxyname>,lastaccess] (Sasha)
- [DEV-124] screen actions moved to Audit, added filter for Audit (Artem)
- [DEV-98] added support of ZABBIX Proxy (Sasha)
diff --git a/include/db.h b/include/db.h
index 15bbb096..994b6663 100644
--- a/include/db.h
+++ b/include/db.h
@@ -580,12 +580,10 @@ int DBadd_history_str(zbx_uint64_t itemid, char *value, int clock);
int DBadd_history_text(zbx_uint64_t itemid, char *value, int clock);
int DBadd_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock);
-int DBproxy_add_history(zbx_uint64_t itemid, double value, int clock);
-int DBproxy_add_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock);
-int DBproxy_add_history_str(zbx_uint64_t itemid, char *value, int clock);
-#define DBproxy_add_history_log(id, itemid, value, clock, timestamp, source, severity) \
- DBadd_history_log(id, itemid, value, clock, timestamp, source, severity)
-#define DBproxy_add_history_text(itemid, value, clock) \
- DBadd_history_text(itemid, value, clock)
+int DBproxy_add_history(const char *host, const char *key, int clock, double value);
+int DBproxy_add_history_uint(const char *host, const char *key, int clock, zbx_uint64_t value);
+int DBproxy_add_history_str(const char *host, const char *key, int clock, char *value);
+int DBproxy_add_history_text(const char *host, const char *key, int clock, char *value);
+int DBproxy_add_history_log(const char *host, const char *key, int clock, int timestamp, char *source, int severity, char *value);
#endif
diff --git a/src/libs/zbxserver/functions.c b/src/libs/zbxserver/functions.c
index 868cec24..273e1ae5 100644
--- a/src/libs/zbxserver/functions.c
+++ b/src/libs/zbxserver/functions.c
@@ -625,27 +625,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))
- DBproxy_add_history_uint(item->itemid,value->ui64,now);
+ DBproxy_add_history_uint(item->host_name, item->key, now, value->ui64);
}
else if(item->value_type==ITEM_VALUE_TYPE_FLOAT)
{
if(GET_DBL_RESULT(value))
- DBproxy_add_history(item->itemid,value->dbl,now);
+ DBproxy_add_history(item->host_name, item->key, now, value->dbl);
}
else if(item->value_type==ITEM_VALUE_TYPE_STR)
{
if(GET_STR_RESULT(value))
- DBproxy_add_history_str(item->itemid,value->str,now);
+ DBproxy_add_history_str(item->host_name, item->key, now, value->str);
}
else if(item->value_type==ITEM_VALUE_TYPE_LOG)
{
if(GET_STR_RESULT(value))
- DBproxy_add_history_log(0, item->itemid,value->str,now,item->timestamp,item->eventlog_source,item->eventlog_severity);
+ DBproxy_add_history_log(item->host_name, item->key, now, item->timestamp, item->eventlog_source, item->eventlog_severity, value->str);
}
else if(item->value_type==ITEM_VALUE_TYPE_TEXT)
{
if(GET_TEXT_RESULT(value))
- DBproxy_add_history_text(item->itemid,value->text,now);
+ DBproxy_add_history_text(item->host_name, item->key, now, value->text);
}
else
{
diff --git a/src/zabbix_proxy/datasender/datasender.c b/src/zabbix_proxy/datasender/datasender.c
index 10886126..eaed9d99 100644
--- a/src/zabbix_proxy/datasender/datasender.c
+++ b/src/zabbix_proxy/datasender/datasender.c
@@ -46,36 +46,10 @@ struct last_ids {
};
static ZBX_HISTORY_TABLE ht[]={
- {"history_sync", "history_lastid",
- {
- {"clock", ZBX_PROTO_TAG_CLOCK},
- {"value", ZBX_PROTO_TAG_VALUE},
- {NULL}
- }
- },
- {"history_uint_sync", "history_uint_lastid",
- {
- {"clock", ZBX_PROTO_TAG_CLOCK},
- {"value", ZBX_PROTO_TAG_VALUE},
- {NULL}
- }
- },
- {"history_str_sync", "history_str_lastid",
- {
- {"clock", ZBX_PROTO_TAG_CLOCK},
- {"value", ZBX_PROTO_TAG_VALUE},
- {NULL}
- }
- },
- {"history_text", "history_text_lastid",
- {
- {"clock", ZBX_PROTO_TAG_CLOCK},
- {"value", ZBX_PROTO_TAG_VALUE},
- {NULL}
- }
- },
- {"history_log", "history_log_lastid",
+ {"proxy_history", "history_lastid",
{
+ {"host", ZBX_PROTO_TAG_HOST},
+ {"key_", ZBX_PROTO_TAG_KEY},
{"clock", ZBX_PROTO_TAG_CLOCK},
{"timestamp", ZBX_PROTO_TAG_LOGTIMESTAMP},
{"source", ZBX_PROTO_TAG_LOGSOURCE},
@@ -225,14 +199,14 @@ static int get_history_data(struct zbx_json *j, const ZBX_HISTORY_TABLE *ht, zbx
get_lastid(ht, &id);
- offset += zbx_snprintf(sql + offset, sizeof(sql) - offset, "select d.id,h.host,i.key_");
+ offset += zbx_snprintf(sql + offset, sizeof(sql) - offset, "select id");
for (f = 0; ht->fields[f].field != NULL; f ++)
- offset += zbx_snprintf(sql + offset, sizeof(sql) - offset, ",d.%s",
+ offset += zbx_snprintf(sql + offset, sizeof(sql) - offset, ",%s",
ht->fields[f].field);
- offset += zbx_snprintf(sql + offset, sizeof(sql) - offset, " from hosts h,items i,%s d"
- " where h.hostid=i.hostid and i.itemid=d.itemid and d.id>" ZBX_FS_UI64 " order by d.id",
+ offset += zbx_snprintf(sql + offset, sizeof(sql) - offset, " from %s"
+ " where id>" ZBX_FS_UI64 " order by id",
ht->table,
id);
@@ -245,8 +219,6 @@ static int get_history_data(struct zbx_json *j, const ZBX_HISTORY_TABLE *ht, zbx
*lastid = zbx_atoui64(row[0]);
- zbx_json_addstring(j, ZBX_PROTO_TAG_HOST, row[1], ZBX_JSON_TYPE_STRING);
- zbx_json_addstring(j, ZBX_PROTO_TAG_KEY, row[2], ZBX_JSON_TYPE_STRING);
for (f = 0; ht->fields[f].field != NULL; f ++) {
field = DBget_field(table, ht->fields[f].field);
@@ -261,7 +233,7 @@ static int get_history_data(struct zbx_json *j, const ZBX_HISTORY_TABLE *ht, zbx
break;
}
- zbx_json_addstring(j, ht->fields[f].tag, row[f + 3], jt);
+ zbx_json_addstring(j, ht->fields[f].tag, row[f + 1], jt);
}
records++;
diff --git a/src/zabbix_proxy/housekeeper/housekeeper.c b/src/zabbix_proxy/housekeeper/housekeeper.c
index 61407582..d700cdfb 100644
--- a/src/zabbix_proxy/housekeeper/housekeeper.c
+++ b/src/zabbix_proxy/housekeeper/housekeeper.c
@@ -110,11 +110,7 @@ static int housekeeping_history(int now)
zabbix_log(LOG_LEVEL_DEBUG, "In housekeeping_history()");
- records += delete_history("history_sync", "history_lastid", now);
- records += delete_history("history_uint_sync", "history_uint_lastid", now);
- records += delete_history("history_str_sync", "history_str_lastid", now);
- records += delete_history("history_text", "history_text_lastid", now);
- records += delete_history("history_log", "history_log_lastid", now);
+ records += delete_history("proxy_history", "history_lastid", now);
records += delete_history("proxy_dhistory", "dhistory_lastid", now);
return records;