summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-25 19:15:55 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-25 19:15:55 +0000
commit97d3cefc8e7bb3c5cd3c5c90b725ff2cdd15bf44 (patch)
treeaaf5424a1520500190e55091d5df2f03dff5e744
parent1bb0fd47706fa5b634807fe870358891decef421 (diff)
- [DEV-110] Proxy
git-svn-id: svn://svn.zabbix.com/trunk@5398 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--src/zabbix_proxy/datasender/datasender.c8
-rw-r--r--src/zabbix_proxy/datasender/datasender.h2
-rw-r--r--src/zabbix_proxy/housekeeper/housekeeper.c216
-rw-r--r--src/zabbix_proxy/housekeeper/housekeeper.h3
-rw-r--r--src/zabbix_proxy/proxy.c20
-rw-r--r--src/zabbix_proxy/proxyconfig/proxyconfig.c18
-rw-r--r--src/zabbix_proxy/proxyconfig/proxyconfig.h2
-rw-r--r--src/zabbix_proxy/servercomms.c21
8 files changed, 150 insertions, 140 deletions
diff --git a/src/zabbix_proxy/datasender/datasender.c b/src/zabbix_proxy/datasender/datasender.c
index da87c6c6..bcb3c1c5 100644
--- a/src/zabbix_proxy/datasender/datasender.c
+++ b/src/zabbix_proxy/datasender/datasender.c
@@ -27,8 +27,6 @@
#include "datasender.h"
#include "../servercomms.h"
-#define CONFIG_DATASENDER_FREQUENCY 3
-
#define ZBX_HISTORY_FIELD struct history_field_t
#define ZBX_HISTORY_TABLE struct history_table_t
@@ -256,13 +254,13 @@ static int main_datasender()
{
struct zbx_json j;
int t, records = 0/*, minclock, lastclock*/;
- double sec;
+/* double sec;*/
zbx_sock_t sock;
char *answer, buf[11]; /* strlen("4294967296") + 1 */
zabbix_log(LOG_LEVEL_DEBUG, "In main_datasender()");
- sec = zbx_time();
+/* sec = zbx_time();*/
if (FAIL == connect_to_server(&sock, 60)) /* alarm */
return FAIL;
@@ -288,7 +286,7 @@ static int main_datasender()
} else
DBrollback();
- zabbix_log(LOG_LEVEL_DEBUG, "----- [%d] [%d] [seconds:%f]", records, j.buffer_size, zbx_time() - sec);
+/* zabbix_log(LOG_LEVEL_DEBUG, "----- [%d] [%d] [seconds:%f]", records, j.buffer_size, zbx_time() - sec);*/
zbx_json_free(&j);
diff --git a/src/zabbix_proxy/datasender/datasender.h b/src/zabbix_proxy/datasender/datasender.h
index 89bbcd38..02630335 100644
--- a/src/zabbix_proxy/datasender/datasender.h
+++ b/src/zabbix_proxy/datasender/datasender.h
@@ -20,6 +20,8 @@
#ifndef ZABBIX_DATASENDER_H
#define ZABBIX_DATASENDER_H
+extern int CONFIG_DATASENDER_FREQUENCY;
+
int main_datasender_loop();
#endif
diff --git a/src/zabbix_proxy/housekeeper/housekeeper.c b/src/zabbix_proxy/housekeeper/housekeeper.c
index 048ac76e..3e0c66ec 100644
--- a/src/zabbix_proxy/housekeeper/housekeeper.c
+++ b/src/zabbix_proxy/housekeeper/housekeeper.c
@@ -40,6 +40,7 @@
* Comments: *
* *
******************************************************************************/
+/*
static int housekeeping_process_log()
{
DB_HOUSEKEEPER housekeeper;
@@ -48,11 +49,11 @@ static int housekeeping_process_log()
DB_ROW row;
int res = SUCCEED;
- long deleted;
+ long records;
zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_process_log()");
- /* order by tablename to effectively use DB cache */
+*/ /* order by tablename to effectively use DB cache *//*
result = DBselect("select housekeeperid, tablename, field, value from housekeeper order by tablename");
while((row=DBfetch(result)))
@@ -63,23 +64,23 @@ static int housekeeping_process_log()
ZBX_STR2UINT64(housekeeper.value,row[3]);
#ifdef HAVE_ORACLE
- deleted = DBexecute("delete from %s where %s=" ZBX_FS_UI64 " and rownum<500",
+ records = DBexecute("delete from %s where %s=" ZBX_FS_UI64 " and rownum<500",
housekeeper.tablename,
housekeeper.field,
housekeeper.value);
#elif defined(HAVE_POSTGRESQL)
- deleted = DBexecute("delete from %s where oid in (select oid from %s where %s=" ZBX_FS_UI64 " limit 500)",
+ records = DBexecute("delete from %s where oid in (select oid from %s where %s=" ZBX_FS_UI64 " limit 500)",
housekeeper.tablename,
housekeeper.tablename,
housekeeper.field,
housekeeper.value);
#else
- deleted = DBexecute("delete from %s where %s=" ZBX_FS_UI64 " limit 500",
+ records = DBexecute("delete from %s where %s=" ZBX_FS_UI64 " limit 500",
housekeeper.tablename,
housekeeper.field,
housekeeper.value);
#endif
- if(deleted == 0)
+ if(records == 0)
{
DBexecute("delete from housekeeper where housekeeperid=" ZBX_FS_UI64,
housekeeper.housekeeperid);
@@ -87,7 +88,7 @@ static int housekeeping_process_log()
else
{
zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [%s]",
- deleted,
+ records,
housekeeper.tablename);
}
}
@@ -99,16 +100,16 @@ static int housekeeping_process_log()
static int housekeeping_sessions(int now)
{
- int deleted;
+ int records;
zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_sessions(%d)",
now);
- deleted = DBexecute("delete from sessions where lastaccess<%d",
+ records = DBexecute("delete from sessions where lastaccess<%d",
now-24*3600);
zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [sessions]",
- deleted);
+ records);
return SUCCEED;
}
@@ -119,7 +120,7 @@ static int housekeeping_alerts(int now)
DB_RESULT result;
DB_ROW row;
int res = SUCCEED;
- int deleted;
+ int records;
zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_alerts(%d)",
now);
@@ -137,10 +138,10 @@ static int housekeeping_alerts(int now)
{
alert_history=atoi(row[0]);
- deleted = DBexecute("delete from alerts where clock<%d",
+ records = DBexecute("delete from alerts where clock<%d",
now-24*3600*alert_history);
zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alerts]",
- deleted);
+ records);
}
DBfree_result(result);
@@ -192,7 +193,7 @@ static int housekeeping_events(int now)
DBfree_result(result);
return res;
}
-
+*/
/******************************************************************************
* *
* Function: delete_history *
@@ -201,57 +202,78 @@ static int housekeeping_events(int now)
* *
* Parameters: now - current timestamp *
* *
- * Return value: number of rows deleted *
+ * Return value: number of rows records *
* *
* Author: Alexei Vladishev *
* *
* Comments: *
* *
******************************************************************************/
-static int delete_history(char *table, zbx_uint64_t itemid, int keep_history, int now)
+static int delete_history(const char *table, const char *fieldname, int now)
{
DB_RESULT result;
DB_ROW row;
- int min_clock;
+ int minclock, records = 0;
+ zbx_uint64_t lastid;
+/* double sec;*/
- zabbix_log( LOG_LEVEL_DEBUG, "In delete_history(%s," ZBX_FS_UI64 "," ZBX_FS_UI64 ",%d)",
- table,
- itemid,
- keep_history,
- now);
+ zabbix_log(LOG_LEVEL_DEBUG, "In delete_history() [table:%s] [now:%d]",
+ table,
+ now);
- result = DBselect("select min(clock) from %s where itemid=" ZBX_FS_UI64,
- table,
- itemid);
+/* sec = zbx_time();*/
- row=DBfetch(result);
+ DBbegin();
- if(!row || DBis_null(row[0]) == SUCCEED)
- {
- DBfree_result(result);
- return 0;
- }
+ result = DBselect("select %s from proxies",
+ fieldname);
+
+ if (NULL == (row = DBfetch(result)) || DBis_null(row[0]) == SUCCEED)
+ goto rollback;
+
+ lastid = zbx_atoui64(row[0]);
+ DBfree_result(result);
- min_clock = atoi(row[0]);
+ result = DBselect("select min(clock) from %s",
+ table);
+
+ if (NULL == (row = DBfetch(result)) || DBis_null(row[0]) == SUCCEED)
+ goto rollback;
+
+ minclock = atoi(row[0]);
+ DBfree_result(result);
+
+ records = DBexecute("delete from %s where clock<%d or (id<" ZBX_FS_UI64 " and clock<%d)",
+ table,
+ now - CONFIG_PROXY_OFFLINE_BUFFER * 3600,
+ lastid,
+ MIN(now - CONFIG_PROXY_LOCAL_BUFFER * 3600, minclock + 4 * CONFIG_HOUSEKEEPING_FREQUENCY * 3600));
+
+/* zabbix_log(LOG_LEVEL_DEBUG, "----- [table:%s] [now:%d] [lastid:" ZBX_FS_UI64 "] [minclock:%d] [offline:%d] [24h:%d] [maxdeleted:%d] [%d] [seconds:%f]",
+ table,
+ now,
+ lastid,
+ minclock,
+ now - CONFIG_PROXY_OFFLINE_BUFFER * 3600,
+ now - CONFIG_PROXY_LOCAL_BUFFER * 3600,
+ minclock + 4 * CONFIG_HOUSEKEEPING_FREQUENCY * 3600,
+ records,
+ zbx_time() - sec);*/
+
+ DBcommit();
+
+ return records;
+rollback:
DBfree_result(result);
-/* zabbix_log( LOG_LEVEL_DEBUG, "Now %d keep_history %d Itemid " ZBX_FS_UI64 " min %d new min %d",
- now,
- keep_history,
- itemid,
- min_clock,
- MIN(now-24*3600*keep_history, min_clock+4*3600*CONFIG_HOUSEKEEPING_FREQUENCY));*/
-
- return DBexecute("delete from %s where itemid=" ZBX_FS_UI64 " and clock<%d",
- table,
- itemid,
- MIN(now-24*3600*keep_history, min_clock+4*3600*CONFIG_HOUSEKEEPING_FREQUENCY)
- );
+ DBrollback();
+
+ return 0;
}
/******************************************************************************
* *
- * Function: housekeeping_history_and_trends *
+ * Function: housekeeping_history *
* *
* Purpose: remove outdated information from history and trends *
* *
@@ -265,94 +287,64 @@ static int delete_history(char *table, zbx_uint64_t itemid, int keep_history, in
* Comments: *
* *
******************************************************************************/
-static int housekeeping_history_and_trends(int now)
+static int housekeeping_history(int now)
{
- DB_ITEM item;
-
- DB_RESULT result;
- DB_ROW row;
+ int records = 0;
- int deleted = 0;
+ zabbix_log(LOG_LEVEL_DEBUG, "In housekeeping_history()");
- zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_history_and_trends(%d)",
- now);
+ 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);
- result = DBselect("select itemid,history,trends from items");
-
- while((row=DBfetch(result)))
- {
- ZBX_STR2UINT64(item.itemid,row[0]);
- item.history=atoi(row[1]);
- item.trends=atoi(row[2]);
-
- deleted += delete_history("history", item.itemid, item.history, now);
- deleted += delete_history("history_uint", item.itemid, item.history, now);
- deleted += delete_history("history_str", item.itemid, item.history, now);
- deleted += delete_history("history_text", item.itemid, item.history, now);
- deleted += delete_history("history_log", item.itemid, item.history, now);
- deleted += delete_history("trends", item.itemid, item.trends, now);
- }
- DBfree_result(result);
- return deleted;
+ return records;
}
int main_housekeeper_loop()
{
- int now;
- int d;
+ int records;
+ int start, sleeptime;
- if(CONFIG_DISABLE_HOUSEKEEPING == 1)
- {
- for(;;)
- {
-/* Do nothing */
- zbx_setproctitle("do nothing");
+ if (CONFIG_DISABLE_HOUSEKEEPING == 1) {
+ zbx_setproctitle("housekeeper [disabled]");
+ for(;;) /* Do nothing */
sleep(3600);
- }
}
- for(;;)
- {
- zabbix_log( LOG_LEVEL_WARNING, "Executing housekeeper");
- now = time(NULL);
-
- zbx_setproctitle("connecting to the database");
-
- DBconnect(ZBX_DB_CONNECT_NORMAL);
-
-/* Transaction is not required here. It causes timeouts under MySQL */
-/* DBbegin();*/
+ for (;;) {
+ start = time(NULL);
-/* zbx_setproctitle("housekeeper [removing deleted hosts]");*/
+ zabbix_log(LOG_LEVEL_WARNING, "Executing housekeeper");
-/* housekeeping_hosts();*/
+ zbx_setproctitle("housekeeper [connecting to the database]");
-/* zbx_setproctitle("housekeeper [removing deleted items]");*/
+ DBconnect(ZBX_DB_CONNECT_NORMAL);
-/* housekeeping_items();*/
+ zbx_setproctitle("housekeeper [removing old history]");
-/* zbx_setproctitle("housekeeper [removing old history]");*/
+ records = housekeeping_history(start);
- d = housekeeping_history_and_trends(now);
- zabbix_log( LOG_LEVEL_WARNING, "Deleted %d records from history and trends",
- d);
+ zabbix_log(LOG_LEVEL_WARNING, "Deleted %d records from history",
+ records);
- zbx_setproctitle("housekeeper [removing old history]");
+/* zbx_setproctitle("housekeeper [removing old history]");
- housekeeping_process_log(now);
+ housekeeping_process_log(start);
zbx_setproctitle("housekeeper [removing old events]");
- housekeeping_events(now);
+ housekeeping_events(start);
zbx_setproctitle("housekeeper [removing old alerts]");
- housekeeping_alerts(now);
+ housekeeping_alerts(start);
zbx_setproctitle("housekeeper [removing old sessions]");
- housekeeping_sessions(now);
+ housekeeping_sessions(start);*/
zbx_setproctitle("housekeeper [vacuuming database]");
@@ -360,16 +352,16 @@ int main_housekeeper_loop()
/* DBcommit();*/
DBvacuum();
+ DBclose();
- zabbix_log( LOG_LEVEL_DEBUG, "Sleeping for %d hours",
- CONFIG_HOUSEKEEPING_FREQUENCY);
-
- zbx_setproctitle("housekeeper [sleeping for %d hour(s)]",
- CONFIG_HOUSEKEEPING_FREQUENCY);
+ sleeptime = CONFIG_HOUSEKEEPING_FREQUENCY * 3600 - (time(NULL) - start);
- DBclose();
- zabbix_log( LOG_LEVEL_DEBUG, "Next housekeeper run is after %dh",
- CONFIG_HOUSEKEEPING_FREQUENCY);
- sleep(3660*CONFIG_HOUSEKEEPING_FREQUENCY);
+ if (sleeptime > 0) {
+ zbx_setproctitle("housekeeper [sleeping for %d seconds]",
+ sleeptime);
+ zabbix_log(LOG_LEVEL_DEBUG, "Sleeping for %d seconds",
+ sleeptime);
+ sleep(sleeptime);
+ }
}
}
diff --git a/src/zabbix_proxy/housekeeper/housekeeper.h b/src/zabbix_proxy/housekeeper/housekeeper.h
index ecb9bb52..e074d0e5 100644
--- a/src/zabbix_proxy/housekeeper/housekeeper.h
+++ b/src/zabbix_proxy/housekeeper/housekeeper.h
@@ -22,7 +22,8 @@
extern int CONFIG_DISABLE_HOUSEKEEPING;
extern int CONFIG_HOUSEKEEPING_FREQUENCY;
-extern char *CONFIG_FPING_LOCATION;
+extern int CONFIG_PROXY_LOCAL_BUFFER;
+extern int CONFIG_PROXY_OFFLINE_BUFFER;
int main_housekeeper_loop();
diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c
index f9570108..ec187c10 100644
--- a/src/zabbix_proxy/proxy.c
+++ b/src/zabbix_proxy/proxy.c
@@ -125,13 +125,19 @@ int CONFIG_LISTEN_PORT = 10051;
char *CONFIG_LISTEN_IP = NULL;
int CONFIG_TRAPPER_TIMEOUT = TRAPPER_TIMEOUT;
/**/
-/*int CONFIG_NOTIMEWAIT =0;*/
-int CONFIG_HOUSEKEEPING_FREQUENCY = 1;
+/*int CONFIG_NOTIMEWAIT = 0;*/
+int CONFIG_DISABLE_HOUSEKEEPING = 0;
+int CONFIG_HOUSEKEEPING_FREQUENCY = 1; /* h */
+int CONFIG_PROXY_LOCAL_BUFFER = 24; /* 24h */
+int CONFIG_PROXY_OFFLINE_BUFFER = 720; /* 720h */
+
+int CONFIG_PROXYCONFIG_FREQUENCY = 60;
+
+int CONFIG_DATASENDER_FREQUENCY = 3;
+
int CONFIG_SENDER_FREQUENCY = 30;
int CONFIG_DBSYNCER_FREQUENCY = 5;
int CONFIG_PINGER_FREQUENCY = 60;
-/*int CONFIG_DISABLE_PINGER = 0;*/
-int CONFIG_DISABLE_HOUSEKEEPING = 0;
int CONFIG_UNREACHABLE_PERIOD = 45;
int CONFIG_UNREACHABLE_DELAY = 15;
int CONFIG_UNAVAILABLE_DELAY = 60;
@@ -199,7 +205,12 @@ void init_config(void)
{"StartPollers",&CONFIG_POLLER_FORKS,0,TYPE_INT,PARM_OPT,0,255},
{"StartPollersUnreachable",&CONFIG_UNREACHABLE_POLLER_FORKS,0,TYPE_INT,PARM_OPT,0,255},
{"StartTrappers",&CONFIG_TRAPPERD_FORKS,0,TYPE_INT,PARM_OPT,0,255},
+
+ {"DisableHousekeeping",&CONFIG_DISABLE_HOUSEKEEPING,0,TYPE_INT,PARM_OPT,0,1},
{"HousekeepingFrequency",&CONFIG_HOUSEKEEPING_FREQUENCY,0,TYPE_INT,PARM_OPT,1,24},
+ {"ProxyLocalBuffer",&CONFIG_PROXY_LOCAL_BUFFER,0,TYPE_INT,PARM_OPT,1,720},
+ {"ProxyOfflineBuffer",&CONFIG_PROXY_OFFLINE_BUFFER,0,TYPE_INT,PARM_OPT,1,720},
+
{"SenderFrequency",&CONFIG_SENDER_FREQUENCY,0,TYPE_INT,PARM_OPT,5,3600},
{"PingerFrequency",&CONFIG_PINGER_FREQUENCY,0,TYPE_INT,PARM_OPT,1,3600},
{"FpingLocation",&CONFIG_FPING_LOCATION,0,TYPE_STRING,PARM_OPT,0,0},
@@ -215,7 +226,6 @@ void init_config(void)
{"ListenPort",&CONFIG_LISTEN_PORT,0,TYPE_INT,PARM_OPT,1024,32768},
/* {"NoTimeWait",&CONFIG_NOTIMEWAIT,0,TYPE_INT,PARM_OPT,0,1},*/
/* {"DisablePinger",&CONFIG_DISABLE_PINGER,0,TYPE_INT,PARM_OPT,0,1},*/
- {"DisableHousekeeping",&CONFIG_DISABLE_HOUSEKEEPING,0,TYPE_INT,PARM_OPT,0,1},
{"DebugLevel",&CONFIG_LOG_LEVEL,0,TYPE_INT,PARM_OPT,0,4},
{"PidFile",&APP_PID_FILE,0,TYPE_STRING,PARM_OPT,0,0},
{"LogFile",&CONFIG_LOG_FILE,0,TYPE_STRING,PARM_OPT,0,0},
diff --git a/src/zabbix_proxy/proxyconfig/proxyconfig.c b/src/zabbix_proxy/proxyconfig/proxyconfig.c
index 24bdd054..ff2acd8b 100644
--- a/src/zabbix_proxy/proxyconfig/proxyconfig.c
+++ b/src/zabbix_proxy/proxyconfig/proxyconfig.c
@@ -20,6 +20,7 @@
#include "common.h"
#include "db.h"
#include "log.h"
+#include "daemon.h"
#include "zbxjson.h"
#include "proxyconfig.h"
@@ -131,7 +132,8 @@ static int process_proxyconfig_table(struct zbx_json_parse *jp, const char *tabl
*/ if (FAIL == zbx_json_brackets_open(p, &jp_row))
goto json_error;
- if (NULL == (pf = zbx_json_next(&jp_row, NULL)) || NULL == (pf = zbx_json_decodevalue(pf, recid, sizeof(recid))) )
+ pf = NULL;
+ if (NULL == (pf = zbx_json_next_value(&jp_row, pf, recid, sizeof(recid))))
goto json_error;
result = DBselect("select 0 from %s where %s=%s",
@@ -159,10 +161,7 @@ static int process_proxyconfig_table(struct zbx_json_parse *jp, const char *tabl
/* {"hosts":{"fields":["hostid","host",...],"data":[[1,"zbx01",...],[2,"zbx02",...],...]},"items":{...},...}
* ^
*/ f = 1;
- while (NULL != (pf = zbx_json_next(&jp_row, pf))) {
- if (NULL == (pf = zbx_json_decodevalue(pf, buf, sizeof(buf))))
- goto json_error;
-
+ while (NULL != (pf = zbx_json_next_value(&jp_row, pf, buf, sizeof(buf)))) {
execute = 1;
if (f == field_count) {
@@ -337,11 +336,16 @@ exit:
******************************************************************************/
void main_proxyconfig_loop()
{
-#define CONFIG_PROXYCONFIG_FREQUENCY 10
+ struct sigaction phan;
int start, sleeptime;
zabbix_log(LOG_LEVEL_DEBUG, "In main_proxyconfig_loop()");
+ phan.sa_handler = child_signal_handler;
+ sigemptyset(&phan.sa_mask);
+ phan.sa_flags = 0;
+ sigaction(SIGALRM, &phan, NULL);
+
for (;;) {
start = time(NULL);
@@ -360,7 +364,7 @@ void main_proxyconfig_loop()
if (sleeptime > 0) {
zbx_setproctitle("configuration syncer [sleeping for %d seconds]",
sleeptime);
- zabbix_log (LOG_LEVEL_DEBUG, "Sleeping %d seconds",
+ zabbix_log(LOG_LEVEL_DEBUG, "Sleeping for %d seconds",
sleeptime);
sleep(sleeptime);
}
diff --git a/src/zabbix_proxy/proxyconfig/proxyconfig.h b/src/zabbix_proxy/proxyconfig/proxyconfig.h
index 15ab3fd8..beeab05f 100644
--- a/src/zabbix_proxy/proxyconfig/proxyconfig.h
+++ b/src/zabbix_proxy/proxyconfig/proxyconfig.h
@@ -20,6 +20,8 @@
#ifndef ZABBIX_PROXYCONFIG_H
#define ZABBIX_PROXYCONFIG_H
+extern int CONFIG_PROXYCONFIG_FREQUENCY;
+
void main_proxyconfig_loop();
#endif
diff --git a/src/zabbix_proxy/servercomms.c b/src/zabbix_proxy/servercomms.c
index eb3ecd86..2adee6fa 100644
--- a/src/zabbix_proxy/servercomms.c
+++ b/src/zabbix_proxy/servercomms.c
@@ -31,15 +31,16 @@ int connect_to_server(zbx_sock_t *sock, int timeout)
{
int res;
- zabbix_log(LOG_LEVEL_DEBUG, "In connect_to_server() [%s]:%d",
- CONFIG_SERVER,
- CONFIG_SERVER_PORT);
+ zabbix_log(LOG_LEVEL_DEBUG, "In connect_to_server() [%s]:%d [timeout:%d]",
+ CONFIG_SERVER,
+ CONFIG_SERVER_PORT,
+ timeout);
if (FAIL == (res = zbx_tcp_connect(sock, CONFIG_SERVER, CONFIG_SERVER_PORT, timeout)))
zabbix_log(LOG_LEVEL_ERR, "Unable connect to the server [%s]:%d [%s]",
- CONFIG_SERVER,
- CONFIG_SERVER_PORT,
- zbx_tcp_strerror());
+ CONFIG_SERVER,
+ CONFIG_SERVER_PORT,
+ zbx_tcp_strerror());
return res;
}
@@ -49,11 +50,11 @@ static int send_data_to_server(zbx_sock_t *sock, const char *data)
int res;
zabbix_log(LOG_LEVEL_DEBUG, "In send_data_to_server() [%s]",
- data);
+ data);
if (FAIL == (res = zbx_tcp_send(sock, data)))
zabbix_log(LOG_LEVEL_ERR, "Error while sending data to the server [%s]",
- zbx_tcp_strerror());
+ zbx_tcp_strerror());
return res;
}
@@ -65,10 +66,10 @@ static int recv_data_from_server(zbx_sock_t *sock, char **data)
zabbix_log(LOG_LEVEL_DEBUG, "In recv_data_from_server()");
if (FAIL == (res = zbx_tcp_recv_ext(sock, data, 0)))
zabbix_log(LOG_LEVEL_ERR, "Error while receiving answer from server [%s]",
- zbx_tcp_strerror());
+ zbx_tcp_strerror());
else
zabbix_log(LOG_LEVEL_DEBUG, "Received [%s] from server",
- *data);
+ *data);
return res;
}