See www.zabbix.com for the official Zabbix site.

Docs/specs/ZBX-10102

From Zabbix.org
Jump to: navigation, search

Meta information update is not correctly handled for log items with value type non-log

ZBX-10102

Status: v1.0

Owner: Vladimir Levijev

Summary

Currently meta information update is supported for log items with value type log. Since ZBX-7821 was implemented server/proxy must support meta information update of log items with any value type.

Specification

In addition to basic monitoring data (clock, ns, value) log file monitoring data has 6 additional fields: (timestamp, source, severity, logeventid, lastlogsize, mtime). These 6 fields in turn can be divided into basic information (timestamp, source, severity, logeventid) and meta information (lastlogsize, mtime). The idea of this task is to separate log file meta information from general log data and allow it with any type of items.

This requires the following changes in monitoring data unit. Disregarding NOTSUPPORTED results:

Currently:

  • log item:
    • monitoring data unit may or may not contain the value
    • monitoring data unit always contains log meta data
  • other item:
    • monitoring data unit always contains the value
    • monitoring data unit never contains log meta data

Proposed new design:

  • monitoring data unit may or may not contain the value
  • monitoring data unit may or may not contain log meta data
  • monitoring data unit must contain at least one of the above

Server Changes

When server/proxy receives agent data and parses it in process_mass_data() it should set if it contains the value and/or meta data in AGENT_RESULT. This structure contains zbx_log_t. Both must be changed in the following way:

typedef struct
{
        char            *value;
        char            *source;
        int             timestamp;
        int             severity;
        int             logeventid;
}
zbx_log_t;

#define ISSET_VALUE(res)        ((res)->type & (AR_UINT64 | AR_DOUBLE | AR_STRING | AR_TEXT | AR_LOG))

/* agent result types */
#define AR_UINT64       0x01
#define AR_DOUBLE       0x02
#define AR_STRING       0x04
#define AR_TEXT         0x08
#define AR_LOG          0x10
#define AR_MESSAGE      0x20
#define AR_META         0x40
/* agent return structure */
typedef struct
{
        int             type;
        zbx_uint64_t    ui64;
        double          dbl;
        char            *str;
        char            *text;
        char            *msg;
        zbx_log_t       log;
        zbx_uint64_t    lastlogsize;
        int             mtime;
}
AGENT_RESULT;

Currently AGENT_RESULT contains a pointer to an array of logs. An array is needed only for vmware item vmware.eventlog, which returns more than one event. It was decided to change AGENT_RESULT structure to contain only one log result, thus logs field must be changed to log. This can potentially introduce regression as this structure is part of Zabbix modules implementation.

In order to allow handling of multiple log results in vmware.eventlog the function get_value() and get_value_simple() must be changed to accept additional parameter - pointer to vmware events. In poller.c, for such items, instead of calling dc_add_history() once, it must be called for every event.

/* result of simple check vmware.eventlog */
typedef struct
{
        char            *value;
        int             logeventid;
        int             timestamp;
        zbx_uint64_t    lastlogsize;
}
zbx_vmware_event_t;

static int      get_value(DC_ITEM *item, AGENT_RESULT *result, zbx_vector_ptr_t *vmware_events)

Also check_vcenter_eventlog() must be changed to return events in passed vmare_events vector.

The following functions must be modified to adopt changes in AGENT_RESULT structure:

  • add_log_result()
  • get_result_value_by_type()
  • zbx_logs_free() should be removed
  • dc_add_history()

The following functions must be changed to allow passing 3 additional parameters: lastlogsize, mtime and flags:

  • dc_local_add_history_dbl()
  • dc_local_add_history_uint()
  • dc_local_add_history_str()
  • dc_local_add_history_text()

These functions must set new parameters in dc_item_value_t structure. If the value is missing from result, flag ZBX_DC_FLAG_NOVALUE must be set. The structures for storing result locally and in the history cache must be changed in the following way:

#define ZBX_DC_FLAG_META        0x01    /* contains meta information (lastlogsize and mtime) */
#define ZBX_DC_FLAG_NOVALUE     0x02    /* entry contains no value */
#define ZBX_DC_FLAG_LLD         0x04    /* low-level discovery value */
#define ZBX_DC_FLAG_UNDEF       0x08    /* unsupported or undefined (delta calculation failed) value */

typedef struct
{
        zbx_uint64_t    itemid;
        dc_value_t      value;
        zbx_timespec_t  ts;
        dc_value_str_t  source;         /* for log items only */
        zbx_uint64_t    lastlogsize;
        int             timestamp;      /* for log items only */
        int             severity;       /* for log items only */
        int             logeventid;     /* for log items only */
        int             mtime;
        unsigned char   value_type;
        unsigned char   state;
        unsigned char   flags;          /* see ZBX_DC_FLAG_* above */
}
dc_item_value_t;

typedef struct
{
        zbx_uint64_t    itemid;
        history_value_t value_orig;     /* empty if flag ZBX_DC_FLAG_NOVALUE is set */
        history_value_t value;          /* used as source for log items */
        zbx_uint64_t    lastlogsize;
        zbx_timespec_t  ts;
        int             timestamp;
        int             severity;
        int             logeventid;
        int             mtime;
        unsigned char   value_type;
        unsigned char   flags;          /* see ZBX_DC_FLAG_* above */
        unsigned char   keep_history;
        unsigned char   keep_trends;
        unsigned char   state;
}
ZBX_DC_HISTORY;

value_undef should be removed and the flag ZBX_DC_FLAG_UNDEF must be used accordingly.

Function DCadd_update_item_sql() must be changed to update lastlogsize and mtime of items with any value type.

Functions DCmass_update_trends(), DCmass_update_triggers() and DCinventory_value_add() must ignore records with no value (ZBX_DC_FLAG_NOVALUE).

DB syncers should also ignore records with no value.

Proxy Changes

Function dc_add_proxy_history_meta() must be added in order to save the meta information in proxy_history table:

static void     dc_add_proxy_history_meta(ZBX_DC_HISTORY *history, int history_num)

The following flags must be added for storing data in proxy_history.flags field in the database:

/* proxy_history flags */
#define PROXY_HISTORY_FLAG_META         0x01
#define PROXY_HISTORY_FLAG_NOVALUE      0x02

proxy_get_history_data() must be changed to:

  • send general log file information (logeventid, source etc.) to the server based on value type check (currently meta flag check)
  • send meta information update only if flag AR_META is set
  • send value only if ISSET_VALUE returns true

Database Changes

In table proxy_history the meta field must be renamed to flags.

Records with meta=1 in proxy_history table must be changed to value 3 (previously meta records never contained a value).

Documentation

  • upgrade notes regarding possible regressions in modules (AGENT_RESULT structure changes)

ChangeLog

  • v0.1 Initial version
  • v0.2 Change specs to separate meta information from log item information
  • v0.3 Change specs to store single log value in AGENT_RESULT
  • v1.0 Adopt new changes for vmware monitoring