diff options
| author | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-02-27 18:02:51 +0000 |
|---|---|---|
| committer | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-02-27 18:02:51 +0000 |
| commit | b35db08802722bc7fda80ae1da96f2e04ce117b9 (patch) | |
| tree | e6d3f835388dfc6addf7c8b0b8fdacf36dab69a9 | |
| parent | 53dd04b8622462ea935972ef843d3c246da1901c (diff) | |
| download | zabbix-b35db08802722bc7fda80ae1da96f2e04ce117b9.tar.gz zabbix-b35db08802722bc7fda80ae1da96f2e04ce117b9.tar.xz zabbix-b35db08802722bc7fda80ae1da96f2e04ce117b9.zip | |
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@3847 97f52cf1-0a1b-0410-bd0e-c28be96e8082
| -rw-r--r-- | src/zabbix_server/nodewatcher/nodecomms.c | 54 | ||||
| -rw-r--r-- | src/zabbix_server/trapper/trapper.c | 6 |
2 files changed, 50 insertions, 10 deletions
diff --git a/src/zabbix_server/nodewatcher/nodecomms.c b/src/zabbix_server/nodewatcher/nodecomms.c index e8d8e31f..59908925 100644 --- a/src/zabbix_server/nodewatcher/nodecomms.c +++ b/src/zabbix_server/nodewatcher/nodecomms.c @@ -50,6 +50,7 @@ #include "zlog.h" #include "zbxsock.h" +#include "comms.h" #include "nodecomms.h" /****************************************************************************** @@ -71,7 +72,7 @@ int send_to_node(int dest_nodeid, int nodeid, char *data) { int i,s; - char answer[MAX_STRING_LEN]; +/* char answer[MAX_STRING_LEN];*/ struct hostent *hp; struct sockaddr_in myaddr_in; @@ -87,6 +88,9 @@ int send_to_node(int dest_nodeid, int nodeid, char *data) DB_RESULT result; DB_ROW row; + zbx_sock_t sock; + char *answer; + zabbix_log( LOG_LEVEL_WARNING, "NODE %d: Sending data of node %d to node %d datalen %d", CONFIG_NODEID, nodeid, dest_nodeid, strlen(data)); /* zabbix_log( LOG_LEVEL_WARNING, "Data [%s]", data);*/ @@ -102,7 +106,44 @@ int send_to_node(int dest_nodeid, int nodeid, char *data) port=atoi(row[1]); DBfree_result(result); - servaddr_in.sin_family=AF_INET; + if( FAIL == zbx_tcp_connect(&sock, ip, port)) + { + zabbix_log( LOG_LEVEL_WARNING, "Unable to connect to Node [%d]", dest_nodeid); + return FAIL; + } + + + if( FAIL == zbx_tcp_send(&sock, data)) + { + zabbix_log( LOG_LEVEL_WARNING, "Error while sending data to Node [%d]", dest_nodeid); + zbx_tcp_close(&sock); + return FAIL; + } + + if( FAIL == zbx_tcp_recv(&sock, &answer)) + { + zabbix_log( LOG_LEVEL_WARNING, "Error while receiving answer from Node [%d]", dest_nodeid); + zbx_tcp_close(&sock); + return FAIL; + } + + zabbix_log( LOG_LEVEL_WARNING, "Answer [%s]", answer); + + if(strcmp(answer,"OK") == 0) + { + zabbix_log( LOG_LEVEL_WARNING, "OK"); + ret = SUCCEED; + } + else + { + zabbix_log( LOG_LEVEL_WARNING, "NOT OK"); + } + + zbx_tcp_close(&sock); + + + +/* servaddr_in.sin_family=AF_INET; if(NULL == (hp = zbx_gethost(ip))) { @@ -134,7 +175,6 @@ int send_to_node(int dest_nodeid, int nodeid, char *data) written = 0; - /* Write header */ i=write(s, header, 5); if(i == -1) { @@ -144,7 +184,6 @@ int send_to_node(int dest_nodeid, int nodeid, char *data) } len64 = (zbx_uint64_t)strlen(data); - /* Write data length */ i=write(s, &len64, sizeof(len64)); if(i == -1) { @@ -175,19 +214,20 @@ int send_to_node(int dest_nodeid, int nodeid, char *data) answer[i-1]=0; + zabbix_log( LOG_LEVEL_WARNING, "Read [%s]", answer); if(strcmp(answer,"OK") == 0) { - zabbix_log( LOG_LEVEL_DEBUG, "OK"); + zabbix_log( LOG_LEVEL_WARNING, "OK"); ret = SUCCEED; } else { - zabbix_log( LOG_LEVEL_DEBUG, "NOT OK"); + zabbix_log( LOG_LEVEL_WARNING, "NOT OK"); } if( close(s)!=0 ) { - } + }*/ return ret; } diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c index 3470886d..e0ba0bd4 100644 --- a/src/zabbix_server/trapper/trapper.c +++ b/src/zabbix_server/trapper/trapper.c @@ -109,7 +109,7 @@ int process_trap(zbx_sock_t *sock,char *s, int max_len) /* zabbix_log( LOG_LEVEL_WARNING, "Node data received [len:%d]", strlen(s)); */ if(node_sync(s) == SUCCEED) { - zbx_snprintf(result,sizeof(result),"OK\n"); + zbx_snprintf(result,sizeof(result),"OK"); if( zbx_tcp_send(sock,result) != SUCCEED) /* if( write(sockfd,result,strlen(result)) == -1) */ { @@ -125,7 +125,7 @@ int process_trap(zbx_sock_t *sock,char *s, int max_len) /* zabbix_log( LOG_LEVEL_WARNING, "Slave node events received [len:%d]", strlen(s)); */ if(node_events(s) == SUCCEED) { - zbx_snprintf(result,sizeof(result),"OK\n"); + zbx_snprintf(result,sizeof(result),"OK"); /* if( write(sockfd,result,strlen(result)) == -1) */ if( zbx_tcp_send(sock,result) != SUCCEED) { @@ -141,7 +141,7 @@ int process_trap(zbx_sock_t *sock,char *s, int max_len) /* zabbix_log( LOG_LEVEL_WARNING, "Slave node history received [len:%d]", strlen(s)); */ if(node_history(s) == SUCCEED) { - zbx_snprintf(result,sizeof(result),"OK\n"); + zbx_snprintf(result,sizeof(result),"OK"); /* if( write(sockfd,result,strlen(result)) == -1) */ if( zbx_tcp_send(sock,result) != SUCCEED) { |
