summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/zabbix_get/zabbix_get.c18
2 files changed, 12 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ab642143..d405ae39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ Changes for 1.5:
Changes for 1.4.2:
+ - improved zabbix_get for receiving large data (Eugene)
- fixed shared memory allocation (Eugene)
- added server-side transactions for PostgreSQL (Alexei)
- fixed housekeeper to run as multiple transations (Alexei)
diff --git a/src/zabbix_get/zabbix_get.c b/src/zabbix_get/zabbix_get.c
index 4cc33cc9..08f50f2f 100644
--- a/src/zabbix_get/zabbix_get.c
+++ b/src/zabbix_get/zabbix_get.c
@@ -132,16 +132,18 @@ static int get_value(
const char *host,
unsigned short port,
const char *key,
- char *value,
- int value_max_len
+ char **value
)
{
zbx_sock_t s;
int ret;
- char
- *buf,
+ char *buf,
request[1024];
+ assert(value);
+
+ *value = NULL;
+
if( SUCCEED == (ret = zbx_tcp_connect(&s, host, port)) )
{
zbx_snprintf(request, sizeof(request),"%s\n",key);
@@ -150,7 +152,7 @@ static int get_value(
if( SUCCEED == (ret = zbx_tcp_recv_ext(&s, &buf, ZBX_TCP_READ_UNTIL_CLOSE)) )
{
zbx_rtrim(buf,"\r\n\0");
- zbx_snprintf(value, value_max_len, "%s", buf);
+ *value = strdup(buf);
}
}
}
@@ -178,7 +180,7 @@ int main(int argc, char **argv)
{
unsigned short port = 10050;
int ret = SUCCEED;
- char value[MAX_STRING_LEN];
+ char *value = NULL;
char *host = NULL;
char *key = NULL;
char ch;
@@ -229,7 +231,7 @@ int main(int argc, char **argv)
alarm(SENDER_TIMEOUT);
#endif /* not WINDOWS */
- ret = get_value(host, port, key, value, sizeof(value));
+ ret = get_value(host, port, key, &value);
#if !defined(_WINDOWS)
alarm(0);
@@ -239,6 +241,8 @@ int main(int argc, char **argv)
{
printf("%s\n",value);
}
+
+ zbx_free(value);
}
zbx_free(host);