diff options
-rwxr-xr-x | go | 2 | ||||
-rw-r--r-- | include/zbxjson.h | 1 | ||||
-rw-r--r-- | src/zabbix_agent/active.c | 23 | ||||
-rw-r--r-- | src/zabbix_server/trapper/trapper.c | 7 | ||||
-rwxr-xr-x | test/env/standalone/create_test.sh | 10 |
5 files changed, 23 insertions, 20 deletions
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash clear rm -f WARNINGS diff --git a/include/zbxjson.h b/include/zbxjson.h index ad821fdf..820b6b1a 100644 --- a/include/zbxjson.h +++ b/include/zbxjson.h @@ -50,6 +50,7 @@ #define ZBX_PROTO_VALUE_DISCOVERY_DATA "discovery data" #define ZBX_PROTO_VALUE_HISTORY_DATA "history data" #define ZBX_PROTO_VALUE_SENDER_DATA "sender data" +#define ZBX_PROTO_VALUE_AGENT_DATA "agent data" typedef enum { diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c index 79f7ef98..a1a1f209 100644 --- a/src/zabbix_agent/active.c +++ b/src/zabbix_agent/active.c @@ -354,21 +354,18 @@ static int refresh_active_checks( static int check_response(char *response) { struct zbx_json_parse jp; - const char *p; char value[MAX_STRING_LEN]; char info[MAX_STRING_LEN]; int ret = SUCCEED; + zabbix_log( LOG_LEVEL_DEBUG, "In check_response(%s)", response); + ret = zbx_json_open(response, &jp); - if(SUCCEED == ret) + if (SUCCEED == ret) { - if (NULL == (p = zbx_json_pair_by_name(&jp, ZBX_PROTO_TAG_RESPONSE)) - || NULL == zbx_json_decodevalue(p, value, sizeof(value))) - { - ret = FAIL; - } + ret = zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_RESPONSE,value, sizeof(value)); } if(SUCCEED == ret) @@ -379,11 +376,13 @@ static int check_response(char *response) } } - if (NULL != (p = zbx_json_pair_by_name(&jp, ZBX_PROTO_TAG_INFO)) - && NULL != zbx_json_decodevalue(p, info, sizeof(info))) + if (SUCCEED == ret) { - zabbix_log(LOG_LEVEL_WARNING, "Info from server: %s", - info); + if(SUCCEED == zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_INFO, info, sizeof(info))) + { + zabbix_log(LOG_LEVEL_WARNING, "Info from server: %s", + info); + } } return ret; @@ -444,7 +443,7 @@ static int send_buffer( zbx_json_init(&json, 8*1024); - zbx_json_addstring(&json, ZBX_PROTO_TAG_REQUEST, ZBX_PROTO_VALUE_SENDER_DATA, ZBX_JSON_TYPE_STRING); + zbx_json_addstring(&json, ZBX_PROTO_TAG_REQUEST, ZBX_PROTO_VALUE_AGENT_DATA, ZBX_JSON_TYPE_STRING); zbx_snprintf(tmp, sizeof(tmp), "%d", (int)time(NULL)); zbx_json_addstring(&json, ZBX_PROTO_TAG_CLOCK, tmp, ZBX_JSON_TYPE_INT); diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c index 06651f0d..d97ea036 100644 --- a/src/zabbix_server/trapper/trapper.c +++ b/src/zabbix_server/trapper/trapper.c @@ -546,7 +546,10 @@ static int process_trap(zbx_sock_t *sock,char *s, int max_len) { send_proxyconfig(sock, &jp); } - else if (0 == strcmp(value, ZBX_PROTO_VALUE_HISTORY_DATA)) + else if (0 == strcmp(value, ZBX_PROTO_VALUE_AGENT_DATA) || + 0 == strcmp(value, ZBX_PROTO_VALUE_SENDER_DATA) || + 0 == strcmp(value, ZBX_PROTO_VALUE_HISTORY_DATA) + ) { ret = process_new_values(sock, &jp); } @@ -560,7 +563,7 @@ static int process_trap(zbx_sock_t *sock,char *s, int max_len) } else { - zabbix_log( LOG_LEVEL_WARNING, "Unknow request received [%s]", + zabbix_log( LOG_LEVEL_WARNING, "Unknown request received [%s]", value); } } diff --git a/test/env/standalone/create_test.sh b/test/env/standalone/create_test.sh index bad94268..941b22a6 100755 --- a/test/env/standalone/create_test.sh +++ b/test/env/standalone/create_test.sh @@ -7,7 +7,7 @@ PROXY_PORT=11000 AGENT_PORT=12000 SERVER_PORT=13000 PROXY_NUM=2 -DEBUG=4 +DEBUG=3 echo Killing all processes killall zabbix_agentd 2>/dev/null @@ -27,14 +27,14 @@ mkdir $DEST/tmp 2>/dev/null echo Making binaries cd ../../.. -#./go +./go cd - cp ../../../sbin/* $DEST/sbin echo Recreating database -#echo "drop database trunk"|mysql -uroot -#echo "create database trunk"|mysql -uroot -#cat data.sql|mysql -uroot trunk +echo "drop database trunk"|mysql -uroot +echo "create database trunk"|mysql -uroot +cat data.sql|mysql -uroot trunk for ((i=1; i <= $PROXY_NUM ; i++)); do echo Processing proxy$i |