diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-08-13 07:08:20 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-08-13 07:08:20 +0000 |
| commit | f8ec2508ed6a4c962bb6cc996881232ab4a2d3f0 (patch) | |
| tree | a45331cb2daf3977e22903421024d0f5d6845ea3 /src/zabbix_proxy/datasender | |
| parent | fff324e490695b15733e2c36e1948a18416bbacb (diff) | |
| download | zabbix-f8ec2508ed6a4c962bb6cc996881232ab4a2d3f0.tar.gz zabbix-f8ec2508ed6a4c962bb6cc996881232ab4a2d3f0.tar.xz zabbix-f8ec2508ed6a4c962bb6cc996881232ab4a2d3f0.zip | |
- [DEV-137] Misc bugs and improvements
[added timediff for processing nextchecks for proxy items]
git-svn-id: svn://svn.zabbix.com/trunk@5902 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_proxy/datasender')
| -rw-r--r-- | src/zabbix_proxy/datasender/datasender.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/src/zabbix_proxy/datasender/datasender.c b/src/zabbix_proxy/datasender/datasender.c index 0e836259..64506048 100644 --- a/src/zabbix_proxy/datasender/datasender.c +++ b/src/zabbix_proxy/datasender/datasender.c @@ -314,9 +314,6 @@ static int history_sender(struct zbx_json *j) zabbix_log(LOG_LEVEL_DEBUG, "In history_sender()"); - if (FAIL == connect_to_server(&sock, 600)) /* alarm !!! */ - return FAIL; - zbx_json_clean(j); zbx_json_addstring(j, ZBX_PROTO_TAG_REQUEST, ZBX_PROTO_VALUE_HISTORY_DATA, ZBX_JSON_TYPE_STRING); zbx_json_addstring(j, ZBX_PROTO_TAG_HOST, CONFIG_HOSTNAME, ZBX_JSON_TYPE_STRING); @@ -336,14 +333,20 @@ static int history_sender(struct zbx_json *j) zbx_json_adduint64(j, ZBX_PROTO_TAG_CLOCK, (int)time(NULL)); - if (SUCCEED == put_data_to_server(&sock, j)) { - DBbegin(); - for (i = 0; i < li_no; i++) - set_lastid(li[i].ht, li[i].lastid); - DBcommit(); - } + if (records) + { + if (FAIL == connect_to_server(&sock, 600)) /* alarm !!! */ + return FAIL; + + if (SUCCEED == put_data_to_server(&sock, j)) { + DBbegin(); + for (i = 0; i < li_no; i++) + set_lastid(li[i].ht, li[i].lastid); + DBcommit(); + } - disconnect_server(&sock); + disconnect_server(&sock); + } return records; } @@ -356,7 +359,7 @@ static int history_sender(struct zbx_json *j) * * * Parameters: * * * - * Return value: * + * Return value: number of records or FAIL if server is not accessible * * * * Author: Aleksander Vladishev * * * @@ -373,9 +376,6 @@ static int dhistory_sender(struct zbx_json *j) zabbix_log(LOG_LEVEL_DEBUG, "In dhistory_sender()"); - if (FAIL == connect_to_server(&sock, 600)) /* alarm !!! */ - return FAIL; - zbx_json_clean(j); zbx_json_addstring(j, ZBX_PROTO_TAG_REQUEST, ZBX_PROTO_VALUE_DISCOVERY_DATA, ZBX_JSON_TYPE_STRING); zbx_json_addstring(j, ZBX_PROTO_TAG_HOST, CONFIG_HOSTNAME, ZBX_JSON_TYPE_STRING); @@ -395,14 +395,20 @@ static int dhistory_sender(struct zbx_json *j) zbx_json_adduint64(j, ZBX_PROTO_TAG_CLOCK, (int)time(NULL)); - if (SUCCEED == put_data_to_server(&sock, j)) { - DBbegin(); - for (i = 0; i < li_no; i++) - set_lastid(li[i].ht, li[i].lastid); - DBcommit(); - } + if (records) + { + if (FAIL == connect_to_server(&sock, 600)) /* alarm !!! */ + return FAIL; - disconnect_server(&sock); + if (SUCCEED == put_data_to_server(&sock, j)) { + DBbegin(); + for (i = 0; i < li_no; i++) + set_lastid(li[i].ht, li[i].lastid); + DBcommit(); + } + + disconnect_server(&sock); + } return records; } @@ -426,7 +432,7 @@ int main_datasender_loop() { struct sigaction phan; int now, sleeptime, - records; + records, r; double sec; struct zbx_json j; @@ -450,8 +456,11 @@ int main_datasender_loop() zbx_setproctitle("data sender [sending data]"); records = 0; - records += history_sender(&j); - records += dhistory_sender(&j); + if (FAIL != (r = history_sender(&j))) + records += r; + + if (FAIL != (r = dhistory_sender(&j))) + records += r; zabbix_log(LOG_LEVEL_DEBUG, "Datasender spent " ZBX_FS_DBL " seconds while processing %3d values.", zbx_time() - sec, |
