Ad Widget

Collapse

Zabbix server restarted [file:json.c,line:101] zbx_realloc: out of memory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sunrise0318
    Junior Member
    • Feb 2017
    • 24

    #1

    Zabbix server restarted [file:json.c,line:101] zbx_realloc: out of memory

    Hello,

    i have a problem with my zabbix server. It restarts in random moments with this error: [file:json.c,line:101] zbx_realloc: out of memory. Requested 134217728 bytes. <- No other information in log.


    My zabbix server:
    Version 6.0.20
    Ram: 512 GB
    CPU: 44 Core
    VMwareCacheSize=128M
    CacheSize=8G
    CacheUpdateFrequency=60
    HistoryCacheSize=2G
    HistoryIndexCacheSize=2G
    TrendCacheSize=2G
    ValueCacheSize=32G
    No direct connect monitored hosts, every server connet to proxy.

    Lately, I have written a lot of javascript programs in Zabbix, the return value of which is specific to Zabbix (IBM MQ RestApi, Weblogic RestApi etc etc...)

    Database run on an other server (PGSQL+ TSDB)

    Please help me where should i search for the problem.
    Last edited by Sunrise0318; 22-08-2023, 21:57.
  • Sunrise0318
    Junior Member
    • Feb 2017
    • 24

    #2
    Hello i have a problem with internal javascript.
    When my item (type: script) with a javascript gets a timeout all item calculated from this and dependent on this item gives an error. Item is not supported. I know this is a common thing, in zabbix server log file there is a lot of line when an item gets unsupported or supported.
    I think the main problem is when all of my items turns into unsupported (around 5000 item on a host, and I got multiple hosts with this type of check) the amount of data overflow the buffer.
    This will restart the zabbix server without any warning. Then only usable information in the log file is this : [file:json.c,line:101] zbx_realloc: out of memory. Requested 134217728 bytes.

    The line from the zabbix source: j->buffer = (char *)zbx_realloc(j->buffer, j->buffer_allocated);
    /************************************************** ****************************
    * *
    * Purpose: return string describing json error *
    * *
    * Return value: pointer to the null terminated string *
    * *
    ************************************************** ****************************/

    if (1 == realloc)
    {
    if (j->buffer == j->buf_stat)
    {
    j->buffer = NULL;
    j->buffer = (char *)zbx_malloc(j->buffer, j->buffer_allocated);
    memcpy(j->buffer, j->buf_stat, sizeof(j->buf_stat));
    }
    else
    j->buffer = (char *)zbx_realloc(j->buffer, j->buffer_allocated);
    }
    }

    Included in common.h:
    #define MAX_ID_LEN 21
    #define MAX_STRING_LEN 2048
    #define MAX_BUFFER_LEN 65536
    #define MAX_ZBX_HOSTNAME_LEN 128
    #define MAX_ZBX_DNSNAME_LEN 255 /* maximum host DNS name length from RFC 1035 (without terminating '\0') */
    #define MAX_EXECUTE_OUTPUT_LEN (512 * ZBX_KIBIBYTE)

    #define ZBX_MAX_UINT64 (~__UINT64_C(0))
    #define ZBX_MAX_UINT64_LEN 21
    #define ZBX_MAX_DOUBLE_LEN 24

    In my case the zabbix wants 13 MB buffer instead of 0.065536 Mb (#define MAX_BUFFER_LEN 65536) and i think its overflow the buffer.
    I think its because of the size of the text message "Item unsupported".

    I am rewriting the JavaScript code, it contains the calculation item (java script preprocessing) and I set the "Custom on fail: Discard value" switch for the preprocessing.

    I think it will fix this error.​

    I think this is a mistake that is a mistake, but not a mistake.

    Comment

    Working...